From 9f06d353519748d9a51cd9228af3bc3b53357a1f Mon Sep 17 00:00:00 2001
From: Bob Mottram
Date: Sun, 17 Sep 2023 15:46:01 +0100
Subject: [PATCH] Warn when replying to an account or instance which may be
blocking
---
webapp_create_post.py | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/webapp_create_post.py b/webapp_create_post.py
index 6ba4098bf..733792a8b 100644
--- a/webapp_create_post.py
+++ b/webapp_create_post.py
@@ -24,6 +24,7 @@ from utils import get_currencies
from utils import get_category_types
from utils import get_account_timezone
from utils import get_supported_languages
+from utils import text_in_file
from webapp_utils import edit_check_box
from webapp_utils import get_buy_links
from webapp_utils import html_following_data_list
@@ -373,6 +374,33 @@ def html_new_post(edit_post_params: {},
'" rel="nofollow noopener noreferrer" ' + \
'target="_blank">' + \
translate['this post'] + '
\n'
+
+ # is sending posts to this account blocked?
+ send_block_filename = \
+ acct_dir(base_dir, nickname, domain) + \
+ '/send_blocks.txt'
+ if os.path.isfile(send_block_filename):
+ reply_actor = in_reply_to
+ reply_nickname = get_nickname_from_actor(in_reply_to)
+ if reply_nickname:
+ reply_actor = \
+ in_reply_to.split('/' + reply_nickname)[0] + \
+ '/' + reply_nickname
+ if text_in_file(reply_actor,
+ send_block_filename, False):
+ new_post_text += \
+ ' ' + \
+ translate['FollowAccountWarning'] + \
+ '
\n'
+ else:
+ reply_domain, _ = \
+ get_domain_from_actor(reply_actor)
+ if text_in_file('://' + reply_domain + '\n',
+ send_block_filename, False):
+ new_post_text += \
+ ' ' + \
+ translate['FollowWarning'] + '
\n'
+
if post_json_object:
timezone = \
get_account_timezone(base_dir, nickname, domain)