From 4a8d8b34a87d5ed57259d9dcf1d74c3b88177fdf Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 18 Oct 2019 10:28:00 +0100 Subject: [PATCH] More support for zap style ActivityPub --- posts.py | 2 ++ webinterface.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/posts.py b/posts.py index 4286ed142..580c693e7 100644 --- a/posts.py +++ b/posts.py @@ -2402,6 +2402,8 @@ def downloadAnnounce(session,baseDir: str,httpPrefix: str,nickname: str,domain: else: print('Downloading Announce content for '+postJsonObject['object']) asHeader={'Accept': 'application/activity+json; profile="https://www.w3.org/ns/activitystreams"'} + if '/channel/' in postJsonObject['actor']: + asHeader={'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'} actorNickname=getNicknameFromActor(postJsonObject['actor']) actorDomain,actorPort=getDomainFromActor(postJsonObject['actor']) announcedJson=getJson(session,postJsonObject['object'],asHeader,None,projectVersion,httpPrefix,domain) diff --git a/webinterface.py b/webinterface.py index e592bba2d..f35afede0 100644 --- a/webinterface.py +++ b/webinterface.py @@ -82,6 +82,8 @@ def updateAvatarImageCache(session,baseDir: str,httpPrefix: str,actor: str,avata print('Failed to download avatar image: '+str(avatarUrl)) print(e) sessionHeaders = {'Accept': 'application/activity+json; profile="https://www.w3.org/ns/activitystreams"'} + if '/channel/' in actor: + sessionHeaders = {'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'} personJson = getJson(session,actor,sessionHeaders,None,__version__,httpPrefix,None) if personJson: if not personJson.get('id'): @@ -1924,9 +1926,12 @@ def individualPostAsHtml(iconsDir: str,translate: {}, \ attachmentCtr+=1 attachmentStr+='' - #if not avatarUrl: - avatarUrl=getPersonAvatarUrl(baseDir,postJsonObject['actor'],personCache) - avatarUrl=updateAvatarImageCache(session,baseDir,httpPrefix,postJsonObject['actor'],avatarUrl,personCache) + if not avatarUrl: + avatarUrl=getPersonAvatarUrl(baseDir,postJsonObject['actor'],personCache) + avatarUrl=updateAvatarImageCache(session,baseDir,httpPrefix,postJsonObject['actor'],avatarUrl,personCache) + else: + updateAvatarImageCache(session,baseDir,httpPrefix,postJsonObject['actor'],avatarUrl,personCache) + if not avatarUrl: avatarUrl=postJsonObject['actor']+'/avatar.png'