merge-requests/30/head
Bob Mottram 2021-07-21 11:48:24 +01:00
parent 0f36625d47
commit b3da026bac
1 changed files with 78 additions and 75 deletions

View File

@ -772,28 +772,51 @@ def _getPostTitleAnnounceHtml(baseDir: str,
"""
titleStr = ''
replyAvatarImageInPost = ''
objJson = postJsonObject['object']
# has no attribution
if not objJson.get('attributedTo'):
titleStr += \
_announceUnattributedHtml(translate, postJsonObject)
return (titleStr, replyAvatarImageInPost,
containerClassIcons, containerClass)
if postJsonObject['object'].get('attributedTo'):
attributedTo = ''
if isinstance(postJsonObject['object']['attributedTo'], str):
attributedTo = postJsonObject['object']['attributedTo']
if isinstance(objJson['attributedTo'], str):
attributedTo = objJson['attributedTo']
# boosting your own toot
if attributedTo.startswith(postActor):
titleStr += _boostOwnTootHtml(translate)
else:
return (titleStr, replyAvatarImageInPost,
containerClassIcons, containerClass)
# boosting another person's post
_logPostTiming(enableTimingLog, postStartTime, '13.2')
announceNickname = None
if attributedTo:
announceNickname = getNicknameFromActor(attributedTo)
if announceNickname:
if not announceNickname:
titleStr += \
_announceUnattributedHtml(translate, postJsonObject)
return (titleStr, replyAvatarImageInPost,
containerClassIcons, containerClass)
announceDomain, announcePort = \
getDomainFromActor(attributedTo)
getPersonFromCache(baseDir, attributedTo,
personCache, allowDownloads)
announceDisplayName = \
getDisplayName(baseDir, attributedTo, personCache)
if announceDisplayName:
if not announceDisplayName:
titleStr += \
_announceWithoutDisplayNameHtml(translate,
announceNickname,
announceDomain,
postJsonObject)
return (titleStr, replyAvatarImageInPost,
containerClassIcons, containerClass)
_logPostTiming(enableTimingLog, postStartTime, '13.3')
# add any emoji to the display name
@ -809,8 +832,7 @@ def _getPostTitleAnnounceHtml(baseDir: str,
postJsonObject,
announceDisplayName)
# show avatar of person replied to
announceActor = \
postJsonObject['object']['attributedTo']
announceActor = objJson['attributedTo']
announceAvatarUrl = \
getPersonAvatarUrl(baseDir, announceActor,
personCache, allowDownloads)
@ -821,35 +843,16 @@ def _getPostTitleAnnounceHtml(baseDir: str,
idx = 'Show options for this person'
if '/users/news/' not in announceAvatarUrl:
replyAvatarImageInPost = \
' ' \
'<div class=' + \
'"timeline-avatar-reply">\n' \
' ' + \
'<a class="imageAnchor" ' + \
'href="/users/' + nickname + \
'?options=' + \
announceActor + ';' + \
str(pageNumber) + \
';' + announceAvatarUrl + \
messageIdStr + '">' \
' <div class="timeline-avatar-reply">\n' \
' <a class="imageAnchor" ' + \
'href="/users/' + nickname + '?options=' + \
announceActor + ';' + str(pageNumber) + \
';' + announceAvatarUrl + messageIdStr + '">' \
'<img loading="lazy" src="' + \
announceAvatarUrl + '" ' + \
'title="' + translate[idx] + \
'" alt=" "' + avatarPosition + \
getBrokenLinkSubstitute() + \
'/></a>\n </div>\n'
else:
titleStr += \
_announceWithoutDisplayNameHtml(translate,
announceNickname,
announceDomain,
postJsonObject)
else:
titleStr += \
_announceUnattributedHtml(translate, postJsonObject)
else:
titleStr += \
_announceUnattributedHtml(translate, postJsonObject)
getBrokenLinkSubstitute() + '/></a>\n </div>\n'
return (titleStr, replyAvatarImageInPost,
containerClassIcons, containerClass)