From ffde81d90907242b072e2ff8bbeab6f1ea3b4789 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 16 Aug 2019 16:04:40 +0100 Subject: [PATCH] testing --- daemon.py | 2 +- inbox.py | 27 +++++++++++++++++++-------- like.py | 7 ++++++- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/daemon.py b/daemon.py index e840b6205..5d693d8b4 100644 --- a/daemon.py +++ b/daemon.py @@ -134,7 +134,7 @@ def readFollowList(filename: str): return followlist class PubServer(BaseHTTPRequestHandler): - protocol_version = 'HTTP/1.0' + protocol_version = 'HTTP/1.1' def _login_headers(self,fileFormat: str,length: int) -> None: self.send_response(200) diff --git a/inbox.py b/inbox.py index 27c691617..69acdede7 100644 --- a/inbox.py +++ b/inbox.py @@ -197,17 +197,23 @@ def savePostToInboxQueue(baseDir: str,httpPrefix: str,nickname: str, domain: str originalPostId=None if postJsonObject.get('id'): originalPostId=postJsonObject['id'].replace('/activity','') + + currTime=datetime.datetime.utcnow() + + postId=None + if postJsonObject.get('id'): + #if '/statuses/' not in postJsonObject['id']: + postId=postJsonObject['id'].replace('/activity','') + published=currTime.strftime("%Y-%m-%dT%H:%M:%SZ") + if not postId: + statusNumber,published = getStatusNumber() + if actor: + postId=actor+'/statuses/'+statusNumber + else: + postId=httpPrefix+'://'+originalDomain+'/users/'+nickname+'/statuses/'+statusNumber - statusNumber,published = getStatusNumber() - if actor: - postId=actor+'/statuses/'+statusNumber - else: - postId=httpPrefix+'://'+originalDomain+'/users/'+nickname+'/statuses/'+statusNumber # NOTE: don't change postJsonObject['id'] before signature check - currTime=datetime.datetime.utcnow() - published=currTime.strftime("%Y-%m-%dT%H:%M:%SZ") - inboxQueueDir=createInboxQueueDir(nickname,domain,baseDir) handle=nickname+'@'+domain @@ -1160,6 +1166,11 @@ def runInboxQueue(projectVersion: str, \ if debug: print('DEBUG: Signature check success') + # set the id to the same as the post filename + # This makes the filename and the id consistent + #if queueJson['post'].get('id'): + # queueJson['post']['id']=queueJson['id'] + if receiveUndo(session, \ baseDir,httpPrefix,port, \ sendThreads,postLog, \ diff --git a/like.py b/like.py index 09823b9e4..9f6fd4c60 100644 --- a/like.py +++ b/like.py @@ -167,6 +167,10 @@ def like(session,baseDir: str,federationList: [],nickname: str,domain: str,port: if likedPostNickname: postFilename=locatePost(baseDir,nickname,domain,objectUrl) if not postFilename: + print('DEBUG: like baseDir: '+baseDir) + print('DEBUG: like nickname: '+nickname) + print('DEBUG: like domain: '+domain) + print('DEBUG: like objectUrl: '+objectUrl) return None updateLikesCollection(postFilename,objectUrl,newLikeJson['actor'],debug) @@ -193,7 +197,8 @@ def likePost(session,baseDir: str,federationList: [], \ """ likeDomain=likeDomain if likePort!=80 and likePort!=443: - likeDomain=likeDomain+':'+str(likePort) + if ':' not in likeDomain: + likeDomain=likeDomain+':'+str(likePort) objectUrl = \ httpPrefix + '://'+likeDomain+'/users/'+likeNickname+ \