diff --git a/daemon.py b/daemon.py index 163717b94..bf1ee0a95 100644 --- a/daemon.py +++ b/daemon.py @@ -410,6 +410,7 @@ class PubServerUnitTest(PubServer): class EpicyonServer(ThreadingHTTPServer): starting_daemon = True + hide_announces = {} no_of_books = 0 max_api_blocks = 32000 block_federated_endpoints = None @@ -801,6 +802,9 @@ def run_daemon(accounts_data_dir: str, # for each account whether to hide announces httpd.hide_announces = {} + hide_announces_filename = data_dir(base_dir) + '/hide_announces.json' + if os.path.isfile(hide_announces_filename): + httpd.hide_announces = load_json(hide_announces_filename) # number of book events which show on profile screens httpd.no_of_books = no_of_books diff --git a/daemon_get.py b/daemon_get.py index d4f23265f..e522acb9e 100644 --- a/daemon_get.py +++ b/daemon_get.py @@ -85,6 +85,7 @@ from httpcodes import http_304 from httpcodes import http_400 from httpcodes import http_503 from httpcodes import write2 +from utils import save_json from utils import data_dir from utils import user_agent_domain from utils import local_network_host @@ -3013,6 +3014,24 @@ def daemon_http_get(self) -> None: '_GET', 'hashtag search done', self.server.debug) + # hide announces button in the web interface + if html_getreq and users_in_path and \ + self.path.endswith('/hideannounces') and \ + authorized: + nickname = self.path.split('/users/')[1] + if '/' in nickname: + nickname = nickname.split('/')[0] + if self.server.hide_announces.get('nickname'): + del self.server.hide_announces['nickname'] + else: + self.server.hide_announces['nickname'] = True + hide_announces_filename = \ + data_dir(self.server.base_dir) + '/hide_announces.json' + save_json(self.server.hide_announces, hide_announces_filename) + self.path = get_default_path(self.server.media_instance, + self.server.blogs_instance, + nickname) + # show or hide buttons in the web interface if html_getreq and users_in_path and \ self.path.endswith('/minimal') and \ @@ -3020,13 +3039,13 @@ def daemon_http_get(self) -> None: nickname = self.path.split('/users/')[1] if '/' in nickname: nickname = nickname.split('/')[0] - not_min = not is_minimal(self.server.base_dir, - self.server.domain, nickname) - set_minimal(self.server.base_dir, - self.server.domain, nickname, not_min) - self.path = get_default_path(self.server.media_instance, - self.server.blogs_instance, - nickname) + not_min = not is_minimal(self.server.base_dir, + self.server.domain, nickname) + set_minimal(self.server.base_dir, + self.server.domain, nickname, not_min) + self.path = get_default_path(self.server.media_instance, + self.server.blogs_instance, + nickname) # search for a fediverse address, shared item or emoji # from the web interface by selecting search icon