From ffa28e81f8e312aa8a68693686a4044ceabbeda0 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 29 Jun 2019 15:41:23 +0100 Subject: [PATCH] Combine --- daemon.py | 7 +++---- epicyon.py | 4 +--- person.py | 2 +- posts.py | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/daemon.py b/daemon.py index 3eeac0f9..71f704ce 100644 --- a/daemon.py +++ b/daemon.py @@ -97,11 +97,10 @@ class PubServer(BaseHTTPRequestHandler): if self._webfinger(): return # get outbox feed for a person - outboxHeader,outboxFeed=personOutboxJson(thisDomain,self.path,useHttps,maxPostsInFeed) - if outboxHeader and outboxFeed: + outboxFeed=personOutboxJson(thisDomain,self.path,useHttps,maxPostsInFeed) + if outboxFeed: self._set_headers('application/json') - outboxFeedList=[outboxHeader,outboxFeed] - self.wfile.write(json.dumps(outboxFeedList).encode('utf-8')) + self.wfile.write(json.dumps(outboxFeed).encode('utf-8')) return # look up a person getPerson = personLookup(thisDomain,self.path) diff --git a/epicyon.py b/epicyon.py index 8d528b4c..8130624b 100644 --- a/epicyon.py +++ b/epicyon.py @@ -39,9 +39,7 @@ setPreferredUsername(username,domain,'badger') setBio(username,domain,'Some personal info') #createPublicPost(username, domain, https, "G'day world!", False, True, None, None, 'Not suitable for Vogons') #archivePosts(username,domain,4) -#outboxHeader,outboxJson=createOutbox(username,domain,https,3,None) -#pprint(outboxHeader) -#print('\n') +#outboxJson=createOutbox(username,domain,https,3,None) #pprint(outboxJson) runDaemon(domain,port,federationList,useTor) diff --git a/person.py b/person.py index c586e9fb..6038a95c 100644 --- a/person.py +++ b/person.py @@ -160,7 +160,7 @@ def personLookup(domain: str,path: str) -> {}: personJson=commentjson.load(fp) 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 """ if not path.endswith('/outbox'): diff --git a/posts.py b/posts.py index a736d0ae..e6fad5ae 100644 --- a/posts.py +++ b/posts.py @@ -259,7 +259,7 @@ def createPublicPost(username: str, domain: str, https: bool, content: str, foll commentjson.dump(newPost, fp, indent=4, sort_keys=False) 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 """ prefix='https' @@ -333,7 +333,7 @@ def createOutbox(username: str,domain: str,https: bool,noOfItems: int,startMessa break except Exception as e: print(e) - return outboxHeader,outboxItems + return [outboxHeader,outboxItems] def archivePosts(username: str,domain: str,maxPostsInOutbox=256) -> None: """Retain a maximum number of posts within the outbox