Handle missing items list

main2
Bob Mottram 2019-09-11 17:09:53 +01:00
parent 89f72579ca
commit 4004e231e5
1 changed files with 12 additions and 14 deletions

View File

@ -117,7 +117,8 @@ def updateLikesCollection(postFilename: str,objectUrl: str, actor: str,debug: bo
} }
postJsonObject['object']['likes']=likesJson postJsonObject['object']['likes']=likesJson
else: else:
if postJsonObject['object']['likes'].get('items'): if not postJsonObject['object']['likes'].get('items'):
postJsonObject['object']['likes']['items']=[]
for likeItem in postJsonObject['object']['likes']['items']: for likeItem in postJsonObject['object']['likes']['items']:
if likeItem.get('actor'): if likeItem.get('actor'):
if likeItem['actor']==actor: if likeItem['actor']==actor:
@ -128,9 +129,6 @@ def updateLikesCollection(postFilename: str,objectUrl: str, actor: str,debug: bo
} }
postJsonObject['object']['likes']['items'].append(newLike) postJsonObject['object']['likes']['items'].append(newLike)
postJsonObject['object']['likes']['totalItems']=len(postJsonObject['likes']['items']) postJsonObject['object']['likes']['totalItems']=len(postJsonObject['likes']['items'])
else:
if debug:
print('DEBUG: likes section of post has no items list')
if debug: if debug:
print('DEBUG: saving post with likes added') print('DEBUG: saving post with likes added')