mirror of https://gitlab.com/bashrc2/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
|
# For follow activities add a 'to' field, which is a copy of the object field
|
||||||
messageJson,toFieldExists=addToField('Follow',messageJson,self.server.debug)
|
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)
|
pprint(messageJson)
|
||||||
|
|
||||||
|
|
2
inbox.py
2
inbox.py
|
@ -125,7 +125,7 @@ def inboxMessageHasParams(messageJson: {}) -> bool:
|
||||||
if not messageJson.get(param):
|
if not messageJson.get(param):
|
||||||
return False
|
return False
|
||||||
if not messageJson.get('to'):
|
if not messageJson.get('to'):
|
||||||
allowedWithoutToParam=['Follow','Request','Accept','Capability','Undo']
|
allowedWithoutToParam=['Like','Follow','Request','Accept','Capability','Undo']
|
||||||
if messageJson['type'] not in allowedWithoutToParam:
|
if messageJson['type'] not in allowedWithoutToParam:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
13
posts.py
13
posts.py
|
@ -1270,7 +1270,10 @@ def addToField(activityType: str,postJsonObject: {},debug: bool) -> ({},bool):
|
||||||
isSameType=True
|
isSameType=True
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: "to" field assigned to Follow')
|
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
|
toFieldAdded=True
|
||||||
elif isinstance(postJsonObject['object'], dict):
|
elif isinstance(postJsonObject['object'], dict):
|
||||||
if postJsonObject['object'].get('type'):
|
if postJsonObject['object'].get('type'):
|
||||||
|
@ -1279,7 +1282,10 @@ def addToField(activityType: str,postJsonObject: {},debug: bool) -> ({},bool):
|
||||||
if isinstance(postJsonObject['object']['object'], str):
|
if isinstance(postJsonObject['object']['object'], str):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: "to" field assigned to Follow')
|
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']]
|
postJsonObject['to']=[postJsonObject['object']['object']]
|
||||||
toFieldAdded=True
|
toFieldAdded=True
|
||||||
|
|
||||||
|
@ -1319,6 +1325,9 @@ def sendToNamedAddresses(session,baseDir: str, \
|
||||||
recipientsObject=postJsonObject['object']
|
recipientsObject=postJsonObject['object']
|
||||||
else:
|
else:
|
||||||
postJsonObject,fieldAdded=addToField('Follow',postJsonObject,debug)
|
postJsonObject,fieldAdded=addToField('Follow',postJsonObject,debug)
|
||||||
|
if not fieldAdded:
|
||||||
|
return
|
||||||
|
postJsonObject,fieldAdded=addToField('Like',postJsonObject,debug)
|
||||||
if not fieldAdded:
|
if not fieldAdded:
|
||||||
return
|
return
|
||||||
recipientsObject=postJsonObject
|
recipientsObject=postJsonObject
|
||||||
|
|
Loading…
Reference in New Issue