don't show icons on posts from blocked accounts/instances

merge-requests/30/head
Bob Mottram 2023-01-30 20:56:47 +00:00
parent 8da545cb72
commit d88f16f089
2 changed files with 16 additions and 2 deletions

View File

@ -12282,7 +12282,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.access_keys, self.server.access_keys,
self.server.min_images_for_accounts, self.server.min_images_for_accounts,
self.server.debug, self.server.debug,
self.server.buy_sites) self.server.buy_sites,
self.server.blocked_cache)
if conv_str: if conv_str:
msg = conv_str.encode('utf-8') msg = conv_str.encode('utf-8')
msglen = len(msg) msglen = len(msg)

View File

@ -11,6 +11,9 @@ __module_group__ = "Timeline"
import os import os
from conversation import download_conversation_posts from conversation import download_conversation_posts
from utils import get_config_param from utils import get_config_param
from utils import get_nickname_from_actor
from utils import get_domain_from_actor
from blocking import is_blocked
from webapp_utils import html_header_with_external_style from webapp_utils import html_header_with_external_style
from webapp_utils import html_post_separator from webapp_utils import html_post_separator
from webapp_utils import html_footer from webapp_utils import html_footer
@ -42,7 +45,8 @@ def html_conversation_view(post_id: str,
timezone: str, bold_reading: bool, timezone: str, bold_reading: bool,
dogwhistles: {}, access_keys: {}, dogwhistles: {}, access_keys: {},
min_images_for_accounts: [], min_images_for_accounts: [],
debug: bool, buy_sites: {}) -> str: debug: bool, buy_sites: {},
blocked_cache: []) -> str:
"""Show a page containing a conversation thread """Show a page containing a conversation thread
""" """
conv_posts = \ conv_posts = \
@ -70,6 +74,15 @@ def html_conversation_view(post_id: str,
minimize_all_images = True minimize_all_images = True
for post_json_object in conv_posts: for post_json_object in conv_posts:
show_individual_post_icons = True show_individual_post_icons = True
from_actor = post_json_object['object']['attributedTo']
from_nickname = get_nickname_from_actor(from_actor)
from_domain, _ = get_domain_from_actor(from_actor)
# don't show icons on posts from blocked accounts/instances
if from_nickname and from_domain:
if is_blocked(base_dir, nickname, domain,
from_nickname, from_domain,
blocked_cache):
show_individual_post_icons = False
allow_deletion = False allow_deletion = False
post_str = \ post_str = \
individual_post_as_html(signing_priv_key_pem, individual_post_as_html(signing_priv_key_pem,