From c20df95b54aa8520ac736cc2ca016717d06e2621 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 14 May 2022 18:07:20 +0100 Subject: [PATCH] Unblock button on profile after search --- daemon.py | 39 ++++++++++++++++++++++++++++++++++++++- webapp_profile.py | 19 ++++++++++++++++--- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/daemon.py b/daemon.py index f43b38807..11438fa05 100644 --- a/daemon.py +++ b/daemon.py @@ -3503,6 +3503,42 @@ class PubServer(BaseHTTPRequestHandler): self.server.domain, self.server.onion_domain, self.server.i2p_domain) + + if '&submitUnblock=' in follow_confirm_params: + blocking_actor = \ + urllib.parse.unquote_plus(follow_confirm_params) + blocking_actor = blocking_actor.split('actor=')[1] + if '&' in blocking_actor: + blocking_actor = blocking_actor.split('&')[0] + blocking_nickname = get_nickname_from_actor(blocking_actor) + if not blocking_nickname: + if calling_domain.endswith('.onion') and onion_domain: + origin_path_str = 'http://' + onion_domain + users_path + elif (calling_domain.endswith('.i2p') and i2p_domain): + origin_path_str = 'http://' + i2p_domain + users_path + print('WARN: unable to find blocked nickname in ' + + blocking_actor) + self._redirect_headers(origin_path_str, + cookie, calling_domain) + self.server.postreq_busy = False + return + blocking_domain, blocking_port = \ + get_domain_from_actor(blocking_actor) + blocking_domain_full = \ + get_full_domain(blocking_domain, blocking_port) + if follower_nickname == blocking_nickname and \ + blocking_domain == domain and \ + blocking_port == port: + if debug: + print('You cannot unblock yourself!') + else: + if debug: + print(follower_nickname + ' stops blocking ' + + blocking_actor) + remove_block(base_dir, + follower_nickname, domain, + blocking_nickname, blocking_domain_full) + if calling_domain.endswith('.onion') and onion_domain: origin_path_str = 'http://' + onion_domain + users_path elif (calling_domain.endswith('.i2p') and i2p_domain): @@ -20864,6 +20900,7 @@ def run_daemon(preferred_podcast_formats: [], 'snoozeButton': 's', 'reportButton': '[', 'viewButton': 'v', + 'unblockButton': 'u', 'enterPetname': 'p', 'enterNotes': 'n', 'menuTimeline': 't', @@ -20881,7 +20918,7 @@ def run_daemon(preferred_podcast_formats: [], 'menuShares': 'h', 'menuWanted': 'w', 'menuBlogs': 'b', - 'menuNewswire': 'u', + 'menuNewswire': '#', 'menuLinks': 'l', 'menuMedia': 'm', 'menuModeration': 'o', diff --git a/webapp_profile.py b/webapp_profile.py index cbc9ab419..e418b5233 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -74,6 +74,7 @@ from blog import get_blog_address from webapp_post import individual_post_as_html from webapp_timeline import html_individual_share from blocking import get_cw_list_variable +from blocking import is_blocked from content import bold_reading_string THEME_FORMATS = '.zip, .gz' @@ -307,6 +308,9 @@ def html_profile_after_search(css_cache: {}, # don't follow yourself! follow_is_permitted = False + blocked = \ + is_blocked(base_dir, nickname, domain, search_nickname, search_domain) + if follow_is_permitted: follow_str = 'Follow' if is_group: @@ -316,15 +320,24 @@ def html_profile_after_search(css_cache: {}, '
\n' + \ '
\n' + \ - '
\n' + \ + '
\n' + profile_str += \ ' \n' + \ ' \n' + \ + translate[follow_str] + '\n' + profile_str += \ ' \n' + \ + translate['View'] + '\n' + if blocked: + profile_str += \ + ' \n' + profile_str += \ '
\n' + \ ' \n' + \ '
\n'