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