diff --git a/daemon.py b/daemon.py index a47f91832..884fbfc22 100644 --- a/daemon.py +++ b/daemon.py @@ -7401,7 +7401,7 @@ class PubServer(BaseHTTPRequestHandler): updateLikesCollection(recentPostsCache, baseDir, likedPostFilename, likeUrl, likeActor, self.postToNickname, - domain, debug) + domain, debug, likedPostJson) likeUrl = origPostUrl likedPostFilename = origFilename if debug: @@ -7409,7 +7409,7 @@ class PubServer(BaseHTTPRequestHandler): updateLikesCollection(recentPostsCache, baseDir, likedPostFilename, likeUrl, likeActor, self.postToNickname, domain, - debug) + debug, None) if debug: print('Regenerating html post for changed likes collection') # clear the icon from the cache so that it gets updated @@ -7570,7 +7570,8 @@ class PubServer(BaseHTTPRequestHandler): if origFilename and origPostUrl: undoLikesCollectionEntry(recentPostsCache, baseDir, likedPostFilename, - likeUrl, undoActor, domain, debug) + likeUrl, undoActor, domain, debug, + likedPostJson) likeUrl = origPostUrl likedPostFilename = origFilename if debug: @@ -7578,7 +7579,7 @@ class PubServer(BaseHTTPRequestHandler): undoLikesCollectionEntry(recentPostsCache, baseDir, likedPostFilename, likeUrl, - undoActor, domain, debug) + undoActor, domain, debug, None) if debug: print('Regenerating html post for changed likes collection') if likedPostJson: diff --git a/inbox.py b/inbox.py index 90695248b..3902c4967 100644 --- a/inbox.py +++ b/inbox.py @@ -940,7 +940,7 @@ def _receiveLike(recentPostsCache: {}, likeActor, postLikedId) updateLikesCollection(recentPostsCache, baseDir, postFilename, postLikedId, likeActor, - handleName, domain, debug) + handleName, domain, debug, None) # regenerate the html likedPostJson = loadJson(postFilename, 0, 1) if likedPostJson: @@ -961,7 +961,7 @@ def _receiveLike(recentPostsCache: {}, postLikedId, likeActor, handleName, - domain, debug) + domain, debug, None) if likedPostJson: if debug: cachedPostFilename = \ @@ -1052,7 +1052,7 @@ def _receiveUndoLike(recentPostsCache: {}, likeActor = messageJson['actor'] postLikedId = messageJson['object'] undoLikesCollectionEntry(recentPostsCache, baseDir, postFilename, - postLikedId, likeActor, domain, debug) + postLikedId, likeActor, domain, debug, None) # regenerate the html likedPostJson = loadJson(postFilename, 0, 1) if likedPostJson: @@ -1069,7 +1069,8 @@ def _receiveUndoLike(recentPostsCache: {}, postFilename = announceLikedFilename undoLikesCollectionEntry(recentPostsCache, baseDir, postFilename, postLikedId, - likeActor, domain, debug) + likeActor, domain, debug, + None) if likedPostJson: if debug: cachedPostFilename = \ diff --git a/like.py b/like.py index 848890998..a83af9aba 100644 --- a/like.py +++ b/like.py @@ -129,7 +129,7 @@ def _like(recentPostsCache: {}, updateLikesCollection(recentPostsCache, baseDir, postFilename, objectUrl, newLikeJson['actor'], - nickname, domain, debug) + nickname, domain, debug, None) sendSignedJson(newLikeJson, session, baseDir, nickname, domain, port, @@ -368,7 +368,7 @@ def outboxLike(recentPostsCache: {}, updateLikesCollection(recentPostsCache, baseDir, postFilename, messageId, messageJson['actor'], - nickname, domain, debug) + nickname, domain, debug, None) if debug: print('DEBUG: post liked via c2s - ' + postFilename) @@ -404,7 +404,7 @@ def outboxUndoLike(recentPostsCache: {}, return True undoLikesCollectionEntry(recentPostsCache, baseDir, postFilename, messageId, messageJson['actor'], - domain, debug) + domain, debug, None) if debug: print('DEBUG: post undo liked via c2s - ' + postFilename) @@ -412,10 +412,12 @@ def outboxUndoLike(recentPostsCache: {}, def updateLikesCollection(recentPostsCache: {}, baseDir: str, postFilename: str, objectUrl: str, actor: str, - nickname: str, domain: str, debug: bool) -> None: + nickname: str, domain: str, debug: bool, + postJsonObject: {}) -> None: """Updates the likes collection within a post """ - postJsonObject = loadJson(postFilename) + if not postJsonObject: + postJsonObject = loadJson(postFilename) if not postJsonObject: return diff --git a/utils.py b/utils.py index 50007b2dd..47572bfb0 100644 --- a/utils.py +++ b/utils.py @@ -2161,10 +2161,12 @@ def getFileCaseInsensitive(path: str) -> str: def undoLikesCollectionEntry(recentPostsCache: {}, baseDir: str, postFilename: str, objectUrl: str, - actor: str, domain: str, debug: bool) -> None: + actor: str, domain: str, debug: bool, + postJsonObject: {}) -> None: """Undoes a like for a particular actor """ - postJsonObject = loadJson(postFilename) + if not postJsonObject: + postJsonObject = loadJson(postFilename) if not postJsonObject: return # remove any cached version of this post so that the