mirror of https://gitlab.com/bashrc2/epicyon
Showing announced posts
parent
7c5317224a
commit
e70a9b96c5
29
announce.py
29
announce.py
|
@ -73,33 +73,14 @@ def outboxAnnounce(recentPostsCache: {},
|
|||
return False
|
||||
|
||||
|
||||
def announcedByPerson(postJsonObject: {}, nickname: str, domain: str) -> bool:
|
||||
def announcedByPerson(isAnnounced: bool, postJsonObject: {},
|
||||
nickname: str, domainFull: str) -> bool:
|
||||
"""Returns True if the given post is announced by the given person
|
||||
"""
|
||||
if not postJsonObject.get('type'):
|
||||
if not postJsonObject.get('actor'):
|
||||
return False
|
||||
if not postJsonObject.get('object'):
|
||||
return False
|
||||
if isinstance(postJsonObject['object'], str):
|
||||
if postJsonObject['type'] == 'Announce' and \
|
||||
postJsonObject.get('actor'):
|
||||
actorMatch = domain + '/users/' + nickname
|
||||
if postJsonObject['actor'].endswith(actorMatch):
|
||||
return True
|
||||
elif not isinstance(postJsonObject['object'], dict):
|
||||
return False
|
||||
# not to be confused with shared items
|
||||
if not postJsonObject['object'].get('shares'):
|
||||
return False
|
||||
if not isinstance(postJsonObject['object']['shares'], dict):
|
||||
return False
|
||||
if not postJsonObject['object']['shares'].get('items'):
|
||||
return False
|
||||
if not isinstance(postJsonObject['object']['shares']['items'], list):
|
||||
return False
|
||||
actorMatch = domain + '/users/' + nickname
|
||||
for item in postJsonObject['object']['shares']['items']:
|
||||
if item['actor'].endswith(actorMatch):
|
||||
if isAnnounced and \
|
||||
postJsonObject['actor'].endswith(domainFull + '/users/' + nickname):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
|
|
@ -385,7 +385,8 @@ def _getEditIconHtml(baseDir: str, nickname: str, domainFull: str,
|
|||
return editStr
|
||||
|
||||
|
||||
def _getAnnounceIconHtml(nickname: str, domainFull: str,
|
||||
def _getAnnounceIconHtml(isAnnounced: bool,
|
||||
nickname: str, domainFull: str,
|
||||
postJsonObject: {},
|
||||
isPublicRepeat: bool,
|
||||
isModerationPost: bool,
|
||||
|
@ -412,7 +413,8 @@ def _getAnnounceIconHtml(nickname: str, domainFull: str,
|
|||
announceLink = 'repeatprivate'
|
||||
announceTitle = translate['Repeat this post']
|
||||
|
||||
if announcedByPerson(postJsonObject, nickname, domainFull):
|
||||
if announcedByPerson(isAnnounced,
|
||||
postJsonObject, nickname, domainFull):
|
||||
announceIcon = 'repeat.png'
|
||||
announceEmoji = '🔁 '
|
||||
announceLink = 'unrepeat'
|
||||
|
@ -1311,6 +1313,7 @@ def individualPostAsHtml(allowDownloads: bool,
|
|||
baseDir, announceFilename,
|
||||
postActor, domainFull, False)
|
||||
|
||||
# create a file for use by text-to-speech
|
||||
if isRecentPost(postJsonObject):
|
||||
if postJsonObject.get('actor'):
|
||||
if not os.path.isfile(announceFilename + '.tts'):
|
||||
|
@ -1407,7 +1410,8 @@ def individualPostAsHtml(allowDownloads: bool,
|
|||
translate, isEvent)
|
||||
|
||||
announceStr = \
|
||||
_getAnnounceIconHtml(nickname, domainFull,
|
||||
_getAnnounceIconHtml(isAnnounced,
|
||||
nickname, domainFull,
|
||||
postJsonObject,
|
||||
isPublicRepeat,
|
||||
isModerationPost,
|
||||
|
|
Loading…
Reference in New Issue