Allow for accumulating domains

main
Bob Mottram 2020-07-08 11:30:29 +01:00
parent 66204e96dc
commit b1516507f8
2 changed files with 11 additions and 9 deletions

View File

@ -448,9 +448,10 @@ if args.postDomains:
args.port = 80 args.port = 80
elif args.gnunet: elif args.gnunet:
proxyType = 'gnunet' proxyType = 'gnunet'
domainList = []
domainList = getPublicPostDomains(baseDir, nickname, domain, False, True, domainList = getPublicPostDomains(baseDir, nickname, domain, False, True,
proxyType, args.port, httpPrefix, debug, proxyType, args.port, httpPrefix, debug,
__version__) __version__, domainList)
for postDomain in domainList: for postDomain in domainList:
print(postDomain) print(postDomain)
sys.exit() sys.exit()

View File

@ -447,7 +447,7 @@ def getPostDomains(session, outboxUrl: str, maxPosts: int,
personCache: {}, raw: bool, personCache: {}, raw: bool,
simple: bool, debug: bool, simple: bool, debug: bool,
projectVersion: str, httpPrefix: str, projectVersion: str, httpPrefix: str,
domain: str) -> []: domain: str, domainList=[]) -> []:
"""Returns a list of domains referenced within public posts """Returns a list of domains referenced within public posts
""" """
if not outboxUrl: if not outboxUrl:
@ -461,7 +461,7 @@ def getPostDomains(session, outboxUrl: str, maxPosts: int,
'Accept': 'application/ld+json; profile="' + profileStr + '"' 'Accept': 'application/ld+json; profile="' + profileStr + '"'
} }
postDomains = [] postDomains = domainList
i = 0 i = 0
userFeed = parseUserFeed(session, outboxUrl, asHeader, userFeed = parseUserFeed(session, outboxUrl, asHeader,
@ -2988,12 +2988,13 @@ def getPublicPostsOfPerson(baseDir: str, nickname: str, domain: str,
def getPublicPostDomains(baseDir: str, nickname: str, domain: str, def getPublicPostDomains(baseDir: str, nickname: str, domain: str,
raw: bool, simple: bool, proxyType: str, raw: bool, simple: bool, proxyType: str,
port: int, httpPrefix: str, port: int, httpPrefix: str,
debug: bool, projectVersion: str) -> []: debug: bool, projectVersion: str,
domainList=[]) -> []:
""" Returns a list of domains referenced within public posts """ Returns a list of domains referenced within public posts
""" """
session = createSession(proxyType) session = createSession(proxyType)
if not session: if not session:
return return domainList
personCache = {} personCache = {}
cachedWebfingers = {} cachedWebfingers = {}
federationList = [] federationList = []
@ -3008,11 +3009,11 @@ def getPublicPostDomains(baseDir: str, nickname: str, domain: str,
webfingerHandle(session, handle, httpPrefix, cachedWebfingers, webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
domain, projectVersion) domain, projectVersion)
if not wfRequest: if not wfRequest:
return [] return domainList
if not isinstance(wfRequest, dict): if not isinstance(wfRequest, dict):
print('Webfinger for ' + handle + ' did not return a dict. ' + print('Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest)) str(wfRequest))
return [] return domainList
(personUrl, pubKeyId, pubKey, (personUrl, pubKeyId, pubKey,
personId, shaedInbox, personId, shaedInbox,
@ -3025,10 +3026,10 @@ def getPublicPostDomains(baseDir: str, nickname: str, domain: str,
maxEmoji = 99 maxEmoji = 99
maxAttachments = 5 maxAttachments = 5
postDomains = \ postDomains = \
getPostDomains(session, personUrl, 60, maxMentions, maxEmoji, getPostDomains(session, personUrl, 64, maxMentions, maxEmoji,
maxAttachments, federationList, maxAttachments, federationList,
personCache, raw, simple, debug, personCache, raw, simple, debug,
projectVersion, httpPrefix, domain) projectVersion, httpPrefix, domain, domainList)
postDomains.sort() postDomains.sort()
return postDomains return postDomains