diff --git a/inbox.py b/inbox.py index 71ab10a0..c071f4a4 100644 --- a/inbox.py +++ b/inbox.py @@ -387,13 +387,19 @@ def receiveLike(session,handle: str,baseDir: str, \ return False if not os.path.isdir(baseDir+'/accounts/'+handle): print('DEBUG: unknown recipient of like - '+handle) + # if this post in the outbox of the person? boxName='outbox' postFilename=baseDir+'/accounts/'+handle+'/'+boxName+'/'+messageJson['object'].replace('/','#')+'.json' if not os.path.isfile(postFilename): + # if this post in the inbox of the person? boxName='inbox' postFilename=baseDir+'/accounts/'+handle+'/'+boxName+'/'+messageJson['object'].replace('/','#')+'.json' if not os.path.isfile(postFilename): - postFilename=None + # if this post in the shared inbox? + handle='inbox@'+domain + postFilename=baseDir+'/accounts/'+handle+'/'+boxName+'/'+messageJson['object'].replace('/','#')+'.json' + if not os.path.isfile(postFilename): + postFilename=None if not postFilename: if debug: print('DEBUG: post not found in inbox or outbox') diff --git a/like.py b/like.py index 51816984..21452ec0 100644 --- a/like.py +++ b/like.py @@ -86,13 +86,23 @@ def updateLikesCollection(postFilename: str,objectUrl: str, actor: str) -> None: 'id': objectUrl, 'type': 'Collection', "totalItems": 1, - 'items': [actor] + 'items': [{ + 'type': 'Like', + 'actor': actor + + }] } postJson['likes']=likesJson else: if postJson['likes'].get('items'): - if actor not in postJson['likes']['items']: - postJson['likes']['items'].append(actor) + for likeItem in postJson['likes']['items']: + if likeItem['actor']==actor: + return + newLike={ + 'type': 'Like', + 'actor': actor + } + postJson['likes']['items'].append(newLike) postJson['likes']['totalItems']=len(postJson['likes']['items']) with open(postFilename, 'w') as fp: commentjson.dump(postJson, fp, indent=4, sort_keys=True)