forked from indymedia/epicyon
Conform to activitystreams collection structure
parent
12150b752f
commit
cb79ddb760
8
inbox.py
8
inbox.py
|
@ -387,13 +387,19 @@ def receiveLike(session,handle: str,baseDir: str, \
|
||||||
return False
|
return False
|
||||||
if not os.path.isdir(baseDir+'/accounts/'+handle):
|
if not os.path.isdir(baseDir+'/accounts/'+handle):
|
||||||
print('DEBUG: unknown recipient of like - '+handle)
|
print('DEBUG: unknown recipient of like - '+handle)
|
||||||
|
# if this post in the outbox of the person?
|
||||||
boxName='outbox'
|
boxName='outbox'
|
||||||
postFilename=baseDir+'/accounts/'+handle+'/'+boxName+'/'+messageJson['object'].replace('/','#')+'.json'
|
postFilename=baseDir+'/accounts/'+handle+'/'+boxName+'/'+messageJson['object'].replace('/','#')+'.json'
|
||||||
if not os.path.isfile(postFilename):
|
if not os.path.isfile(postFilename):
|
||||||
|
# if this post in the inbox of the person?
|
||||||
boxName='inbox'
|
boxName='inbox'
|
||||||
postFilename=baseDir+'/accounts/'+handle+'/'+boxName+'/'+messageJson['object'].replace('/','#')+'.json'
|
postFilename=baseDir+'/accounts/'+handle+'/'+boxName+'/'+messageJson['object'].replace('/','#')+'.json'
|
||||||
if not os.path.isfile(postFilename):
|
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 not postFilename:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: post not found in inbox or outbox')
|
print('DEBUG: post not found in inbox or outbox')
|
||||||
|
|
16
like.py
16
like.py
|
@ -86,13 +86,23 @@ def updateLikesCollection(postFilename: str,objectUrl: str, actor: str) -> None:
|
||||||
'id': objectUrl,
|
'id': objectUrl,
|
||||||
'type': 'Collection',
|
'type': 'Collection',
|
||||||
"totalItems": 1,
|
"totalItems": 1,
|
||||||
'items': [actor]
|
'items': [{
|
||||||
|
'type': 'Like',
|
||||||
|
'actor': actor
|
||||||
|
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
postJson['likes']=likesJson
|
postJson['likes']=likesJson
|
||||||
else:
|
else:
|
||||||
if postJson['likes'].get('items'):
|
if postJson['likes'].get('items'):
|
||||||
if actor not in postJson['likes']['items']:
|
for likeItem in postJson['likes']['items']:
|
||||||
postJson['likes']['items'].append(actor)
|
if likeItem['actor']==actor:
|
||||||
|
return
|
||||||
|
newLike={
|
||||||
|
'type': 'Like',
|
||||||
|
'actor': actor
|
||||||
|
}
|
||||||
|
postJson['likes']['items'].append(newLike)
|
||||||
postJson['likes']['totalItems']=len(postJson['likes']['items'])
|
postJson['likes']['totalItems']=len(postJson['likes']['items'])
|
||||||
with open(postFilename, 'w') as fp:
|
with open(postFilename, 'w') as fp:
|
||||||
commentjson.dump(postJson, fp, indent=4, sort_keys=True)
|
commentjson.dump(postJson, fp, indent=4, sort_keys=True)
|
||||||
|
|
Loading…
Reference in New Issue