forked from indymedia/epicyon
Conform to activitystreams collection structure
parent
12150b752f
commit
cb79ddb760
6
inbox.py
6
inbox.py
|
@ -387,11 +387,17 @@ 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):
|
||||
# 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:
|
||||
|
|
16
like.py
16
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)
|
||||
|
|
Loading…
Reference in New Issue