forked from indymedia/epicyon
Add to fields to like activity
parent
3beab5e7c5
commit
115127c730
|
@ -409,6 +409,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
|
||||
# For follow activities add a 'to' field, which is a copy of the object field
|
||||
messageJson,toFieldExists=addToField('Follow',messageJson,self.server.debug)
|
||||
|
||||
# For like activities add a 'to' field, which is a copy of the actor within the object field
|
||||
messageJson,toFieldExists=addToField('Like',messageJson,self.server.debug)
|
||||
|
||||
pprint(messageJson)
|
||||
|
||||
|
|
2
inbox.py
2
inbox.py
|
@ -125,7 +125,7 @@ def inboxMessageHasParams(messageJson: {}) -> bool:
|
|||
if not messageJson.get(param):
|
||||
return False
|
||||
if not messageJson.get('to'):
|
||||
allowedWithoutToParam=['Follow','Request','Accept','Capability','Undo']
|
||||
allowedWithoutToParam=['Like','Follow','Request','Accept','Capability','Undo']
|
||||
if messageJson['type'] not in allowedWithoutToParam:
|
||||
return False
|
||||
return True
|
||||
|
|
13
posts.py
13
posts.py
|
@ -1270,7 +1270,10 @@ def addToField(activityType: str,postJsonObject: {},debug: bool) -> ({},bool):
|
|||
isSameType=True
|
||||
if debug:
|
||||
print('DEBUG: "to" field assigned to Follow')
|
||||
postJsonObject['to']=[postJsonObject['object']]
|
||||
toAddress=postJsonObject['object']
|
||||
if '/statuses/' in toAddress:
|
||||
toAddress=toAddress.split('/statuses/')[0]
|
||||
postJsonObject['to']=[toAddress]
|
||||
toFieldAdded=True
|
||||
elif isinstance(postJsonObject['object'], dict):
|
||||
if postJsonObject['object'].get('type'):
|
||||
|
@ -1279,7 +1282,10 @@ def addToField(activityType: str,postJsonObject: {},debug: bool) -> ({},bool):
|
|||
if isinstance(postJsonObject['object']['object'], str):
|
||||
if debug:
|
||||
print('DEBUG: "to" field assigned to Follow')
|
||||
postJsonObject['object']['to']=[postJsonObject['object']['object']]
|
||||
toAddress=postJsonObject['object']['object']
|
||||
if '/statuses/' in toAddress:
|
||||
toAddress=toAddress.split('/statuses/')[0]
|
||||
postJsonObject['object']['to']=[toAddress]
|
||||
postJsonObject['to']=[postJsonObject['object']['object']]
|
||||
toFieldAdded=True
|
||||
|
||||
|
@ -1319,6 +1325,9 @@ def sendToNamedAddresses(session,baseDir: str, \
|
|||
recipientsObject=postJsonObject['object']
|
||||
else:
|
||||
postJsonObject,fieldAdded=addToField('Follow',postJsonObject,debug)
|
||||
if not fieldAdded:
|
||||
return
|
||||
postJsonObject,fieldAdded=addToField('Like',postJsonObject,debug)
|
||||
if not fieldAdded:
|
||||
return
|
||||
recipientsObject=postJsonObject
|
||||
|
|
Loading…
Reference in New Issue