mirror of https://gitlab.com/bashrc2/epicyon
Conversation view by non-authorized viewers
parent
a7c0e187b5
commit
f076bf3d05
|
@ -109,7 +109,8 @@ def unmute_conversation(base_dir: str, nickname: str, domain: str,
|
||||||
conversation_filename + '.muted')
|
conversation_filename + '.muted')
|
||||||
|
|
||||||
|
|
||||||
def download_conversation_posts(session, http_prefix: str, base_dir: str,
|
def download_conversation_posts(authorized: bool, session,
|
||||||
|
http_prefix: str, base_dir: str,
|
||||||
nickname: str, domain: str,
|
nickname: str, domain: str,
|
||||||
post_id: str, debug: bool) -> []:
|
post_id: str, debug: bool) -> []:
|
||||||
"""Downloads all posts for a conversation and returns a list of the
|
"""Downloads all posts for a conversation and returns a list of the
|
||||||
|
@ -126,13 +127,15 @@ def download_conversation_posts(session, http_prefix: str, base_dir: str,
|
||||||
post_id = remove_id_ending(post_id)
|
post_id = remove_id_ending(post_id)
|
||||||
post_filename = \
|
post_filename = \
|
||||||
locate_post(base_dir, nickname, domain, post_id)
|
locate_post(base_dir, nickname, domain, post_id)
|
||||||
|
post_json_object = None
|
||||||
if post_filename:
|
if post_filename:
|
||||||
post_json_object = load_json(post_filename)
|
post_json_object = load_json(post_filename)
|
||||||
else:
|
else:
|
||||||
post_json_object = \
|
if authorized:
|
||||||
get_json(signing_priv_key_pem, session, post_id,
|
post_json_object = \
|
||||||
as_header, None, debug, __version__,
|
get_json(signing_priv_key_pem, session, post_id,
|
||||||
http_prefix, domain)
|
as_header, None, debug, __version__,
|
||||||
|
http_prefix, domain)
|
||||||
if debug:
|
if debug:
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
print(post_id + ' returned no json')
|
print(post_id + ' returned no json')
|
||||||
|
@ -181,6 +184,9 @@ def download_conversation_posts(session, http_prefix: str, base_dir: str,
|
||||||
harmless_markup(post_json_object)
|
harmless_markup(post_json_object)
|
||||||
|
|
||||||
conversation_view = [post_json_object] + conversation_view
|
conversation_view = [post_json_object] + conversation_view
|
||||||
|
if not authorized:
|
||||||
|
# only show a single post to non-authorized viewers
|
||||||
|
break
|
||||||
if not post_json_object['object'].get('inReplyTo'):
|
if not post_json_object['object'].get('inReplyTo'):
|
||||||
if debug:
|
if debug:
|
||||||
print(post_id + ' is not a reply')
|
print(post_id + ' is not a reply')
|
||||||
|
@ -189,13 +195,15 @@ def download_conversation_posts(session, http_prefix: str, base_dir: str,
|
||||||
post_id = remove_id_ending(post_id)
|
post_id = remove_id_ending(post_id)
|
||||||
post_filename = \
|
post_filename = \
|
||||||
locate_post(base_dir, nickname, domain, post_id)
|
locate_post(base_dir, nickname, domain, post_id)
|
||||||
|
post_json_object = None
|
||||||
if post_filename:
|
if post_filename:
|
||||||
post_json_object = load_json(post_filename)
|
post_json_object = load_json(post_filename)
|
||||||
else:
|
else:
|
||||||
post_json_object = \
|
if authorized:
|
||||||
get_json(signing_priv_key_pem, session, post_id,
|
post_json_object = \
|
||||||
as_header, None, debug, __version__,
|
get_json(signing_priv_key_pem, session, post_id,
|
||||||
http_prefix, domain)
|
as_header, None, debug, __version__,
|
||||||
|
http_prefix, domain)
|
||||||
if debug:
|
if debug:
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
print(post_id + ' returned no json')
|
print(post_id + ' returned no json')
|
||||||
|
|
|
@ -12330,7 +12330,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if self.server.bold_reading.get(nickname):
|
if self.server.bold_reading.get(nickname):
|
||||||
bold_reading = True
|
bold_reading = True
|
||||||
conv_str = \
|
conv_str = \
|
||||||
html_conversation_view(post_id, self.server.translate,
|
html_conversation_view(authorized,
|
||||||
|
post_id, self.server.translate,
|
||||||
base_dir,
|
base_dir,
|
||||||
http_prefix,
|
http_prefix,
|
||||||
nickname,
|
nickname,
|
||||||
|
|
|
@ -1181,7 +1181,7 @@ def _command_options() -> None:
|
||||||
if not nickname:
|
if not nickname:
|
||||||
print('Please specify a nickname with the --nickname option')
|
print('Please specify a nickname with the --nickname option')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
conv_json = download_conversation_posts(session, http_prefix,
|
conv_json = download_conversation_posts(True, session, http_prefix,
|
||||||
base_dir, nickname, domain,
|
base_dir, nickname, domain,
|
||||||
post_id, argb.debug)
|
post_id, argb.debug)
|
||||||
if conv_json:
|
if conv_json:
|
||||||
|
|
|
@ -13,6 +13,7 @@ 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_nickname_from_actor
|
||||||
from utils import get_domain_from_actor
|
from utils import get_domain_from_actor
|
||||||
|
from utils import is_public_post
|
||||||
from blocking import is_blocked
|
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
|
||||||
|
@ -20,7 +21,7 @@ from webapp_utils import html_footer
|
||||||
from webapp_post import individual_post_as_html
|
from webapp_post import individual_post_as_html
|
||||||
|
|
||||||
|
|
||||||
def html_conversation_view(post_id: str,
|
def html_conversation_view(authorized: bool, post_id: str,
|
||||||
translate: {}, base_dir: str,
|
translate: {}, base_dir: str,
|
||||||
http_prefix: str,
|
http_prefix: str,
|
||||||
nickname: str, domain: str,
|
nickname: str, domain: str,
|
||||||
|
@ -50,7 +51,8 @@ def html_conversation_view(post_id: str,
|
||||||
"""Show a page containing a conversation thread
|
"""Show a page containing a conversation thread
|
||||||
"""
|
"""
|
||||||
conv_posts = \
|
conv_posts = \
|
||||||
download_conversation_posts(session, http_prefix, base_dir,
|
download_conversation_posts(authorized,
|
||||||
|
session, http_prefix, base_dir,
|
||||||
nickname, domain,
|
nickname, domain,
|
||||||
post_id, debug)
|
post_id, debug)
|
||||||
|
|
||||||
|
@ -74,6 +76,11 @@ 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
|
||||||
|
# if not authorized then only show public posts
|
||||||
|
if not authorized:
|
||||||
|
show_individual_post_icons = False
|
||||||
|
if not is_public_post(post_json_object):
|
||||||
|
continue
|
||||||
from_actor = post_json_object['object']['attributedTo']
|
from_actor = post_json_object['object']['attributedTo']
|
||||||
from_nickname = get_nickname_from_actor(from_actor)
|
from_nickname = get_nickname_from_actor(from_actor)
|
||||||
from_domain, _ = get_domain_from_actor(from_actor)
|
from_domain, _ = get_domain_from_actor(from_actor)
|
||||||
|
|
Loading…
Reference in New Issue