master
Bob Mottram 2019-08-16 16:04:40 +01:00
parent d2394b3a69
commit ffde81d909
3 changed files with 26 additions and 10 deletions

View File

@ -134,7 +134,7 @@ def readFollowList(filename: str):
return followlist return followlist
class PubServer(BaseHTTPRequestHandler): class PubServer(BaseHTTPRequestHandler):
protocol_version = 'HTTP/1.0' protocol_version = 'HTTP/1.1'
def _login_headers(self,fileFormat: str,length: int) -> None: def _login_headers(self,fileFormat: str,length: int) -> None:
self.send_response(200) self.send_response(200)

View File

@ -197,17 +197,23 @@ def savePostToInboxQueue(baseDir: str,httpPrefix: str,nickname: str, domain: str
originalPostId=None originalPostId=None
if postJsonObject.get('id'): if postJsonObject.get('id'):
originalPostId=postJsonObject['id'].replace('/activity','') 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 # 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) inboxQueueDir=createInboxQueueDir(nickname,domain,baseDir)
handle=nickname+'@'+domain handle=nickname+'@'+domain
@ -1160,6 +1166,11 @@ def runInboxQueue(projectVersion: str, \
if debug: if debug:
print('DEBUG: Signature check success') 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, \ if receiveUndo(session, \
baseDir,httpPrefix,port, \ baseDir,httpPrefix,port, \
sendThreads,postLog, \ sendThreads,postLog, \

View File

@ -167,6 +167,10 @@ def like(session,baseDir: str,federationList: [],nickname: str,domain: str,port:
if likedPostNickname: if likedPostNickname:
postFilename=locatePost(baseDir,nickname,domain,objectUrl) postFilename=locatePost(baseDir,nickname,domain,objectUrl)
if not postFilename: 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 return None
updateLikesCollection(postFilename,objectUrl,newLikeJson['actor'],debug) updateLikesCollection(postFilename,objectUrl,newLikeJson['actor'],debug)
@ -193,7 +197,8 @@ def likePost(session,baseDir: str,federationList: [], \
""" """
likeDomain=likeDomain likeDomain=likeDomain
if likePort!=80 and likePort!=443: if likePort!=80 and likePort!=443:
likeDomain=likeDomain+':'+str(likePort) if ':' not in likeDomain:
likeDomain=likeDomain+':'+str(likePort)
objectUrl = \ objectUrl = \
httpPrefix + '://'+likeDomain+'/users/'+likeNickname+ \ httpPrefix + '://'+likeDomain+'/users/'+likeNickname+ \