Clearing cache when new announce is received

merge-requests/30/head
Bob Mottram 2021-05-19 20:42:45 +01:00
parent bbde34144f
commit 3b2237dc44
4 changed files with 6 additions and 5 deletions

View File

@ -48,7 +48,8 @@ def outboxAnnounce(recentPostsCache: {},
messageJson['object'])
if postFilename:
updateAnnounceCollection(recentPostsCache, baseDir, postFilename,
messageJson['actor'], domain, debug)
messageJson['actor'],
nickname, domain, debug)
return True
elif messageJson['type'] == 'Undo':
if not isinstance(messageJson['object'], dict):

View File

@ -1398,7 +1398,7 @@ def _receiveAnnounce(recentPostsCache: {},
print(messageJson['object'])
return True
updateAnnounceCollection(recentPostsCache, baseDir, postFilename,
messageJson['actor'], domain, debug)
messageJson['actor'], nickname, domain, debug)
if debug:
print('DEBUG: Downloading announce post ' + messageJson['actor'] +
' -> ' + messageJson['object'])

View File

@ -2010,7 +2010,8 @@ def undoAnnounceCollectionEntry(recentPostsCache: {},
def updateAnnounceCollection(recentPostsCache: {},
baseDir: str, postFilename: str,
actor: str, domain: str, debug: bool) -> None:
actor: str,
nickname: str, domain: str, debug: bool) -> None:
"""Updates the announcements collection within a post
Confusingly this is known as "shares", but isn't the
same as shared items within shares.py
@ -2021,7 +2022,6 @@ def updateAnnounceCollection(recentPostsCache: {},
return
# remove any cached version of this announce so that the announce
# icon is changed
nickname = getNicknameFromActor(actor)
cachedPostFilename = getCachedPostFilename(baseDir, nickname, domain,
postJsonObject)
if cachedPostFilename:

View File

@ -1320,7 +1320,7 @@ def individualPostAsHtml(allowDownloads: bool,
if announceFilename:
updateAnnounceCollection(recentPostsCache,
baseDir, announceFilename,
postActor, domainFull, False)
postActor, nickname, domainFull, False)
# create a file for use by text-to-speech
if isRecentPost(postJsonObject):