diff --git a/webinterface.py b/webinterface.py index 5508094c..00832183 100644 --- a/webinterface.py +++ b/webinterface.py @@ -283,12 +283,13 @@ def updateAvatarImageCache(session, baseDir: str, httpPrefix: str, actor) return None storePersonInCache(baseDir, actor, personJson, personCache) - return getPersonAvatarUrl(baseDir, actor, personCache) + return getPersonAvatarUrl(baseDir, actor, personCache, True) return None return avatarImageFilename.replace(baseDir + '/cache', '') -def getPersonAvatarUrl(baseDir: str, personUrl: str, personCache: {}) -> str: +def getPersonAvatarUrl(baseDir: str, personUrl: str, personCache: {}, + allowDownloads: bool) -> str: """Returns the avatar url for the person """ personJson = getPersonFromCache(baseDir, personUrl, personCache) @@ -797,7 +798,7 @@ def htmlHashtagSearch(nickname: str, domain: str, port: int, showIndividualPostIcons = True allowDeletion = False hashtagSearchForm += \ - individualPostAsHtml(recentPostsCache, + individualPostAsHtml(True, recentPostsCache, maxRecentPosts, iconsDir, translate, None, baseDir, session, wfRequest, @@ -1026,7 +1027,7 @@ def htmlHistorySearch(translate: {}, baseDir: str, showIndividualPostIcons = True allowDeletion = False historySearchForm += \ - individualPostAsHtml(recentPostsCache, + individualPostAsHtml(True, recentPostsCache, maxRecentPosts, iconsDir, translate, None, baseDir, session, wfRequest, @@ -2502,7 +2503,8 @@ def htmlProfilePosts(recentPostsCache: {}, maxRecentPosts: int, for item in outboxFeed['orderedItems']: if item['type'] == 'Create': postStr = \ - individualPostAsHtml(recentPostsCache, maxRecentPosts, + individualPostAsHtml(True, recentPostsCache, + maxRecentPosts, iconsDir, translate, None, baseDir, session, wfRequest, personCache, @@ -3062,7 +3064,7 @@ def individualFollowAsHtml(translate: {}, nickname = getNicknameFromActor(followUrl) domain, port = getDomainFromActor(followUrl) titleStr = '@' + nickname + '@' + domain - avatarUrl = getPersonAvatarUrl(baseDir, followUrl, personCache) + avatarUrl = getPersonAvatarUrl(baseDir, followUrl, personCache, True) if not avatarUrl: avatarUrl = followUrl + '/avatar.png' if domain not in followUrl: @@ -3787,7 +3789,8 @@ def getPostAttachmentsAsHtml(postJsonObject: {}, boxName: str, translate: {}, return attachmentStr, galleryStr -def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int, +def individualPostAsHtml(allowDownloads: bool, + recentPostsCache: {}, maxRecentPosts: int, iconsDir: str, translate: {}, pageNumber: int, baseDir: str, session, wfRequest: {}, personCache: {}, @@ -3849,7 +3852,8 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int, # update avatar if needed if not avatarUrl: avatarUrl = \ - getPersonAvatarUrl(baseDir, postActor, personCache) + getPersonAvatarUrl(baseDir, postActor, personCache, + allowDownloads) # benchmark 2.1 timeDiff = int((time.time() - postStartTime) * 1000) @@ -3884,7 +3888,8 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int, if not avatarUrl: avatarUrl = \ - getPersonAvatarUrl(baseDir, postActor, personCache) + getPersonAvatarUrl(baseDir, postActor, personCache, + allowDownloads) avatarUrl = \ updateAvatarImageCache(session, baseDir, httpPrefix, postActor, avatarUrl, personCache) @@ -4317,7 +4322,8 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int, # benchmark 13.2 timeDiff = int((time.time() - postStartTime) * 1000) if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 13.2 = ' + str(timeDiff)) + print('TIMING INDIV ' + boxName + + ' 13.2 = ' + str(timeDiff)) announceNickname = None if attributedTo: announceNickname = getNicknameFromActor(attributedTo) @@ -4329,9 +4335,11 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int, getDisplayName(baseDir, attributedTo, personCache) if announceDisplayName: # benchmark 13.3 - timeDiff = int((time.time() - postStartTime) * 1000) + timeDiff = \ + int((time.time() - postStartTime) * 1000) if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 13.3 = ' + str(timeDiff)) + print('TIMING INDIV ' + boxName + + ' 13.3 = ' + str(timeDiff)) if ':' in announceDisplayName: announceDisplayName = \ @@ -4340,9 +4348,11 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int, announceDisplayName, False) # benchmark 13.3.1 - timeDiff = int((time.time() - postStartTime) * 1000) + timeDiff = \ + int((time.time() - postStartTime) * 1000) if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 13.3.1 = ' + str(timeDiff)) + print('TIMING INDIV ' + boxName + + ' 13.3.1 = ' + str(timeDiff)) titleStr += \ '