Check that attributedTo is a string

main
Bob Mottram 2021-10-17 13:33:02 +01:00
parent 4c14d606ef
commit 82507d418e
1 changed files with 5 additions and 5 deletions

View File

@ -5062,22 +5062,22 @@ def getOriginalPostFromAnnounceUrl(announceUrl: str, baseDir: str,
return None, None, None return None, None, None
if not isinstance(announcePostJson['object'], str): if not isinstance(announcePostJson['object'], str):
return None, None, None return None, None, None
actor = url = None
# do we have the original post? # do we have the original post?
origPostId = announcePostJson['object'] origPostId = announcePostJson['object']
origFilename = locatePost(baseDir, nickname, domain, origPostId) origFilename = locatePost(baseDir, nickname, domain, origPostId)
actor = url = None
if origFilename: if origFilename:
# we have the original post # we have the original post
origPostJson = loadJson(origFilename, 0, 1) origPostJson = loadJson(origFilename, 0, 1)
if origPostJson: if origPostJson:
url = announcePostJson['object']
if hasObjectDict(origPostJson): if hasObjectDict(origPostJson):
if origPostJson['object'].get('attributedTo'): if origPostJson['object'].get('attributedTo'):
actor = origPostJson['object']['attributedTo'] if isinstance(origPostJson['object']['attributedTo'], str):
actor = origPostJson['object']['attributedTo']
url = origPostId
elif origPostJson['object'].get('actor'): elif origPostJson['object'].get('actor'):
actor = origPostJson['actor'] actor = origPostJson['actor']
else: url = origPostId
url = None
else: else:
# we don't have the original post # we don't have the original post
if hasUsersPath(origPostId): if hasUsersPath(origPostId):