From c8d90863ea4950ea06e46bba551c1455450a0c49 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 6 Jun 2020 19:06:06 +0100 Subject: [PATCH] Directly like/unlike posts This is faster and so should work better with the web interface --- daemon.py | 26 ++++++++++++++++++++++++++ theme.py | 3 --- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/daemon.py b/daemon.py index dcce78fb..34c9873c 100644 --- a/daemon.py +++ b/daemon.py @@ -176,6 +176,8 @@ from outbox import postMessageToOutbox from happening import removeCalendarEvent from bookmarks import bookmark from bookmarks import undoBookmark +from like import updateLikesCollectionEntry +from like import undoLikesCollectionEntry import os @@ -2517,6 +2519,18 @@ class PubServer(BaseHTTPRequestHandler): 'to': [actorLiked], 'object': likeUrl } + # directly like the post file + likedPostFilename = locatePost(self.server.baseDir, + self.postToNickname, + self.server.domain, + actorLiked) + if likedPostFilename: + updateLikesCollectionEntry(self.server.recentPostsCache, + self.server.baseDir, + likedPostFilename, likeUrl, + likeActor, self.server.domain, + self.server.debug) + # send out the like to followers self._postToOutbox(likeJson, self.server.projectVersion) self.server.GETbusy = False actorAbsolute = \ @@ -2599,6 +2613,18 @@ class PubServer(BaseHTTPRequestHandler): 'object': likeUrl } } + # directly undo the like within the post file + likedPostFilename = locatePost(self.server.baseDir, + self.postToNickname, + self.server.domain, + actorLiked) + if likedPostFilename: + undoLikesCollectionEntry(self.server.recentPostsCache, + self.server.baseDir, + likedPostFilename, likeUrl, + likeActor, self.server.domain, + self.server.debug) + # send out the undo like to followers self._postToOutbox(undoLikeJson, self.server.projectVersion) self.server.GETbusy = False actorAbsolute = self.server.httpPrefix + '://' + \ diff --git a/theme.py b/theme.py index 65860064..899968d4 100644 --- a/theme.py +++ b/theme.py @@ -191,12 +191,9 @@ def setThemeNight(baseDir: str): "link-bg-color": "#0f0d10", "main-fg-color": "#7961ab", "main-bg-color-dm": "#0b0a0a", - "main-bg-color-reply": "#030202", - "main-bg-color-report": "#050202", "border-color": "#7961ab", "main-bg-color-reply": "#0f0d10", "main-bg-color-report": "#0f0d10", - "day-number2": "#0f0d10", "hashtag-vertical-spacing3": "100px", "hashtag-vertical-spacing4": "150px", "button-background": "#7961ab",