main
Bob Mottram 2021-07-21 20:46:31 +01:00
parent 20477ef2b2
commit 54ab1b5a12
1 changed files with 20 additions and 42 deletions

View File

@ -776,8 +776,7 @@ def _getPostTitleAnnounceHtml(baseDir: str,
# has no attribution # has no attribution
if not objJson.get('attributedTo'): if not objJson.get('attributedTo'):
titleStr += \ titleStr += _announceUnattributedHtml(translate, postJsonObject)
_announceUnattributedHtml(translate, postJsonObject)
return (titleStr, replyAvatarImageInPost, return (titleStr, replyAvatarImageInPost,
containerClassIcons, containerClass) containerClassIcons, containerClass)
@ -797,23 +796,17 @@ def _getPostTitleAnnounceHtml(baseDir: str,
if attributedTo: if attributedTo:
announceNickname = getNicknameFromActor(attributedTo) announceNickname = getNicknameFromActor(attributedTo)
if not announceNickname: if not announceNickname:
titleStr += \ titleStr += _announceUnattributedHtml(translate, postJsonObject)
_announceUnattributedHtml(translate, postJsonObject)
return (titleStr, replyAvatarImageInPost, return (titleStr, replyAvatarImageInPost,
containerClassIcons, containerClass) containerClassIcons, containerClass)
announceDomain, announcePort = \ announceDomain, announcePort = getDomainFromActor(attributedTo)
getDomainFromActor(attributedTo) getPersonFromCache(baseDir, attributedTo, personCache, allowDownloads)
getPersonFromCache(baseDir, attributedTo, announceDisplayName = getDisplayName(baseDir, attributedTo, personCache)
personCache, allowDownloads)
announceDisplayName = \
getDisplayName(baseDir, attributedTo, personCache)
if not announceDisplayName: if not announceDisplayName:
titleStr += \ titleStr += \
_announceWithoutDisplayNameHtml(translate, _announceWithoutDisplayNameHtml(translate, announceNickname,
announceNickname, announceDomain, postJsonObject)
announceDomain,
postJsonObject)
return (titleStr, replyAvatarImageInPost, return (titleStr, replyAvatarImageInPost,
containerClassIcons, containerClass) containerClassIcons, containerClass)
@ -822,14 +815,11 @@ def _getPostTitleAnnounceHtml(baseDir: str,
# add any emoji to the display name # add any emoji to the display name
if ':' in announceDisplayName: if ':' in announceDisplayName:
announceDisplayName = \ announceDisplayName = \
addEmojiToDisplayName(baseDir, httpPrefix, addEmojiToDisplayName(baseDir, httpPrefix, nickname, domain,
nickname, domain, announceDisplayName, False)
announceDisplayName,
False)
_logPostTiming(enableTimingLog, postStartTime, '13.3.1') _logPostTiming(enableTimingLog, postStartTime, '13.3.1')
titleStr += \ titleStr += \
_announceWithDisplayNameHtml(translate, _announceWithDisplayNameHtml(translate, postJsonObject,
postJsonObject,
announceDisplayName) announceDisplayName)
# show avatar of person replied to # show avatar of person replied to
announceActor = attributedTo announceActor = attributedTo
@ -986,32 +976,23 @@ def _getPostTitleReplyHtml(baseDir: str,
replyActor = inReplyTo.split('/statuses/')[0] replyActor = inReplyTo.split('/statuses/')[0]
replyNickname = getNicknameFromActor(replyActor) replyNickname = getNicknameFromActor(replyActor)
if not replyNickname: if not replyNickname:
titleStr += \ titleStr += _replyToUnknownHtml(translate, postJsonObject)
_replyToUnknownHtml(translate, postJsonObject)
return (titleStr, replyAvatarImageInPost, return (titleStr, replyAvatarImageInPost,
containerClassIcons, containerClass) containerClassIcons, containerClass)
replyDomain, replyPort = \ replyDomain, replyPort = getDomainFromActor(replyActor)
getDomainFromActor(replyActor)
if not (replyNickname and replyDomain): if not (replyNickname and replyDomain):
titleStr += \ titleStr += _replyToUnknownHtml(translate, postJsonObject)
_replyToUnknownHtml(translate, postJsonObject)
return (titleStr, replyAvatarImageInPost, return (titleStr, replyAvatarImageInPost,
containerClassIcons, containerClass) containerClassIcons, containerClass)
getPersonFromCache(baseDir, replyActor, getPersonFromCache(baseDir, replyActor, personCache, allowDownloads)
personCache, replyDisplayName = getDisplayName(baseDir, replyActor, personCache)
allowDownloads)
replyDisplayName = \
getDisplayName(baseDir, replyActor,
personCache)
if not replyDisplayName: if not replyDisplayName:
inReplyTo = objJson['inReplyTo'] inReplyTo = objJson['inReplyTo']
titleStr += \ titleStr += \
_getReplyWithoutDisplayName(translate, _getReplyWithoutDisplayName(translate, inReplyTo,
inReplyTo, replyNickname, replyDomain)
replyNickname,
replyDomain)
return (titleStr, replyAvatarImageInPost, return (titleStr, replyAvatarImageInPost,
containerClassIcons, containerClass) containerClassIcons, containerClass)
@ -1020,13 +1001,11 @@ def _getPostTitleReplyHtml(baseDir: str,
_logPostTiming(enableTimingLog, postStartTime, '13.5') _logPostTiming(enableTimingLog, postStartTime, '13.5')
replyDisplayName = \ replyDisplayName = \
addEmojiToDisplayName(baseDir, httpPrefix, addEmojiToDisplayName(baseDir, httpPrefix, nickname, domain,
nickname, domain,
replyDisplayName, False) replyDisplayName, False)
_logPostTiming(enableTimingLog, postStartTime, '13.6') _logPostTiming(enableTimingLog, postStartTime, '13.6')
titleStr += \ titleStr += _getReplyHtml(translate, inReplyTo, replyDisplayName)
_getReplyHtml(translate, inReplyTo, replyDisplayName)
_logPostTiming(enableTimingLog, postStartTime, '13.7') _logPostTiming(enableTimingLog, postStartTime, '13.7')
@ -1322,8 +1301,7 @@ def individualPostAsHtml(allowDownloads: bool,
postJsonObject = postJsonAnnounce postJsonObject = postJsonAnnounce
announceFilename = \ announceFilename = \
locatePost(baseDir, nickname, domain, locatePost(baseDir, nickname, domain, postJsonObject['id'])
postJsonObject['id'])
if announceFilename: if announceFilename:
updateAnnounceCollection(recentPostsCache, updateAnnounceCollection(recentPostsCache,
baseDir, announceFilename, baseDir, announceFilename,