Check announces

main
Bob Mottram 2021-05-07 14:26:00 +01:00
parent 38c1d68816
commit 469e8304be
1 changed files with 9 additions and 1 deletions

View File

@ -76,9 +76,17 @@ def outboxAnnounce(recentPostsCache: {},
def announcedByPerson(postJsonObject: {}, nickname: str, domain: str) -> bool:
"""Returns True if the given post is announced by the given person
"""
if not postJsonObject.get('type'):
return False
if not postJsonObject.get('object'):
return False
if not isinstance(postJsonObject['object'], dict):
if isinstance(postJsonObject['object'], str):
if postJsonObject['type'] == 'Announce' and \
postJsonObject.get('actor'):
actorMatch = domain + '/users/' + nickname
if postJsonObject['actor'].endswith(actorMatch):
return True
elif not isinstance(postJsonObject['object'], dict):
return False
# not to be confused with shared items
if not postJsonObject['object'].get('shares'):