master
Bob Mottram 2019-06-29 15:41:23 +01:00
parent ed39eb1ac6
commit ffa28e81f8
4 changed files with 7 additions and 10 deletions

View File

@ -97,11 +97,10 @@ class PubServer(BaseHTTPRequestHandler):
if self._webfinger(): if self._webfinger():
return return
# get outbox feed for a person # get outbox feed for a person
outboxHeader,outboxFeed=personOutboxJson(thisDomain,self.path,useHttps,maxPostsInFeed) outboxFeed=personOutboxJson(thisDomain,self.path,useHttps,maxPostsInFeed)
if outboxHeader and outboxFeed: if outboxFeed:
self._set_headers('application/json') self._set_headers('application/json')
outboxFeedList=[outboxHeader,outboxFeed] self.wfile.write(json.dumps(outboxFeed).encode('utf-8'))
self.wfile.write(json.dumps(outboxFeedList).encode('utf-8'))
return return
# look up a person # look up a person
getPerson = personLookup(thisDomain,self.path) getPerson = personLookup(thisDomain,self.path)

View File

@ -39,9 +39,7 @@ setPreferredUsername(username,domain,'badger')
setBio(username,domain,'Some personal info') setBio(username,domain,'Some personal info')
#createPublicPost(username, domain, https, "G'day world!", False, True, None, None, 'Not suitable for Vogons') #createPublicPost(username, domain, https, "G'day world!", False, True, None, None, 'Not suitable for Vogons')
#archivePosts(username,domain,4) #archivePosts(username,domain,4)
#outboxHeader,outboxJson=createOutbox(username,domain,https,3,None) #outboxJson=createOutbox(username,domain,https,3,None)
#pprint(outboxHeader)
#print('\n')
#pprint(outboxJson) #pprint(outboxJson)
runDaemon(domain,port,federationList,useTor) runDaemon(domain,port,federationList,useTor)

View File

@ -160,7 +160,7 @@ def personLookup(domain: str,path: str) -> {}:
personJson=commentjson.load(fp) personJson=commentjson.load(fp)
return personJson return personJson
def personOutboxJson(domain: str,path: str,https: bool,noOfItems: int) -> ({},{}): def personOutboxJson(domain: str,path: str,https: bool,noOfItems: int) -> []:
"""Obtain the outbox feed for the given person """Obtain the outbox feed for the given person
""" """
if not path.endswith('/outbox'): if not path.endswith('/outbox'):

View File

@ -259,7 +259,7 @@ def createPublicPost(username: str, domain: str, https: bool, content: str, foll
commentjson.dump(newPost, fp, indent=4, sort_keys=False) commentjson.dump(newPost, fp, indent=4, sort_keys=False)
return newPost return newPost
def createOutbox(username: str,domain: str,https: bool,noOfItems: int,startMessageId=None) -> ({},{}): def createOutbox(username: str,domain: str,https: bool,noOfItems: int,startMessageId=None) -> []:
"""Constructs the outbox feed """Constructs the outbox feed
""" """
prefix='https' prefix='https'
@ -333,7 +333,7 @@ def createOutbox(username: str,domain: str,https: bool,noOfItems: int,startMessa
break break
except Exception as e: except Exception as e:
print(e) print(e)
return outboxHeader,outboxItems return [outboxHeader,outboxItems]
def archivePosts(username: str,domain: str,maxPostsInOutbox=256) -> None: def archivePosts(username: str,domain: str,maxPostsInOutbox=256) -> None:
"""Retain a maximum number of posts within the outbox """Retain a maximum number of posts within the outbox