If display name is not available locally then try to download it

merge-requests/30/head
Bob Mottram 2021-11-05 23:36:39 +00:00
parent 8222ad2c76
commit 6e42ba3e2f
1 changed files with 25 additions and 1 deletions

View File

@ -9,6 +9,7 @@ __module_group__ = "Web Interface"
import os import os
from pprint import pprint from pprint import pprint
from webfinger import webfingerHandle
from utils import getDisplayName from utils import getDisplayName
from utils import isGroupAccount from utils import isGroupAccount
from utils import hasObjectDict from utils import hasObjectDict
@ -34,6 +35,7 @@ from theme import getThemesList
from person import personBoxJson from person import personBoxJson
from person import getActorJson from person import getActorJson
from person import getPersonAvatarUrl from person import getPersonAvatarUrl
from posts import getPersonBox
from posts import isModerator from posts import isModerator
from posts import parseUserFeed from posts import parseUserFeed
from posts import isCreateInsideAnnounce from posts import isCreateInsideAnnounce
@ -2251,6 +2253,27 @@ def _individualFollowAsHtml(signingPrivateKeyPem: str,
avatarUrl = followUrl + '/avatar.png' avatarUrl = followUrl + '/avatar.png'
displayName = getDisplayName(baseDir, followUrl, personCache) displayName = getDisplayName(baseDir, followUrl, personCache)
isGroup = False
if not displayName:
# lookup the correct webfinger for the followUrl
followUrlHandle = followUrlNickname + '@' + followUrlDomainFull
followUrlWf = \
webfingerHandle(session, followUrlHandle, httpPrefix,
cachedWebfingers,
domain, __version__, debug, False,
signingPrivateKeyPem)
originDomain = domain
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl2,
displayName, isGroup) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session,
followUrlWf,
personCache, projectVersion,
httpPrefix, followUrlNickname,
domain, 'outbox', 43036)
if avatarUrl2:
avatarUrl = avatarUrl2
if displayName: if displayName:
displayName = \ displayName = \
@ -2273,7 +2296,8 @@ def _individualFollowAsHtml(signingPrivateKeyPem: str,
translate['Block'] + '</button></a>\n' translate['Block'] + '</button></a>\n'
elif b == 'unfollow': elif b == 'unfollow':
unfollowStr = 'Unfollow' unfollowStr = 'Unfollow'
if isGroupAccount(baseDir, if isGroup or \
isGroupAccount(baseDir,
followUrlNickname, followUrlDomain): followUrlNickname, followUrlDomain):
unfollowStr = 'Leave' unfollowStr = 'Leave'
buttonsStr += \ buttonsStr += \