master
Bob Mottram 2019-06-29 14:23:46 +01:00
parent 255d498cf7
commit f94f8ae406
1 changed files with 7 additions and 0 deletions

View File

@ -290,20 +290,26 @@ def createOutbox(username: str,domain: str,https: bool,noOfItems: int,startMessa
# Insert posts # Insert posts
for postFilename in postsInOutbox: for postFilename in postsInOutbox:
# Are we at the starting message ID yet?
if startMessageId and prevPostFilename: if startMessageId and prevPostFilename:
if '#statuses#'+startMessageId in postFilename: if '#statuses#'+startMessageId in postFilename:
# update the prev entry for the last message id
postId = prevPostFilename.split('#statuses#')[1].replace('#activity','') postId = prevPostFilename.split('#statuses#')[1].replace('#activity','')
outboxHeader['prev']= \ outboxHeader['prev']= \
prefix+'://'+domain+'/users/'+username+'/outbox?min_id='+postId+'&page=true' prefix+'://'+domain+'/users/'+username+'/outbox?min_id='+postId+'&page=true'
# get the full path of the post file
filePath = os.path.join(outboxDir, postFilename) filePath = os.path.join(outboxDir, postFilename)
try: try:
if os.path.isfile(filePath): if os.path.isfile(filePath):
if postCtr <= noOfItems: if postCtr <= noOfItems:
# get the post as json
with open(filePath, 'r') as fp: with open(filePath, 'r') as fp:
p=commentjson.load(fp) p=commentjson.load(fp)
# insert it into the outbox feed
if postCtr < noOfItems: if postCtr < noOfItems:
outboxItems['orderedItems'].append(p) outboxItems['orderedItems'].append(p)
elif postCtr == noOfItems: elif postCtr == noOfItems:
# if this is the last post update the next message ID
if '/statuses/' in p['id']: if '/statuses/' in p['id']:
postId = p['id'].split('/statuses/')[1].replace('/activity','') postId = p['id'].split('/statuses/')[1].replace('/activity','')
outboxHeader['next']= \ outboxHeader['next']= \
@ -311,6 +317,7 @@ def createOutbox(username: str,domain: str,https: bool,noOfItems: int,startMessa
username+'/outbox?max_id='+ \ username+'/outbox?max_id='+ \
postId+'&page=true' postId+'&page=true'
postCtr += 1 postCtr += 1
# remember the last post filename for use with prev
prevPostFilename = postFilename prevPostFilename = postFilename
if postCtr > noOfItems: if postCtr > noOfItems:
break break