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
|
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
|
"""Returns True if the given post is announced by the given person
|
||||||
"""
|
"""
|
||||||
if not postJsonObject.get('type'):
|
if not postJsonObject.get('actor'):
|
||||||
return False
|
return False
|
||||||
if not postJsonObject.get('object'):
|
if isAnnounced and \
|
||||||
return False
|
postJsonObject['actor'].endswith(domainFull + '/users/' + nickname):
|
||||||
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):
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -385,7 +385,8 @@ def _getEditIconHtml(baseDir: str, nickname: str, domainFull: str,
|
||||||
return editStr
|
return editStr
|
||||||
|
|
||||||
|
|
||||||
def _getAnnounceIconHtml(nickname: str, domainFull: str,
|
def _getAnnounceIconHtml(isAnnounced: bool,
|
||||||
|
nickname: str, domainFull: str,
|
||||||
postJsonObject: {},
|
postJsonObject: {},
|
||||||
isPublicRepeat: bool,
|
isPublicRepeat: bool,
|
||||||
isModerationPost: bool,
|
isModerationPost: bool,
|
||||||
|
@ -412,7 +413,8 @@ def _getAnnounceIconHtml(nickname: str, domainFull: str,
|
||||||
announceLink = 'repeatprivate'
|
announceLink = 'repeatprivate'
|
||||||
announceTitle = translate['Repeat this post']
|
announceTitle = translate['Repeat this post']
|
||||||
|
|
||||||
if announcedByPerson(postJsonObject, nickname, domainFull):
|
if announcedByPerson(isAnnounced,
|
||||||
|
postJsonObject, nickname, domainFull):
|
||||||
announceIcon = 'repeat.png'
|
announceIcon = 'repeat.png'
|
||||||
announceEmoji = '🔁 '
|
announceEmoji = '🔁 '
|
||||||
announceLink = 'unrepeat'
|
announceLink = 'unrepeat'
|
||||||
|
@ -1311,6 +1313,7 @@ def individualPostAsHtml(allowDownloads: bool,
|
||||||
baseDir, announceFilename,
|
baseDir, announceFilename,
|
||||||
postActor, domainFull, False)
|
postActor, domainFull, False)
|
||||||
|
|
||||||
|
# create a file for use by text-to-speech
|
||||||
if isRecentPost(postJsonObject):
|
if isRecentPost(postJsonObject):
|
||||||
if postJsonObject.get('actor'):
|
if postJsonObject.get('actor'):
|
||||||
if not os.path.isfile(announceFilename + '.tts'):
|
if not os.path.isfile(announceFilename + '.tts'):
|
||||||
|
@ -1407,7 +1410,8 @@ def individualPostAsHtml(allowDownloads: bool,
|
||||||
translate, isEvent)
|
translate, isEvent)
|
||||||
|
|
||||||
announceStr = \
|
announceStr = \
|
||||||
_getAnnounceIconHtml(nickname, domainFull,
|
_getAnnounceIconHtml(isAnnounced,
|
||||||
|
nickname, domainFull,
|
||||||
postJsonObject,
|
postJsonObject,
|
||||||
isPublicRepeat,
|
isPublicRepeat,
|
||||||
isModerationPost,
|
isModerationPost,
|
||||||
|
|
Loading…
Reference in New Issue