Get actor from status

main2
Bob Mottram 2019-10-01 14:23:22 +01:00
parent a94665d9a0
commit e986d30367
1 changed files with 41 additions and 27 deletions

View File

@ -984,6 +984,8 @@ def receiveAnnounce(session,handle: str,baseDir: str, \
print('DEBUG: Downloading announce post '+messageJson['object'])
postJsonObject=downloadAnnounce(session,baseDir,httpPrefix,nickname,domain,messageJson,__version__)
if postJsonObject:
if debug:
print('DEBUG: Announce post downloaded for '+messageJson['object'])
# Try to obtain the actor for this person
# so that their avatar can be shown
lookupActor=None
@ -992,6 +994,12 @@ def receiveAnnounce(session,handle: str,baseDir: str, \
if postJsonObject['object'].get('attributedTo'):
lookupActor=postJsonObject['object']['attributedTo']
if lookupActor:
if '/users/' in lookupActor:
if '/statuses/' in lookupActor:
lookupActor=lookupActor.split('/statuses/')[0]
elif '/profile/' in lookupActor:
lookupActor=lookupActor.split('/profile/')[0]
if debug:
print('DEBUG: Obtaining actor for announce post '+lookupActor)
for tries in range(6):
@ -1189,6 +1197,12 @@ def obtainAvatarForReplyPost(session,baseDir: str,httpPrefix: str,domain: str,pe
lookupActor=postJsonObject['object']['inReplyTo']
if lookupActor:
if '/users/' in lookupActor:
if '/statuses/' in lookupActor:
lookupActor=lookupActor.split('/statuses/')[0]
elif '/profile/' in lookupActor:
lookupActor=lookupActor.split('/profile/')[0]
if debug:
print('DEBUG: Obtaining actor for reply post '+lookupActor)
for tries in range(6):