Detecting announces

merge-requests/30/head
Bob Mottram 2021-05-07 23:49:04 +01:00
parent 539766b74d
commit db3243724d
2 changed files with 6 additions and 4 deletions

View File

@ -73,14 +73,14 @@ def outboxAnnounce(recentPostsCache: {},
return False return False
def announcedByPerson(isAnnounced: bool, postJsonObject: {}, def announcedByPerson(isAnnounced: bool, postActor: str,
nickname: str, domainFull: str) -> bool: nickname: str, domainFull: str) -> bool:
"""Returns True if the given post is announced by the given person """Returns True if the given post is announced by the given person
""" """
if not postJsonObject.get('actor'): if not postActor:
return False return False
if isAnnounced and \ if isAnnounced and \
postJsonObject['actor'].endswith(domainFull + '/users/' + nickname): postActor.endswith(domainFull + '/users/' + nickname):
return True return True
return False return False

View File

@ -386,6 +386,7 @@ def _getEditIconHtml(baseDir: str, nickname: str, domainFull: str,
def _getAnnounceIconHtml(isAnnounced: bool, def _getAnnounceIconHtml(isAnnounced: bool,
postActor: str,
nickname: str, domainFull: str, nickname: str, domainFull: str,
postJsonObject: {}, postJsonObject: {},
isPublicRepeat: bool, isPublicRepeat: bool,
@ -414,7 +415,7 @@ def _getAnnounceIconHtml(isAnnounced: bool,
announceTitle = translate['Repeat this post'] announceTitle = translate['Repeat this post']
if announcedByPerson(isAnnounced, if announcedByPerson(isAnnounced,
postJsonObject, nickname, domainFull): postActor, nickname, domainFull):
announceIcon = 'repeat.png' announceIcon = 'repeat.png'
announceEmoji = '🔁 ' announceEmoji = '🔁 '
announceLink = 'unrepeat' announceLink = 'unrepeat'
@ -1411,6 +1412,7 @@ def individualPostAsHtml(allowDownloads: bool,
announceStr = \ announceStr = \
_getAnnounceIconHtml(isAnnounced, _getAnnounceIconHtml(isAnnounced,
postActor,
nickname, domainFull, nickname, domainFull,
postJsonObject, postJsonObject,
isPublicRepeat, isPublicRepeat,