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']) messageJson['object'])
if postFilename: if postFilename:
updateAnnounceCollection(recentPostsCache, baseDir, postFilename, updateAnnounceCollection(recentPostsCache, baseDir, postFilename,
messageJson['actor'], domain, debug) messageJson['actor'],
nickname, domain, debug)
return True return True
elif messageJson['type'] == 'Undo': elif messageJson['type'] == 'Undo':
if not isinstance(messageJson['object'], dict): if not isinstance(messageJson['object'], dict):

View File

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

View File

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

View File

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