mirror of https://gitlab.com/bashrc2/epicyon
Add a to field to bookmarks
parent
4af4cf401e
commit
eada662691
23
posts.py
23
posts.py
|
|
@ -2365,7 +2365,7 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str,
|
||||||
|
|
||||||
def addToField(activityType: str, postJsonObject: {},
|
def addToField(activityType: str, postJsonObject: {},
|
||||||
debug: bool) -> ({}, bool):
|
debug: bool) -> ({}, bool):
|
||||||
"""The Follow activity doesn't have a 'to' field and so one
|
"""The Follow/Add/Remove activity doesn't have a 'to' field and so one
|
||||||
needs to be added so that activity distribution happens in a consistent way
|
needs to be added so that activity distribution happens in a consistent way
|
||||||
Returns true if a 'to' field exists or was added
|
Returns true if a 'to' field exists or was added
|
||||||
"""
|
"""
|
||||||
|
|
@ -2384,19 +2384,34 @@ def addToField(activityType: str, postJsonObject: {},
|
||||||
if postJsonObject['type'] == activityType:
|
if postJsonObject['type'] == activityType:
|
||||||
isSameType = True
|
isSameType = True
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: "to" field assigned to Follow')
|
print('DEBUG: "to" field assigned to ' + activityType)
|
||||||
toAddress = postJsonObject['object']
|
toAddress = postJsonObject['object']
|
||||||
if '/statuses/' in toAddress:
|
if '/statuses/' in toAddress:
|
||||||
toAddress = toAddress.split('/statuses/')[0]
|
toAddress = toAddress.split('/statuses/')[0]
|
||||||
postJsonObject['to'] = [toAddress]
|
postJsonObject['to'] = [toAddress]
|
||||||
toFieldAdded = True
|
toFieldAdded = True
|
||||||
elif isinstance(postJsonObject['object'], dict):
|
elif isinstance(postJsonObject['object'], dict):
|
||||||
if postJsonObject['object'].get('type'):
|
# add a to field to bookmark add or remove
|
||||||
|
if postJsonObject.get('type') and \
|
||||||
|
postJsonObject.get('actor') and \
|
||||||
|
postJsonObject['object'].get('type'):
|
||||||
|
if postJsonObject['type'] == 'Add' or \
|
||||||
|
postJsonObject['type'] == 'Remove':
|
||||||
|
if postJsonObject['object']['type'] == 'Document':
|
||||||
|
postJsonObject['to'] = \
|
||||||
|
[postJsonObject['actor']]
|
||||||
|
postJsonObject['object']['to'] = \
|
||||||
|
[postJsonObject['actor']]
|
||||||
|
toFieldAdded = True
|
||||||
|
|
||||||
|
if not toFieldAdded and \
|
||||||
|
postJsonObject['object'].get('type'):
|
||||||
if postJsonObject['object']['type'] == activityType:
|
if postJsonObject['object']['type'] == activityType:
|
||||||
isSameType = True
|
isSameType = True
|
||||||
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 ' +
|
||||||
|
activityType)
|
||||||
toAddress = postJsonObject['object']['object']
|
toAddress = postJsonObject['object']['object']
|
||||||
if '/statuses/' in toAddress:
|
if '/statuses/' in toAddress:
|
||||||
toAddress = toAddress.split('/statuses/')[0]
|
toAddress = toAddress.split('/statuses/')[0]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue