mirror of https://gitlab.com/bashrc2/epicyon
Handle replying to unlisted posts
parent
d77d397bca
commit
998fa21b13
20
daemon.py
20
daemon.py
|
@ -16799,6 +16799,26 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if self.server.debug:
|
if self.server.debug:
|
||||||
print('DEBUG: replyto path ' + self.path)
|
print('DEBUG: replyto path ' + self.path)
|
||||||
|
|
||||||
|
# unlisted reply
|
||||||
|
if '?replyunlisted=' in self.path:
|
||||||
|
in_reply_to_url = self.path.split('?replyunlisted=')[1]
|
||||||
|
if '?' in in_reply_to_url:
|
||||||
|
mentions_list = in_reply_to_url.split('?')
|
||||||
|
for m in mentions_list:
|
||||||
|
if m.startswith('mention='):
|
||||||
|
reply_handle = m.replace('mention=', '')
|
||||||
|
if reply_handle not in reply_to_list:
|
||||||
|
reply_to_list.append(reply_handle)
|
||||||
|
if m.startswith('page='):
|
||||||
|
reply_page_str = m.replace('page=', '')
|
||||||
|
if reply_page_str.isdigit():
|
||||||
|
reply_page_number = int(reply_page_str)
|
||||||
|
in_reply_to_url = mentions_list[0]
|
||||||
|
self.path = \
|
||||||
|
self.path.split('?replyunlisted=')[0] + '/newunlisted'
|
||||||
|
if self.server.debug:
|
||||||
|
print('DEBUG: replyunlisted path ' + self.path)
|
||||||
|
|
||||||
# reply to followers
|
# reply to followers
|
||||||
if '?replyfollowers=' in self.path:
|
if '?replyfollowers=' in self.path:
|
||||||
in_reply_to_url = self.path.split('?replyfollowers=')[1]
|
in_reply_to_url = self.path.split('?replyfollowers=')[1]
|
||||||
|
|
26
utils.py
26
utils.py
|
@ -2023,6 +2023,32 @@ def is_public_post(post_json_object: {}) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def is_unlisted_post(post_json_object: {}) -> bool:
|
||||||
|
"""Returns true if the given post is unlisted
|
||||||
|
"""
|
||||||
|
if not post_json_object.get('type'):
|
||||||
|
return False
|
||||||
|
if post_json_object['type'] != 'Create':
|
||||||
|
return False
|
||||||
|
if not has_object_dict(post_json_object):
|
||||||
|
return False
|
||||||
|
if not post_json_object['object'].get('to'):
|
||||||
|
return False
|
||||||
|
if not post_json_object['object'].get('cc'):
|
||||||
|
return False
|
||||||
|
has_followers = False
|
||||||
|
for recipient in post_json_object['object']['to']:
|
||||||
|
if recipient.endswith('/followers'):
|
||||||
|
has_followers = True
|
||||||
|
break
|
||||||
|
if not has_followers:
|
||||||
|
return False
|
||||||
|
for recipient in post_json_object['object']['cc']:
|
||||||
|
if recipient.endswith('#Public'):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def copytree(src: str, dst: str, symlinks: str = False, ignore: bool = None):
|
def copytree(src: str, dst: str, symlinks: str = False, ignore: bool = None):
|
||||||
"""Copy a directory
|
"""Copy a directory
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -692,7 +692,7 @@ def html_new_post(css_cache: {}, media_instance: bool, translate: {},
|
||||||
if inReplyTo:
|
if inReplyTo:
|
||||||
dropdown_new_post_suffix += '?replyto=' + inReplyTo
|
dropdown_new_post_suffix += '?replyto=' + inReplyTo
|
||||||
dropdown_new_blog_suffix += '?replyto=' + inReplyTo
|
dropdown_new_blog_suffix += '?replyto=' + inReplyTo
|
||||||
dropdown_unlisted_suffix += '?replyto=' + inReplyTo
|
dropdown_unlisted_suffix += '?replyunlisted=' + inReplyTo
|
||||||
dropdown_followers_suffix += '?replyfollowers=' + inReplyTo
|
dropdown_followers_suffix += '?replyfollowers=' + inReplyTo
|
||||||
if reply_is_chat:
|
if reply_is_chat:
|
||||||
dropdown_dm_suffix += '?replychat=' + inReplyTo
|
dropdown_dm_suffix += '?replychat=' + inReplyTo
|
||||||
|
|
|
@ -57,6 +57,7 @@ from utils import get_nickname_from_actor
|
||||||
from utils import get_domain_from_actor
|
from utils import get_domain_from_actor
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from utils import local_actor_url
|
from utils import local_actor_url
|
||||||
|
from utils import is_unlisted_post
|
||||||
from content import limit_repeated_words
|
from content import limit_repeated_words
|
||||||
from content import replace_emoji_from_tags
|
from content import replace_emoji_from_tags
|
||||||
from content import html_replace_quote_marks
|
from content import html_replace_quote_marks
|
||||||
|
@ -389,7 +390,7 @@ def _get_avatar_image_html(showAvatarOptions: bool,
|
||||||
|
|
||||||
|
|
||||||
def _get_reply_icon_html(base_dir: str, nickname: str, domain: str,
|
def _get_reply_icon_html(base_dir: str, nickname: str, domain: str,
|
||||||
is_public_repeat: bool,
|
is_public_reply: bool, is_unlisted_reply: bool,
|
||||||
show_icons: bool, comments_enabled: bool,
|
show_icons: bool, comments_enabled: bool,
|
||||||
post_json_object: {}, page_number_param: str,
|
post_json_object: {}, page_number_param: str,
|
||||||
translate: {}, system_language: str,
|
translate: {}, system_language: str,
|
||||||
|
@ -439,13 +440,20 @@ def _get_reply_icon_html(base_dir: str, nickname: str, domain: str,
|
||||||
conversation_str = ''
|
conversation_str = ''
|
||||||
if conversation_id:
|
if conversation_id:
|
||||||
conversation_str = '?conversationId=' + conversation_id
|
conversation_str = '?conversationId=' + conversation_id
|
||||||
if is_public_repeat:
|
if is_public_reply:
|
||||||
reply_str += \
|
reply_str += \
|
||||||
' <a class="imageAnchor" href="/users/' + \
|
' <a class="imageAnchor" href="/users/' + \
|
||||||
nickname + '?replyto=' + reply_to_link + \
|
nickname + '?replyto=' + reply_to_link + \
|
||||||
'?actor=' + post_json_object['actor'] + \
|
'?actor=' + post_json_object['actor'] + \
|
||||||
conversation_str + \
|
conversation_str + \
|
||||||
'" title="' + reply_to_this_post_str + '">\n'
|
'" title="' + reply_to_this_post_str + '">\n'
|
||||||
|
elif is_unlisted_reply:
|
||||||
|
reply_str += \
|
||||||
|
' <a class="imageAnchor" href="/users/' + \
|
||||||
|
nickname + '?replyunlisted=' + reply_to_link + \
|
||||||
|
'?actor=' + post_json_object['actor'] + \
|
||||||
|
conversation_str + \
|
||||||
|
'" title="' + reply_to_this_post_str + '">\n'
|
||||||
else:
|
else:
|
||||||
if is_dm(post_json_object):
|
if is_dm(post_json_object):
|
||||||
reply_type = 'replydm'
|
reply_type = 'replydm'
|
||||||
|
@ -1698,10 +1706,14 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
||||||
conversation_id = post_json_object['object']['conversation']
|
conversation_id = post_json_object['object']['conversation']
|
||||||
|
|
||||||
public_reply = False
|
public_reply = False
|
||||||
|
unlisted_reply = False
|
||||||
if is_public_post(post_json_object):
|
if is_public_post(post_json_object):
|
||||||
public_reply = True
|
public_reply = True
|
||||||
|
if is_unlisted_post(post_json_object):
|
||||||
|
public_reply = False
|
||||||
|
unlisted_reply = True
|
||||||
reply_str = _get_reply_icon_html(base_dir, nickname, domain,
|
reply_str = _get_reply_icon_html(base_dir, nickname, domain,
|
||||||
public_reply,
|
public_reply, unlisted_reply,
|
||||||
show_icons, comments_enabled,
|
show_icons, comments_enabled,
|
||||||
post_json_object, page_number_param,
|
post_json_object, page_number_param,
|
||||||
translate, system_language,
|
translate, system_language,
|
||||||
|
|
Loading…
Reference in New Issue