mirror of https://gitlab.com/bashrc2/epicyon
Displaying remote conversations
parent
5493747add
commit
846381d140
80
daemon.py
80
daemon.py
|
@ -221,6 +221,7 @@ from webapp_suspended import html_suspended
|
||||||
from webapp_tos import html_terms_of_service
|
from webapp_tos import html_terms_of_service
|
||||||
from webapp_confirm import html_confirm_follow
|
from webapp_confirm import html_confirm_follow
|
||||||
from webapp_confirm import html_confirm_unfollow
|
from webapp_confirm import html_confirm_unfollow
|
||||||
|
from webapp_post import html_conversation_thread
|
||||||
from webapp_post import html_emoji_reaction_picker
|
from webapp_post import html_emoji_reaction_picker
|
||||||
from webapp_post import html_post_replies
|
from webapp_post import html_post_replies
|
||||||
from webapp_post import html_individual_post
|
from webapp_post import html_individual_post
|
||||||
|
@ -11801,6 +11802,72 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self._redirect_headers(actor_absolute, cookie, calling_domain)
|
self._redirect_headers(actor_absolute, cookie, calling_domain)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _show_conversation_thread(self, authorized: bool,
|
||||||
|
calling_domain: str, path: str,
|
||||||
|
base_dir: str, http_prefix: str,
|
||||||
|
domain: str, port: int,
|
||||||
|
debug: str, curr_session) -> bool:
|
||||||
|
"""get conversation thread from the date link on a post
|
||||||
|
"""
|
||||||
|
if not authorized:
|
||||||
|
return False
|
||||||
|
if not path.startswith('/users/'):
|
||||||
|
return False
|
||||||
|
if '?convthread=' not in path:
|
||||||
|
return False
|
||||||
|
post_id = path.split('?convthread=')[1].strip()
|
||||||
|
post_id = post_id.replace('--', '/')
|
||||||
|
nickname = path.split('/users/')[1]
|
||||||
|
if '?convthread=' in nickname:
|
||||||
|
nickname = nickname.split('?convthread=')[0]
|
||||||
|
if '/' in nickname:
|
||||||
|
nickname = nickname.split('/')[0]
|
||||||
|
timezone = None
|
||||||
|
if self.server.account_timezone.get(nickname):
|
||||||
|
timezone = \
|
||||||
|
self.server.account_timezone.get(nickname)
|
||||||
|
bold_reading = False
|
||||||
|
if self.server.bold_reading.get(nickname):
|
||||||
|
bold_reading = True
|
||||||
|
conv_str = \
|
||||||
|
html_conversation_thread(post_id, self.server.translate,
|
||||||
|
base_dir,
|
||||||
|
http_prefix,
|
||||||
|
nickname,
|
||||||
|
domain,
|
||||||
|
self.server.project_version,
|
||||||
|
self.server.recent_posts_cache,
|
||||||
|
self.server.max_recent_posts,
|
||||||
|
curr_session,
|
||||||
|
self.server.cached_webfingers,
|
||||||
|
self.server.person_cache,
|
||||||
|
port,
|
||||||
|
self.server.yt_replace_domain,
|
||||||
|
self.server.twitter_replacement_domain,
|
||||||
|
self.server.show_published_date_only,
|
||||||
|
self.server.peertube_instances,
|
||||||
|
self.server.allow_local_network_access,
|
||||||
|
self.server.theme_name,
|
||||||
|
self.server.system_language,
|
||||||
|
self.server.max_like_count,
|
||||||
|
self.server.signing_priv_key_pem,
|
||||||
|
self.server.cw_lists,
|
||||||
|
self.server.lists_enabled,
|
||||||
|
timezone, bold_reading,
|
||||||
|
self.server.dogwhistles,
|
||||||
|
self.server.access_keys,
|
||||||
|
self.server.min_images_for_accounts,
|
||||||
|
self.server.debug)
|
||||||
|
if conv_str:
|
||||||
|
msg = conv_str.encode('utf-8')
|
||||||
|
msglen = len(msg)
|
||||||
|
self._login_headers('text/html',
|
||||||
|
msglen, calling_domain)
|
||||||
|
self._write(msg)
|
||||||
|
self._404()
|
||||||
|
self.server.getreq_busy = False
|
||||||
|
return True
|
||||||
|
|
||||||
def _show_individual_at_post(self, ssml_getreq: bool, authorized: bool,
|
def _show_individual_at_post(self, ssml_getreq: bool, authorized: bool,
|
||||||
calling_domain: str, referer_domain: str,
|
calling_domain: str, referer_domain: str,
|
||||||
path: str,
|
path: str,
|
||||||
|
@ -16419,6 +16486,19 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.debug)
|
self.server.debug)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self._show_conversation_thread(authorized,
|
||||||
|
calling_domain, self.path,
|
||||||
|
self.server.base_dir,
|
||||||
|
self.server.http_prefix,
|
||||||
|
self.server.domain,
|
||||||
|
self.server.port,
|
||||||
|
self.server.debug,
|
||||||
|
self.server.session):
|
||||||
|
fitness_performance(getreq_start_time, self.server.fitness,
|
||||||
|
'_GET', '_show_conversation_thread',
|
||||||
|
self.server.debug)
|
||||||
|
return
|
||||||
|
|
||||||
# shared items catalog for this instance
|
# shared items catalog for this instance
|
||||||
# this is only accessible to instance members or to
|
# this is only accessible to instance members or to
|
||||||
# other instances which present an authorization token
|
# other instances which present an authorization token
|
||||||
|
|
|
@ -21,6 +21,7 @@ from announce import no_of_announces
|
||||||
from like import liked_by_person
|
from like import liked_by_person
|
||||||
from like import no_of_likes
|
from like import no_of_likes
|
||||||
from follow import is_following_actor
|
from follow import is_following_actor
|
||||||
|
from posts import download_conversation_posts
|
||||||
from posts import post_is_muted
|
from posts import post_is_muted
|
||||||
from posts import get_person_box
|
from posts import get_person_box
|
||||||
from posts import download_announce
|
from posts import download_announce
|
||||||
|
@ -91,6 +92,7 @@ from webapp_utils import get_post_attachments_as_html
|
||||||
from webapp_utils import html_header_with_external_style
|
from webapp_utils import html_header_with_external_style
|
||||||
from webapp_utils import html_footer
|
from webapp_utils import html_footer
|
||||||
from webapp_utils import get_broken_link_substitute
|
from webapp_utils import get_broken_link_substitute
|
||||||
|
from webapp_utils import html_post_separator
|
||||||
from webapp_media import add_embedded_elements
|
from webapp_media import add_embedded_elements
|
||||||
from webapp_question import insert_question
|
from webapp_question import insert_question
|
||||||
from devices import e2e_edecrypt_message_from_device
|
from devices import e2e_edecrypt_message_from_device
|
||||||
|
@ -1541,7 +1543,8 @@ def _get_footer_with_icons(show_icons: bool,
|
||||||
bookmark_str: str,
|
bookmark_str: str,
|
||||||
delete_str: str, mute_str: str, edit_str: str,
|
delete_str: str, mute_str: str, edit_str: str,
|
||||||
post_json_object: {}, published_link: str,
|
post_json_object: {}, published_link: str,
|
||||||
time_class: str, published_str: str) -> str:
|
time_class: str, published_str: str,
|
||||||
|
nickname: str) -> str:
|
||||||
"""Returns the html for a post footer containing icons
|
"""Returns the html for a post footer containing icons
|
||||||
"""
|
"""
|
||||||
if not show_icons:
|
if not show_icons:
|
||||||
|
@ -1553,7 +1556,9 @@ def _get_footer_with_icons(show_icons: bool,
|
||||||
reply_str + announce_str + like_str + bookmark_str + reaction_str
|
reply_str + announce_str + like_str + bookmark_str + reaction_str
|
||||||
footer_str += delete_str + mute_str + edit_str
|
footer_str += delete_str + mute_str + edit_str
|
||||||
if not is_news_post(post_json_object):
|
if not is_news_post(post_json_object):
|
||||||
footer_str += ' <a href="' + published_link + '" class="' + \
|
footer_str += ' <a href="/users/' + \
|
||||||
|
nickname + '?convthread=' + \
|
||||||
|
published_link.replace('/', '--') + '" class="' + \
|
||||||
time_class + '" tabindex="10"><span itemprop="datePublished">' + \
|
time_class + '" tabindex="10"><span itemprop="datePublished">' + \
|
||||||
published_str + '</span></a>\n'
|
published_str + '</span></a>\n'
|
||||||
else:
|
else:
|
||||||
|
@ -2289,7 +2294,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
||||||
like_str, reaction_str, bookmark_str,
|
like_str, reaction_str, bookmark_str,
|
||||||
delete_str, mute_str, edit_str,
|
delete_str, mute_str, edit_str,
|
||||||
post_json_object, published_link,
|
post_json_object, published_link,
|
||||||
time_class, published_str)
|
time_class, published_str, nickname)
|
||||||
if new_footer_str:
|
if new_footer_str:
|
||||||
footer_str = new_footer_str
|
footer_str = new_footer_str
|
||||||
|
|
||||||
|
@ -2841,3 +2846,90 @@ def html_emoji_reaction_picker(recent_posts_cache: {}, max_recent_posts: int,
|
||||||
'</header>\n'
|
'</header>\n'
|
||||||
|
|
||||||
return header_str + reacted_to_post_str + emoji_picks_str + html_footer()
|
return header_str + reacted_to_post_str + emoji_picks_str + html_footer()
|
||||||
|
|
||||||
|
|
||||||
|
def html_conversation_thread(post_id: str,
|
||||||
|
translate: {}, base_dir: str,
|
||||||
|
http_prefix: str,
|
||||||
|
nickname: str, domain: str,
|
||||||
|
project_version: str,
|
||||||
|
recent_posts_cache: {},
|
||||||
|
max_recent_posts: int,
|
||||||
|
session,
|
||||||
|
cached_webfingers,
|
||||||
|
person_cache: {},
|
||||||
|
port: int,
|
||||||
|
yt_replace_domain: str,
|
||||||
|
twitter_replacement_domain: str,
|
||||||
|
show_published_date_only: bool,
|
||||||
|
peertube_instances: [],
|
||||||
|
allow_local_network_access: bool,
|
||||||
|
theme_name: str,
|
||||||
|
system_language: str,
|
||||||
|
max_like_count: int,
|
||||||
|
signing_priv_key_pem: str,
|
||||||
|
cw_lists: {},
|
||||||
|
lists_enabled: str,
|
||||||
|
timezone: str, bold_reading: bool,
|
||||||
|
dogwhistles: {}, access_keys: {},
|
||||||
|
min_images_for_accounts: [],
|
||||||
|
debug: bool) -> str:
|
||||||
|
"""Show a page containing a conversation thread
|
||||||
|
"""
|
||||||
|
conv_posts = \
|
||||||
|
download_conversation_posts(session, http_prefix, base_dir,
|
||||||
|
nickname, domain,
|
||||||
|
post_id, debug)
|
||||||
|
|
||||||
|
css_filename = base_dir + '/epicyon-profile.css'
|
||||||
|
if os.path.isfile(base_dir + '/epicyon.css'):
|
||||||
|
css_filename = base_dir + '/epicyon.css'
|
||||||
|
|
||||||
|
instance_title = \
|
||||||
|
get_config_param(base_dir, 'instanceTitle')
|
||||||
|
conv_str = \
|
||||||
|
html_header_with_external_style(css_filename, instance_title, None)
|
||||||
|
|
||||||
|
if len(conv_posts) == 0:
|
||||||
|
conv_str += html_footer()
|
||||||
|
return conv_str
|
||||||
|
|
||||||
|
separator_str = html_post_separator(base_dir, None)
|
||||||
|
|
||||||
|
minimize_all_images = False
|
||||||
|
if nickname in min_images_for_accounts:
|
||||||
|
minimize_all_images = True
|
||||||
|
for post_json_object in conv_posts:
|
||||||
|
show_individual_post_icons = False
|
||||||
|
allow_deletion = False
|
||||||
|
post_str = \
|
||||||
|
individual_post_as_html(signing_priv_key_pem,
|
||||||
|
True, recent_posts_cache,
|
||||||
|
max_recent_posts,
|
||||||
|
translate, None,
|
||||||
|
base_dir, session, cached_webfingers,
|
||||||
|
person_cache,
|
||||||
|
nickname, domain, port,
|
||||||
|
post_json_object,
|
||||||
|
None, True, allow_deletion,
|
||||||
|
http_prefix, project_version,
|
||||||
|
'search',
|
||||||
|
yt_replace_domain,
|
||||||
|
twitter_replacement_domain,
|
||||||
|
show_published_date_only,
|
||||||
|
peertube_instances,
|
||||||
|
allow_local_network_access,
|
||||||
|
theme_name, system_language,
|
||||||
|
max_like_count,
|
||||||
|
show_individual_post_icons,
|
||||||
|
show_individual_post_icons,
|
||||||
|
False, False, False, False,
|
||||||
|
cw_lists, lists_enabled,
|
||||||
|
timezone, False, bold_reading,
|
||||||
|
dogwhistles,
|
||||||
|
minimize_all_images)
|
||||||
|
if post_str:
|
||||||
|
conv_str += separator_str + post_str
|
||||||
|
|
||||||
|
conv_str += html_footer()
|
||||||
|
return conv_str
|
||||||
|
|
|
@ -749,6 +749,7 @@ def html_history_search(translate: {}, base_dir: str,
|
||||||
history_search_form += \
|
history_search_form += \
|
||||||
'<center><h5>' + translate['No results'] + \
|
'<center><h5>' + translate['No results'] + \
|
||||||
'</h5></center>'
|
'</h5></center>'
|
||||||
|
history_search_form += html_footer()
|
||||||
return history_search_form
|
return history_search_form
|
||||||
|
|
||||||
separator_str = html_post_separator(base_dir, None)
|
separator_str = html_post_separator(base_dir, None)
|
||||||
|
|
Loading…
Reference in New Issue