mirror of https://gitlab.com/bashrc2/epicyon
Merge
commit
604ae60c95
|
@ -25,54 +25,54 @@ from utils import has_object_string_type
|
|||
|
||||
def _create_accept_reject(base_dir: str, federation_list: [],
|
||||
nickname: str, domain: str, port: int,
|
||||
toUrl: str, ccUrl: str, http_prefix: str,
|
||||
objectJson: {}, acceptType: str) -> {}:
|
||||
to_url: str, cc_url: str, http_prefix: str,
|
||||
object_json: {}, accept_type: str) -> {}:
|
||||
"""Accepts or rejects something (eg. a follow request or offer)
|
||||
Typically toUrl will be https://www.w3.org/ns/activitystreams#Public
|
||||
and ccUrl might be a specific person favorited or repeated and
|
||||
Typically to_url will be https://www.w3.org/ns/activitystreams#Public
|
||||
and cc_url might be a specific person favorited or repeated and
|
||||
the followers url objectUrl is typically the url of the message,
|
||||
corresponding to url or atomUri in createPostBase
|
||||
"""
|
||||
if not objectJson.get('actor'):
|
||||
if not object_json.get('actor'):
|
||||
return None
|
||||
|
||||
if not url_permitted(objectJson['actor'], federation_list):
|
||||
if not url_permitted(object_json['actor'], federation_list):
|
||||
return None
|
||||
|
||||
domain = get_full_domain(domain, port)
|
||||
|
||||
new_accept = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
'type': acceptType,
|
||||
'type': accept_type,
|
||||
'actor': local_actor_url(http_prefix, nickname, domain),
|
||||
'to': [toUrl],
|
||||
'to': [to_url],
|
||||
'cc': [],
|
||||
'object': objectJson
|
||||
'object': object_json
|
||||
}
|
||||
if ccUrl:
|
||||
if len(ccUrl) > 0:
|
||||
new_accept['cc'] = [ccUrl]
|
||||
if cc_url:
|
||||
if len(cc_url) > 0:
|
||||
new_accept['cc'] = [cc_url]
|
||||
return new_accept
|
||||
|
||||
|
||||
def create_accept(base_dir: str, federation_list: [],
|
||||
nickname: str, domain: str, port: int,
|
||||
toUrl: str, ccUrl: str, http_prefix: str,
|
||||
objectJson: {}) -> {}:
|
||||
to_url: str, cc_url: str, http_prefix: str,
|
||||
object_json: {}) -> {}:
|
||||
return _create_accept_reject(base_dir, federation_list,
|
||||
nickname, domain, port,
|
||||
toUrl, ccUrl, http_prefix,
|
||||
objectJson, 'Accept')
|
||||
to_url, cc_url, http_prefix,
|
||||
object_json, 'Accept')
|
||||
|
||||
|
||||
def create_reject(base_dir: str, federation_list: [],
|
||||
nickname: str, domain: str, port: int,
|
||||
toUrl: str, ccUrl: str, http_prefix: str,
|
||||
objectJson: {}) -> {}:
|
||||
to_url: str, cc_url: str, http_prefix: str,
|
||||
object_json: {}) -> {}:
|
||||
return _create_accept_reject(base_dir, federation_list,
|
||||
nickname, domain, port,
|
||||
toUrl, ccUrl,
|
||||
http_prefix, objectJson, 'Reject')
|
||||
to_url, cc_url,
|
||||
http_prefix, object_json, 'Reject')
|
||||
|
||||
|
||||
def _accept_follow(base_dir: str, domain: str, message_json: {},
|
||||
|
|
30
announce.py
30
announce.py
|
@ -135,10 +135,10 @@ def announced_by_person(is_announced: bool, post_actor: str,
|
|||
|
||||
def create_announce(session, base_dir: str, federation_list: [],
|
||||
nickname: str, domain: str, port: int,
|
||||
to_url: str, ccUrl: str, http_prefix: str,
|
||||
object_url: str, saveToFile: bool,
|
||||
to_url: str, cc_url: str, http_prefix: str,
|
||||
object_url: str, save_to_file: bool,
|
||||
client_to_server: bool,
|
||||
send_threads: [], postLog: [],
|
||||
send_threads: [], post_log: [],
|
||||
person_cache: {}, cached_webfingers: {},
|
||||
debug: bool, project_version: str,
|
||||
signing_priv_key_pem: str,
|
||||
|
@ -146,7 +146,7 @@ def create_announce(session, base_dir: str, federation_list: [],
|
|||
onion_domain: str, i2p_domain: str) -> {}:
|
||||
"""Creates an announce message
|
||||
Typically to_url will be https://www.w3.org/ns/activitystreams#Public
|
||||
and ccUrl might be a specific person favorited or repeated and the
|
||||
and cc_url might be a specific person favorited or repeated and the
|
||||
followers url object_url is typically the url of the message,
|
||||
corresponding to url or atomUri in createPostBase
|
||||
"""
|
||||
|
@ -172,10 +172,10 @@ def create_announce(session, base_dir: str, federation_list: [],
|
|||
'to': [to_url],
|
||||
'type': 'Announce'
|
||||
}
|
||||
if ccUrl:
|
||||
if len(ccUrl) > 0:
|
||||
new_announce['cc'] = [ccUrl]
|
||||
if saveToFile:
|
||||
if cc_url:
|
||||
if len(cc_url) > 0:
|
||||
new_announce['cc'] = [cc_url]
|
||||
if save_to_file:
|
||||
outbox_dir = create_outbox_dir(nickname, domain, base_dir)
|
||||
filename = \
|
||||
outbox_dir + '/' + new_announce_id.replace('/', '#') + '.json'
|
||||
|
@ -202,7 +202,7 @@ def create_announce(session, base_dir: str, federation_list: [],
|
|||
announce_nickname, announce_domain,
|
||||
announce_port, None,
|
||||
http_prefix, True, client_to_server, federation_list,
|
||||
send_threads, postLog, cached_webfingers,
|
||||
send_threads, post_log, cached_webfingers,
|
||||
person_cache,
|
||||
debug, project_version, None, group_account,
|
||||
signing_priv_key_pem, 639633,
|
||||
|
@ -214,7 +214,7 @@ def create_announce(session, base_dir: str, federation_list: [],
|
|||
def announce_public(session, base_dir: str, federation_list: [],
|
||||
nickname: str, domain: str, port: int, http_prefix: str,
|
||||
object_url: str, client_to_server: bool,
|
||||
send_threads: [], postLog: [],
|
||||
send_threads: [], post_log: [],
|
||||
person_cache: {}, cached_webfingers: {},
|
||||
debug: bool, project_version: str,
|
||||
signing_priv_key_pem: str,
|
||||
|
@ -225,12 +225,12 @@ def announce_public(session, base_dir: str, federation_list: [],
|
|||
from_domain = get_full_domain(domain, port)
|
||||
|
||||
to_url = 'https://www.w3.org/ns/activitystreams#Public'
|
||||
ccUrl = local_actor_url(http_prefix, nickname, from_domain) + '/followers'
|
||||
cc_url = local_actor_url(http_prefix, nickname, from_domain) + '/followers'
|
||||
return create_announce(session, base_dir, federation_list,
|
||||
nickname, domain, port,
|
||||
to_url, ccUrl, http_prefix,
|
||||
to_url, cc_url, http_prefix,
|
||||
object_url, True, client_to_server,
|
||||
send_threads, postLog,
|
||||
send_threads, post_log,
|
||||
person_cache, cached_webfingers,
|
||||
debug, project_version,
|
||||
signing_priv_key_pem, curr_domain,
|
||||
|
@ -239,7 +239,7 @@ def announce_public(session, base_dir: str, federation_list: [],
|
|||
|
||||
def send_announce_via_server(base_dir: str, session,
|
||||
from_nickname: str, password: str,
|
||||
from_domain: str, fromPort: int,
|
||||
from_domain: str, from_port: int,
|
||||
http_prefix: str, repeat_object_url: str,
|
||||
cached_webfingers: {}, person_cache: {},
|
||||
debug: bool, project_version: str,
|
||||
|
@ -250,7 +250,7 @@ def send_announce_via_server(base_dir: str, session,
|
|||
print('WARN: No session for send_announce_via_server')
|
||||
return 6
|
||||
|
||||
from_domain_full = get_full_domain(from_domain, fromPort)
|
||||
from_domain_full = get_full_domain(from_domain, from_port)
|
||||
|
||||
to_url = 'https://www.w3.org/ns/activitystreams#Public'
|
||||
actor_str = local_actor_url(http_prefix, from_nickname, from_domain_full)
|
||||
|
|
|
@ -917,7 +917,7 @@ def set_broch_mode(base_dir: str, domain_full: str, enabled: bool) -> None:
|
|||
# generate instance allow list
|
||||
allowed_domains = [domain_full]
|
||||
follow_files = ('following.txt', 'followers.txt')
|
||||
for subdir, dirs, files in os.walk(base_dir + '/accounts'):
|
||||
for _, dirs, _ in os.walk(base_dir + '/accounts'):
|
||||
for acct in dirs:
|
||||
if not is_account_dir(acct):
|
||||
continue
|
||||
|
@ -995,7 +995,7 @@ def load_cw_lists(base_dir: str, verbose: bool) -> {}:
|
|||
if not os.path.isdir(base_dir + '/cwlists'):
|
||||
return {}
|
||||
result = {}
|
||||
for subdir, dirs, files in os.walk(base_dir + '/cwlists'):
|
||||
for _, _, files in os.walk(base_dir + '/cwlists'):
|
||||
for fname in files:
|
||||
if not fname.endswith('.json'):
|
||||
continue
|
||||
|
|
|
@ -986,8 +986,8 @@ def _desktop_show_box(indent: str,
|
|||
translate: {},
|
||||
screenreader: str, system_language: str, espeak,
|
||||
page_number: int,
|
||||
newReplies: bool,
|
||||
newDMs: bool) -> bool:
|
||||
new_replies: bool,
|
||||
new_dms: bool) -> bool:
|
||||
"""Shows online timeline
|
||||
"""
|
||||
number_width = 2
|
||||
|
@ -1004,9 +1004,9 @@ def _desktop_show_box(indent: str,
|
|||
else:
|
||||
box_name_str = box_name
|
||||
title_str = _highlight_text(box_name_str.upper())
|
||||
# if newDMs:
|
||||
# if new_dms:
|
||||
# notification_icons += ' 📩'
|
||||
# if newReplies:
|
||||
# if new_replies:
|
||||
# notification_icons += ' 📨'
|
||||
|
||||
if notification_icons:
|
||||
|
@ -1086,8 +1086,7 @@ def _desktop_show_box(indent: str,
|
|||
if i > 10:
|
||||
break
|
||||
likes_count = no_of_likes(post_json_object)
|
||||
if likes_count > 10:
|
||||
likes_count = 10
|
||||
likes_count = max(likes_count, 10)
|
||||
for _ in range(likes_count):
|
||||
if not space_added:
|
||||
space_added = True
|
||||
|
@ -1654,8 +1653,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
refresh_timeline = True
|
||||
elif command_str.startswith('prev'):
|
||||
page_number -= 1
|
||||
if page_number < 1:
|
||||
page_number = 1
|
||||
page_number = max(page_number, 1)
|
||||
prev_timeline_first_id = ''
|
||||
box_json = c2s_box_json(base_dir, session,
|
||||
nickname, password,
|
||||
|
@ -1673,8 +1671,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
command_str.startswith('show ') or
|
||||
command_str == 'read' or
|
||||
command_str == 'show'):
|
||||
if command_str == 'read' or \
|
||||
command_str == 'show':
|
||||
if command_str in ('read', 'show'):
|
||||
post_index_str = '1'
|
||||
else:
|
||||
if 'read ' in command_str:
|
||||
|
@ -1774,7 +1771,10 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
post_content = ''
|
||||
if post_json_object['object'].get('content'):
|
||||
post_content = post_json_object['object']['content']
|
||||
if not disallow_reply(post_content):
|
||||
post_summary = ''
|
||||
if post_json_object['object'].get('summary'):
|
||||
post_summary = post_json_object['object']['summary']
|
||||
if not disallow_reply(post_summary + ' ' + post_content):
|
||||
if post_json_object.get('id'):
|
||||
post_id = post_json_object['id']
|
||||
subject = None
|
||||
|
@ -2154,7 +2154,11 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
post_content = ''
|
||||
if post_json_object['object'].get('content'):
|
||||
post_content = post_json_object['object']['content']
|
||||
if not disallow_announce(post_content):
|
||||
post_summary = ''
|
||||
if post_json_object['object'].get('summary'):
|
||||
post_summary = post_json_object['object']['summary']
|
||||
if not disallow_announce(post_summary + ' ' +
|
||||
post_content):
|
||||
if post_json_object.get('id'):
|
||||
post_id = post_json_object['id']
|
||||
announce_actor = \
|
||||
|
|
|
@ -2057,14 +2057,18 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
|||
if not content_str:
|
||||
return ''
|
||||
|
||||
summary_str = ''
|
||||
if content_str:
|
||||
summary_str = get_summary_from_post(post_json_object, system_language,
|
||||
languages_understood)
|
||||
content_all_str = str(summary_str) + ' ' + content_str
|
||||
# does an emoji indicate a no boost preference?
|
||||
# if so then don't show the repeat/announce icon
|
||||
if disallow_announce(content_str):
|
||||
if disallow_announce(content_all_str):
|
||||
announce_str = ''
|
||||
# does an emoji indicate a no replies preference?
|
||||
# if so then don't show the reply icon
|
||||
if disallow_reply(content_str):
|
||||
if disallow_reply(content_all_str):
|
||||
reply_str = ''
|
||||
|
||||
new_footer_str = \
|
||||
|
@ -2083,8 +2087,9 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
|||
if post_is_sensitive:
|
||||
footer_str = '<br>' + footer_str
|
||||
|
||||
summary_str = get_summary_from_post(post_json_object, system_language,
|
||||
languages_understood)
|
||||
if not summary_str:
|
||||
summary_str = get_summary_from_post(post_json_object, system_language,
|
||||
languages_understood)
|
||||
is_patch = is_git_patch(base_dir, nickname, domain,
|
||||
post_json_object['object']['type'],
|
||||
summary_str, content_str)
|
||||
|
|
Loading…
Reference in New Issue