Merge branch 'main' of gitlab.com:bashrc2/epicyon

merge-requests/30/head
Bob Mottram 2022-07-18 18:32:20 +01:00
commit 0f3df09f29
41 changed files with 279 additions and 114 deletions

View File

@ -1087,7 +1087,7 @@ def add_cw_from_lists(post_json_object: {}, cw_lists: {}, translate: {},
# match words within the content # match words within the content
if item.get('words'): if item.get('words'):
for word_str in item['words']: for word_str in item['words']:
if word_str in content: if word_str in content or word_str.title() in content:
if cw_text: if cw_text:
cw_text = warning + ' / ' + cw_text cw_text = warning + ' / ' + cw_text
else: else:

View File

@ -1151,7 +1151,7 @@ def load_dogwhistles(filename: str) -> {}:
def add_html_tags(base_dir: str, http_prefix: str, def add_html_tags(base_dir: str, http_prefix: str,
nickname: str, domain: str, content: str, nickname: str, domain: str, content: str,
recipients: [], hashtags: {}, recipients: [], hashtags: {}, translate: {},
is_json_content: bool = False) -> str: is_json_content: bool = False) -> str:
""" Replaces plaintext mentions such as @nick@domain into html """ Replaces plaintext mentions such as @nick@domain into html
by matching against known following accounts by matching against known following accounts
@ -1162,7 +1162,10 @@ def add_html_tags(base_dir: str, http_prefix: str,
max_word_length = 40 max_word_length = 40
content = content.replace('\r', '') content = content.replace('\r', '')
content = content.replace('\n', ' --linebreak-- ') content = content.replace('\n', ' --linebreak-- ')
content = _add_music_tag(content, 'nowplaying') now_playing_str = 'NowPlaying'
if translate.get(now_playing_str):
now_playing_str = translate[now_playing_str]
content = _add_music_tag(content, now_playing_str)
words = _get_simplified_content(content).split(' ') words = _get_simplified_content(content).split(' ')
# remove . for words which are not mentions # remove . for words which are not mentions

View File

@ -0,0 +1,18 @@
{
"name": "Ableism",
"warning": "Ableism",
"description": "Discrimination and social prejudice against people with disabilities.",
"words": [
"crazy", "cripple", "turn a blind", "turn a deaf", "diffability",
"differently abled", "different abilit",
" dumb.", " dumb ", " dumb!", " dumb?", "handicap",
"idiot", "imbecil", "insanity", "insane", " lame", "lunatic",
"maniac", "moron", "retard", "spaz", "spastic", "specially-abled",
"special needs", "stupid", "blind to", "bonkers",
"wheelchair bound", "confined to a wheelchair", "deaf to",
"deranged", "derranged", "harelip", "wacko", "whacko",
"cretin", "feeble-minded", "mental defective", "mentally defective",
"mongoloid", "blinded by", "double-blind"
],
"domains": []
}

View File

@ -565,7 +565,8 @@ class PubServer(BaseHTTPRequestHandler):
conversation_id, conversation_id,
self.server.low_bandwidth, self.server.low_bandwidth,
self.server.content_license_url, self.server.content_license_url,
languages_understood) languages_understood,
self.server.translate)
if message_json: if message_json:
# name field contains the answer # name field contains the answer
message_json['object']['name'] = answer message_json['object']['name'] = answer
@ -6290,7 +6291,8 @@ class PubServer(BaseHTTPRequestHandler):
http_prefix, http_prefix,
nickname, nickname,
domain_full, domain_full,
bio_str, [], actor_tags) bio_str, [], actor_tags,
self.server.translate)
if actor_tags: if actor_tags:
actor_json['tag'] = [] actor_json['tag'] = []
for _, tag in actor_tags.items(): for _, tag in actor_tags.items():
@ -15334,8 +15336,8 @@ class PubServer(BaseHTTPRequestHandler):
self.path = self.path.replace('?nodropdown', '') self.path = self.path.replace('?nodropdown', '')
# redirect music to #nowplaying list # redirect music to #nowplaying list
if self.path == '/music' or self.path == '/nowplaying': if self.path == '/music' or self.path == '/NowPlaying':
self.path = '/tags/nowplaying' self.path = '/tags/NowPlaying'
if self.server.debug: if self.server.debug:
print('DEBUG: GET from ' + self.server.base_dir + print('DEBUG: GET from ' + self.server.base_dir +
@ -19049,7 +19051,8 @@ class PubServer(BaseHTTPRequestHandler):
conversation_id, conversation_id,
self.server.low_bandwidth, self.server.low_bandwidth,
self.server.content_license_url, self.server.content_license_url,
languages_understood) languages_understood,
self.server.translate)
if message_json: if message_json:
if fields['schedulePost']: if fields['schedulePost']:
return 1 return 1
@ -19140,7 +19143,8 @@ class PubServer(BaseHTTPRequestHandler):
conversation_id, conversation_id,
self.server.low_bandwidth, self.server.low_bandwidth,
self.server.content_license_url, self.server.content_license_url,
languages_understood) languages_understood,
self.server.translate)
if message_json: if message_json:
if fields['schedulePost']: if fields['schedulePost']:
return 1 return 1
@ -19195,7 +19199,9 @@ class PubServer(BaseHTTPRequestHandler):
nickname, self.server.domain, nickname, self.server.domain,
fields['message'], fields['message'],
mentioned_recipients, mentioned_recipients,
hashtags_dict, True) hashtags_dict,
self.server.translate,
True)
# replace emoji with unicode # replace emoji with unicode
tags = [] tags = []
for _, tag in hashtags_dict.items(): for _, tag in hashtags_dict.items():
@ -19303,7 +19309,8 @@ class PubServer(BaseHTTPRequestHandler):
conversation_id, conversation_id,
self.server.low_bandwidth, self.server.low_bandwidth,
self.server.content_license_url, self.server.content_license_url,
languages_understood) languages_understood,
self.server.translate)
if message_json: if message_json:
if fields['schedulePost']: if fields['schedulePost']:
return 1 return 1
@ -19364,7 +19371,8 @@ class PubServer(BaseHTTPRequestHandler):
conversation_id, conversation_id,
self.server.low_bandwidth, self.server.low_bandwidth,
self.server.content_license_url, self.server.content_license_url,
languages_understood) languages_understood,
self.server.translate)
if message_json: if message_json:
if fields['schedulePost']: if fields['schedulePost']:
return 1 return 1
@ -19437,7 +19445,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.low_bandwidth, self.server.low_bandwidth,
content_license_url, content_license_url,
languages_understood, languages_understood,
reply_is_chat) reply_is_chat,
self.server.translate)
if message_json: if message_json:
if fields['schedulePost']: if fields['schedulePost']:
return 1 return 1
@ -19502,7 +19511,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.low_bandwidth, self.server.low_bandwidth,
self.server.content_license_url, self.server.content_license_url,
languages_understood, languages_understood,
False) False, self.server.translate)
if message_json: if message_json:
if fields['schedulePost']: if fields['schedulePost']:
return 1 return 1
@ -19546,7 +19555,8 @@ class PubServer(BaseHTTPRequestHandler):
fields['languagesDropdown'], fields['languagesDropdown'],
self.server.low_bandwidth, self.server.low_bandwidth,
self.server.content_license_url, self.server.content_license_url,
languages_understood) languages_understood,
self.server.translate)
if message_json: if message_json:
if self._post_to_outbox(message_json, if self._post_to_outbox(message_json,
self.server.project_version, self.server.project_version,
@ -19595,7 +19605,8 @@ class PubServer(BaseHTTPRequestHandler):
fields['languagesDropdown'], fields['languagesDropdown'],
self.server.low_bandwidth, self.server.low_bandwidth,
self.server.content_license_url, self.server.content_license_url,
languages_understood) languages_understood,
self.server.translate)
if message_json: if message_json:
if self.server.debug: if self.server.debug:
print('DEBUG: new Question') print('DEBUG: new Question')

View File

@ -464,7 +464,8 @@ def _desktop_reply_to_post(session, post_id: str,
espeak, conversation_id: str, espeak, conversation_id: str,
low_bandwidth: bool, low_bandwidth: bool,
content_license_url: str, content_license_url: str,
signing_priv_key_pem: str) -> None: signing_priv_key_pem: str,
translate: {}) -> None:
"""Use the desktop client to send a reply to the most recent post """Use the desktop client to send a reply to the most recent post
""" """
if '://' not in post_id: if '://' not in post_id:
@ -523,7 +524,7 @@ def _desktop_reply_to_post(session, post_id: str,
system_language, languages_understood, system_language, languages_understood,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
event_date, event_time, event_end_time, location, event_date, event_time, event_end_time, location,
debug, post_id, post_id, translate, debug, post_id, post_id,
conversation_id, subject) == 0: conversation_id, subject) == 0:
say_str = 'Reply sent' say_str = 'Reply sent'
else: else:
@ -540,7 +541,8 @@ def _desktop_new_post(session,
languages_understood: [], languages_understood: [],
espeak, low_bandwidth: bool, espeak, low_bandwidth: bool,
content_license_url: str, content_license_url: str,
signing_priv_key_pem: str) -> None: signing_priv_key_pem: str,
translate: {}) -> None:
"""Use the desktop client to create a new post """Use the desktop client to create a new post
""" """
conversation_id = None conversation_id = None
@ -596,7 +598,7 @@ def _desktop_new_post(session,
system_language, languages_understood, system_language, languages_understood,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
event_date, event_time, event_end_time, location, event_date, event_time, event_end_time, location,
debug, None, None, translate, debug, None, None,
conversation_id, subject) == 0: conversation_id, subject) == 0:
say_str = 'Post sent' say_str = 'Post sent'
else: else:
@ -1188,7 +1190,8 @@ def _desktop_new_dm(session, to_handle: str,
languages_understood: [], languages_understood: [],
espeak, low_bandwidth: bool, espeak, low_bandwidth: bool,
content_license_url: str, content_license_url: str,
signing_priv_key_pem: str) -> None: signing_priv_key_pem: str,
translate: {}) -> None:
"""Use the desktop client to create a new direct message """Use the desktop client to create a new direct message
which can include multiple destination handles which can include multiple destination handles
""" """
@ -1212,7 +1215,7 @@ def _desktop_new_dm(session, to_handle: str,
languages_understood, languages_understood,
espeak, low_bandwidth, espeak, low_bandwidth,
content_license_url, content_license_url,
signing_priv_key_pem) signing_priv_key_pem, translate)
def _desktop_new_dm_base(session, to_handle: str, def _desktop_new_dm_base(session, to_handle: str,
@ -1224,7 +1227,8 @@ def _desktop_new_dm_base(session, to_handle: str,
languages_understood: [], languages_understood: [],
espeak, low_bandwidth: bool, espeak, low_bandwidth: bool,
content_license_url: str, content_license_url: str,
signing_priv_key_pem: str) -> None: signing_priv_key_pem: str,
translate: {}) -> None:
"""Use the desktop client to create a new direct message """Use the desktop client to create a new direct message
""" """
conversation_id = None conversation_id = None
@ -1323,7 +1327,7 @@ def _desktop_new_dm_base(session, to_handle: str,
system_language, languages_understood, system_language, languages_understood,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
event_date, event_time, event_end_time, location, event_date, event_time, event_end_time, location,
debug, None, None, translate, debug, None, None,
conversation_id, subject) == 0: conversation_id, subject) == 0:
say_str = 'Direct message sent' say_str = 'Direct message sent'
else: else:
@ -1791,7 +1795,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
espeak, conversation_id, espeak, conversation_id,
low_bandwidth, low_bandwidth,
content_license_url, content_license_url,
signing_priv_key_pem) signing_priv_key_pem,
translate)
refresh_timeline = True refresh_timeline = True
print('') print('')
elif (command_str == 'post' or command_str == 'p' or elif (command_str == 'post' or command_str == 'p' or
@ -1828,7 +1833,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
languages_understood, languages_understood,
espeak, low_bandwidth, espeak, low_bandwidth,
content_license_url, content_license_url,
signing_priv_key_pem) signing_priv_key_pem, translate)
refresh_timeline = True refresh_timeline = True
else: else:
# public post # public post
@ -1841,7 +1846,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
languages_understood, languages_understood,
espeak, low_bandwidth, espeak, low_bandwidth,
content_license_url, content_license_url,
signing_priv_key_pem) signing_priv_key_pem, translate)
refresh_timeline = True refresh_timeline = True
print('') print('')
elif command_str == 'like' or command_str.startswith('like '): elif command_str == 'like' or command_str.startswith('like '):

View File

@ -1546,6 +1546,7 @@ def _command_options() -> None:
languages_understood = [argb.language] languages_understood = [argb.language]
if argb.languages_understood: if argb.languages_understood:
languages_understood = [argb.languages_understood] languages_understood = [argb.languages_understood]
translate = {}
print('Sending post to ' + argb.sendto) print('Sending post to ' + argb.sendto)
send_post_via_server(signing_priv_key_pem, __version__, send_post_via_server(signing_priv_key_pem, __version__,
@ -1560,7 +1561,7 @@ def _command_options() -> None:
argb.low_bandwidth, argb.low_bandwidth,
argb.content_license_url, argb.content_license_url,
argb.eventDate, argb.eventTime, argb.eventEndTime, argb.eventDate, argb.eventTime, argb.eventEndTime,
argb.eventLocation, argb.eventLocation, translate,
argb.debug, argb.debug,
reply_to, reply_to, argb.conversationId, subject) reply_to, reply_to, argb.conversationId, subject)
for _ in range(10): for _ in range(10):
@ -3217,6 +3218,7 @@ def _command_options() -> None:
conversation_id = None conversation_id = None
low_bandwidth = False low_bandwidth = False
languages_understood = [argb.language] languages_understood = [argb.language]
translate = {}
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
"like this is totally just a #test man", "like this is totally just a #test man",
@ -3231,7 +3233,7 @@ def _command_options() -> None:
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, argb.language, conversation_id, test_is_article, argb.language, conversation_id,
low_bandwidth, argb.content_license_url, low_bandwidth, argb.content_license_url,
languages_understood) languages_understood, translate)
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
"Zoiks!!!", "Zoiks!!!",
test_save_to_file, test_save_to_file,
@ -3245,7 +3247,7 @@ def _command_options() -> None:
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, argb.language, conversation_id, test_is_article, argb.language, conversation_id,
low_bandwidth, argb.content_license_url, low_bandwidth, argb.content_license_url,
languages_understood) languages_understood, translate)
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
"Hey scoob we need like a hundred more #milkshakes", "Hey scoob we need like a hundred more #milkshakes",
test_save_to_file, test_save_to_file,
@ -3259,7 +3261,7 @@ def _command_options() -> None:
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, argb.language, conversation_id, test_is_article, argb.language, conversation_id,
low_bandwidth, argb.content_license_url, low_bandwidth, argb.content_license_url,
languages_understood) languages_understood, translate)
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
"Getting kinda spooky around here", "Getting kinda spooky around here",
test_save_to_file, test_save_to_file,
@ -3273,7 +3275,7 @@ def _command_options() -> None:
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, argb.language, conversation_id, test_is_article, argb.language, conversation_id,
low_bandwidth, argb.content_license_url, low_bandwidth, argb.content_license_url,
languages_understood) languages_understood, translate)
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
"And they would have gotten away with it too" + "And they would have gotten away with it too" +
"if it wasn't for those pesky hackers", "if it wasn't for those pesky hackers",
@ -3288,7 +3290,7 @@ def _command_options() -> None:
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, argb.language, conversation_id, test_is_article, argb.language, conversation_id,
low_bandwidth, argb.content_license_url, low_bandwidth, argb.content_license_url,
languages_understood) languages_understood, translate)
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
"man these centralized sites are like the worst!", "man these centralized sites are like the worst!",
test_save_to_file, test_save_to_file,
@ -3302,7 +3304,7 @@ def _command_options() -> None:
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, argb.language, conversation_id, test_is_article, argb.language, conversation_id,
low_bandwidth, argb.content_license_url, low_bandwidth, argb.content_license_url,
languages_understood) languages_understood, translate)
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
"another mystery solved #test", "another mystery solved #test",
test_save_to_file, test_save_to_file,
@ -3316,7 +3318,7 @@ def _command_options() -> None:
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, argb.language, conversation_id, test_is_article, argb.language, conversation_id,
low_bandwidth, argb.content_license_url, low_bandwidth, argb.content_license_url,
languages_understood) languages_understood, translate)
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
"let's go bowling", "let's go bowling",
test_save_to_file, test_save_to_file,
@ -3330,7 +3332,7 @@ def _command_options() -> None:
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, argb.language, conversation_id, test_is_article, argb.language, conversation_id,
low_bandwidth, argb.content_license_url, low_bandwidth, argb.content_license_url,
languages_understood) languages_understood, translate)
domain_full = domain + ':' + str(port) domain_full = domain + ':' + str(port)
clear_follows(base_dir, nickname, domain) clear_follows(base_dir, nickname, domain)
follow_person(base_dir, nickname, domain, 'maxboardroom', domain_full, follow_person(base_dir, nickname, domain, 'maxboardroom', domain_full,

View File

@ -3319,7 +3319,8 @@ def _bounce_dm(sender_post_id: str, session, http_prefix: str,
location, system_language, conversation_id, location, system_language, conversation_id,
low_bandwidth, low_bandwidth,
content_license_url, content_license_url,
languages_understood, bounce_is_chat) languages_understood, bounce_is_chat,
translate)
if not post_json_object: if not post_json_object:
print('WARN: unable to create bounce message to ' + sending_handle) print('WARN: unable to create bounce message to ' + sending_handle)
return False return False

View File

@ -643,7 +643,7 @@ def _convert_rss_to_activitypub(base_dir: str, http_prefix: str,
rss_title, system_language, rss_title, system_language,
conversation_id, low_bandwidth, conversation_id, low_bandwidth,
content_license_url, content_license_url,
languages_understood) languages_understood, translate)
if not blog: if not blog:
continue continue

View File

@ -190,6 +190,26 @@ def _person_receive_update_outbox(base_dir: str, http_prefix: str,
print('DEBUG: actor update via c2s - ' + nickname + '@' + domain) print('DEBUG: actor update via c2s - ' + nickname + '@' + domain)
def _capitalize_hashtag(content: str, message_json: {},
system_language: str, translate: {},
original_tag: str,
capitalized_tag: str) -> None:
"""If a nowplaying hashtag exists then ensure it is capitalized
"""
if translate.get(original_tag) and \
translate.get(capitalized_tag):
original_tag = translate[original_tag].replace(' ', '_')
capitalized_tag = translate[capitalized_tag].replace(' ', '_')
if '#' + original_tag not in content:
return
content = content.replace('#' + original_tag, '#' + capitalized_tag)
if message_json['object'].get('contentMap'):
if message_json['object']['contentMap'].get(system_language):
message_json['object']['contentMap'][system_language] = content
message_json['object']['contentMap'][system_language] = content
def post_message_to_outbox(session, translate: {}, def post_message_to_outbox(session, translate: {},
message_json: {}, post_to_nickname: str, message_json: {}, post_to_nickname: str,
server, base_dir: str, http_prefix: str, server, base_dir: str, http_prefix: str,
@ -243,6 +263,10 @@ def post_message_to_outbox(session, translate: {},
if has_object_dict(message_json): if has_object_dict(message_json):
content_str = get_base_content_from_post(message_json, system_language) content_str = get_base_content_from_post(message_json, system_language)
if content_str: if content_str:
_capitalize_hashtag(content_str, message_json,
system_language, translate,
'nowplaying', 'NowPlaying')
if dangerous_markup(content_str, allow_local_network_access): if dangerous_markup(content_str, allow_local_network_access):
print('POST to outbox contains dangerous markup: ' + print('POST to outbox contains dangerous markup: ' +
str(message_json)) str(message_json))

View File

@ -1425,7 +1425,7 @@ def _create_post_base(base_dir: str,
system_language: str, system_language: str,
conversation_id: str, low_bandwidth: bool, conversation_id: str, low_bandwidth: bool,
content_license_url: str, content_license_url: str,
languages_understood: []) -> {}: languages_understood: [], translate: {}) -> {}:
"""Creates a message """Creates a message
""" """
content = remove_invalid_chars(content) content = remove_invalid_chars(content)
@ -1470,7 +1470,7 @@ def _create_post_base(base_dir: str,
add_html_tags(base_dir, http_prefix, add_html_tags(base_dir, http_prefix,
nickname, domain, content, nickname, domain, content,
mentioned_recipients, mentioned_recipients,
hashtags_dict, True) hashtags_dict, translate, True)
# replace emoji with unicode # replace emoji with unicode
tags = [] tags = []
@ -1837,7 +1837,7 @@ def create_public_post(base_dir: str,
location: str, is_article: bool, system_language: str, location: str, is_article: bool, system_language: str,
conversation_id: str, low_bandwidth: bool, conversation_id: str, low_bandwidth: bool,
content_license_url: str, content_license_url: str,
languages_understood: []) -> {}: languages_understood: [], translate: {}) -> {}:
"""Public post """Public post
""" """
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
@ -1871,7 +1871,7 @@ def create_public_post(base_dir: str,
event_status, ticket_url, system_language, event_status, ticket_url, system_language,
conversation_id, low_bandwidth, conversation_id, low_bandwidth,
content_license_url, content_license_url,
languages_understood) languages_understood, translate)
def _append_citations_to_blog_post(base_dir: str, def _append_citations_to_blog_post(base_dir: str,
@ -1916,7 +1916,7 @@ def create_blog_post(base_dir: str,
location: str, system_language: str, location: str, system_language: str,
conversation_id: str, low_bandwidth: bool, conversation_id: str, low_bandwidth: bool,
content_license_url: str, content_license_url: str,
languages_understood: []) -> {}: languages_understood: [], translate: {}) -> {}:
blog_json = \ blog_json = \
create_public_post(base_dir, create_public_post(base_dir,
nickname, domain, port, http_prefix, nickname, domain, port, http_prefix,
@ -1929,7 +1929,7 @@ def create_blog_post(base_dir: str,
event_date, event_time, event_end_time, location, event_date, event_time, event_end_time, location,
True, system_language, conversation_id, True, system_language, conversation_id,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
languages_understood) languages_understood, translate)
blog_json['object']['url'] = \ blog_json['object']['url'] = \
blog_json['object']['url'].replace('/@', '/users/') blog_json['object']['url'].replace('/@', '/users/')
_append_citations_to_blog_post(base_dir, nickname, domain, blog_json) _append_citations_to_blog_post(base_dir, nickname, domain, blog_json)
@ -1945,7 +1945,7 @@ def create_news_post(base_dir: str,
subject: str, system_language: str, subject: str, system_language: str,
conversation_id: str, low_bandwidth: bool, conversation_id: str, low_bandwidth: bool,
content_license_url: str, content_license_url: str,
languages_understood: []) -> {}: languages_understood: [], translate: {}) -> {}:
client_to_server = False client_to_server = False
in_reply_to = None in_reply_to = None
in_reply_to_atom_uri = None in_reply_to_atom_uri = None
@ -1966,7 +1966,7 @@ def create_news_post(base_dir: str,
event_date, event_time, event_end_time, location, event_date, event_time, event_end_time, location,
True, system_language, conversation_id, True, system_language, conversation_id,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
languages_understood) languages_understood, translate)
blog['object']['type'] = 'Article' blog['object']['type'] = 'Article'
return blog return blog
@ -1982,7 +1982,7 @@ def create_question_post(base_dir: str,
subject: str, duration_days: int, subject: str, duration_days: int,
system_language: str, low_bandwidth: bool, system_language: str, low_bandwidth: bool,
content_license_url: str, content_license_url: str,
languages_understood: []) -> {}: languages_understood: [], translate: {}) -> {}:
"""Question post with multiple choice options """Question post with multiple choice options
""" """
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
@ -2000,7 +2000,7 @@ def create_question_post(base_dir: str,
None, None, None, None, None, None,
None, None, None, None, None, system_language, None, None, None, None, None, system_language,
None, low_bandwidth, content_license_url, None, low_bandwidth, content_license_url,
languages_understood) languages_understood, translate)
message_json['object']['type'] = 'Question' message_json['object']['type'] = 'Question'
message_json['object']['oneOf'] = [] message_json['object']['oneOf'] = []
message_json['object']['votersCount'] = 0 message_json['object']['votersCount'] = 0
@ -2035,7 +2035,7 @@ def create_unlisted_post(base_dir: str,
location: str, system_language: str, location: str, system_language: str,
conversation_id: str, low_bandwidth: bool, conversation_id: str, low_bandwidth: bool,
content_license_url: str, content_license_url: str,
languages_understood: []) -> {}: languages_understood: [], translate: {}) -> {}:
"""Unlisted post. This has the #Public and followers links inverted. """Unlisted post. This has the #Public and followers links inverted.
""" """
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
@ -2054,7 +2054,8 @@ def create_unlisted_post(base_dir: str,
None, None, None, event_date, event_end_time, None, None, None, event_date, event_end_time,
None, None, None, None, None, system_language, None, None, None, None, None, system_language,
conversation_id, low_bandwidth, conversation_id, low_bandwidth,
content_license_url, languages_understood) content_license_url, languages_understood,
translate)
def create_followers_only_post(base_dir: str, def create_followers_only_post(base_dir: str,
@ -2072,7 +2073,8 @@ def create_followers_only_post(base_dir: str,
location: str, system_language: str, location: str, system_language: str,
conversation_id: str, low_bandwidth: bool, conversation_id: str, low_bandwidth: bool,
content_license_url: str, content_license_url: str,
languages_understood: []) -> {}: languages_understood: [],
translate: {}) -> {}:
"""Followers only post """Followers only post
""" """
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
@ -2089,7 +2091,8 @@ def create_followers_only_post(base_dir: str,
None, None, None, event_date, event_end_time, None, None, None, event_date, event_end_time,
None, None, None, None, None, system_language, None, None, None, None, None, system_language,
conversation_id, low_bandwidth, conversation_id, low_bandwidth,
content_license_url, languages_understood) content_license_url, languages_understood,
translate)
def get_mentioned_people(base_dir: str, http_prefix: str, def get_mentioned_people(base_dir: str, http_prefix: str,
@ -2145,7 +2148,7 @@ def create_direct_message_post(base_dir: str,
conversation_id: str, low_bandwidth: bool, conversation_id: str, low_bandwidth: bool,
content_license_url: str, content_license_url: str,
languages_understood: [], languages_understood: [],
dm_is_chat: bool) -> {}: dm_is_chat: bool, translate: {}) -> {}:
"""Direct Message post """Direct Message post
""" """
content = resolve_petnames(base_dir, nickname, domain, content) content = resolve_petnames(base_dir, nickname, domain, content)
@ -2170,7 +2173,8 @@ def create_direct_message_post(base_dir: str,
None, None, None, event_date, event_end_time, None, None, None, event_date, event_end_time,
None, None, None, None, None, system_language, None, None, None, None, None, system_language,
conversation_id, low_bandwidth, conversation_id, low_bandwidth,
content_license_url, languages_understood) content_license_url, languages_understood,
translate)
# mentioned recipients go into To rather than Cc # mentioned recipients go into To rather than Cc
message_json['to'] = message_json['object']['cc'] message_json['to'] = message_json['object']['cc']
message_json['object']['to'] = message_json['to'] message_json['object']['to'] = message_json['to']
@ -2194,7 +2198,7 @@ def create_report_post(base_dir: str,
debug: bool, subject: str, system_language: str, debug: bool, subject: str, system_language: str,
low_bandwidth: bool, low_bandwidth: bool,
content_license_url: str, content_license_url: str,
languages_understood: []) -> {}: languages_understood: [], translate: {}) -> {}:
"""Send a report to moderators """Send a report to moderators
""" """
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
@ -2273,7 +2277,7 @@ def create_report_post(base_dir: str,
None, None, None, None, None, None,
None, None, None, None, None, system_language, None, None, None, None, None, system_language,
None, low_bandwidth, content_license_url, None, low_bandwidth, content_license_url,
languages_understood) languages_understood, translate)
if not post_json_object: if not post_json_object:
continue continue
@ -2398,6 +2402,7 @@ def send_post(signing_priv_key_pem: str, project_version: str,
shared_items_federated_domains: [], shared_items_federated_domains: [],
shared_item_federation_tokens: {}, shared_item_federation_tokens: {},
low_bandwidth: bool, content_license_url: str, low_bandwidth: bool, content_license_url: str,
translate: {},
debug: bool = False, in_reply_to: str = None, debug: bool = False, in_reply_to: str = None,
in_reply_to_atom_uri: str = None, subject: str = None) -> int: in_reply_to_atom_uri: str = None, subject: str = None) -> int:
"""Post to another inbox. Used by unit tests. """Post to another inbox. Used by unit tests.
@ -2464,7 +2469,8 @@ def send_post(signing_priv_key_pem: str, project_version: str,
None, None, None, None, None, None,
None, None, None, None, None, system_language, None, None, None, None, None, system_language,
conversation_id, low_bandwidth, conversation_id, low_bandwidth,
content_license_url, languages_understood) content_license_url, languages_understood,
translate)
# get the senders private key # get the senders private key
private_key_pem = _get_person_key(nickname, domain, base_dir, 'private') private_key_pem = _get_person_key(nickname, domain, base_dir, 'private')
@ -2561,7 +2567,7 @@ def send_post_via_server(signing_priv_key_pem: str, project_version: str,
low_bandwidth: bool, low_bandwidth: bool,
content_license_url: str, content_license_url: str,
event_date: str, event_time: str, event_end_time: str, event_date: str, event_time: str, event_end_time: str,
location: str, location: str, translate: {},
debug: bool = False, debug: bool = False,
in_reply_to: str = None, in_reply_to: str = None,
in_reply_to_atom_uri: str = None, in_reply_to_atom_uri: str = None,
@ -2652,7 +2658,8 @@ def send_post_via_server(signing_priv_key_pem: str, project_version: str,
None, None, None, event_date, event_end_time, None, None, None, event_date, event_end_time,
None, None, None, None, None, system_language, None, None, None, None, None, system_language,
conversation_id, low_bandwidth, conversation_id, low_bandwidth,
content_license_url, languages_understood) content_license_url, languages_understood,
translate)
auth_header = create_basic_auth_header(from_nickname, password) auth_header = create_basic_auth_header(from_nickname, password)

View File

@ -763,6 +763,7 @@ def create_server_alice(path: str, domain: str, port: int,
test_location = None test_location = None
test_is_article = False test_is_article = False
conversation_id = None conversation_id = None
translate = {}
content_license_url = 'https://creativecommons.org/licenses/by/4.0' content_license_url = 'https://creativecommons.org/licenses/by/4.0'
create_public_post(path, nickname, domain, port, http_prefix, create_public_post(path, nickname, domain, port, http_prefix,
"No wise fish would go anywhere without a porpoise", "No wise fish would go anywhere without a porpoise",
@ -778,7 +779,7 @@ def create_server_alice(path: str, domain: str, port: int,
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, system_language, conversation_id, test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
languages_understood) languages_understood, translate)
create_public_post(path, nickname, domain, port, http_prefix, create_public_post(path, nickname, domain, port, http_prefix,
"Curiouser and curiouser!", "Curiouser and curiouser!",
test_save_to_file, test_save_to_file,
@ -793,7 +794,7 @@ def create_server_alice(path: str, domain: str, port: int,
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, system_language, conversation_id, test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
languages_understood) languages_understood, translate)
create_public_post(path, nickname, domain, port, http_prefix, create_public_post(path, nickname, domain, port, http_prefix,
"In the gardens of memory, in the palace " + "In the gardens of memory, in the palace " +
"of dreams, that is where you and I shall meet", "of dreams, that is where you and I shall meet",
@ -809,7 +810,7 @@ def create_server_alice(path: str, domain: str, port: int,
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, system_language, conversation_id, test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
languages_understood) languages_understood, translate)
regenerate_index_for_box(path, nickname, domain, 'outbox') regenerate_index_for_box(path, nickname, domain, 'outbox')
global TEST_SERVER_ALICE_RUNNING global TEST_SERVER_ALICE_RUNNING
TEST_SERVER_ALICE_RUNNING = True TEST_SERVER_ALICE_RUNNING = True
@ -923,6 +924,7 @@ def create_server_bob(path: str, domain: str, port: int,
test_is_article = False test_is_article = False
conversation_id = None conversation_id = None
content_license_url = 'https://creativecommons.org/licenses/by/4.0' content_license_url = 'https://creativecommons.org/licenses/by/4.0'
translate = {}
create_public_post(path, nickname, domain, port, http_prefix, create_public_post(path, nickname, domain, port, http_prefix,
"It's your life, live it your way.", "It's your life, live it your way.",
test_save_to_file, test_save_to_file,
@ -937,7 +939,7 @@ def create_server_bob(path: str, domain: str, port: int,
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, system_language, conversation_id, test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
languages_understood) languages_understood, translate)
create_public_post(path, nickname, domain, port, http_prefix, create_public_post(path, nickname, domain, port, http_prefix,
"One of the things I've realised is that " + "One of the things I've realised is that " +
"I am very simple", "I am very simple",
@ -953,7 +955,7 @@ def create_server_bob(path: str, domain: str, port: int,
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, system_language, conversation_id, test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
languages_understood) languages_understood, translate)
create_public_post(path, nickname, domain, port, http_prefix, create_public_post(path, nickname, domain, port, http_prefix,
"Quantum physics is a bit of a passion of mine", "Quantum physics is a bit of a passion of mine",
test_save_to_file, test_save_to_file,
@ -968,7 +970,7 @@ def create_server_bob(path: str, domain: str, port: int,
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, system_language, conversation_id, test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
languages_understood) languages_understood, translate)
regenerate_index_for_box(path, nickname, domain, 'outbox') regenerate_index_for_box(path, nickname, domain, 'outbox')
global TEST_SERVER_BOB_RUNNING global TEST_SERVER_BOB_RUNNING
TEST_SERVER_BOB_RUNNING = True TEST_SERVER_BOB_RUNNING = True
@ -1294,6 +1296,7 @@ def test_post_message_between_servers(base_dir: str) -> None:
if os.path.isfile(os.path.join(outbox_path, name))]) == 0 if os.path.isfile(os.path.join(outbox_path, name))]) == 0
low_bandwidth = False low_bandwidth = False
signing_priv_key_pem = None signing_priv_key_pem = None
translate = {}
send_result = \ send_result = \
send_post(signing_priv_key_pem, __version__, send_post(signing_priv_key_pem, __version__,
session_alice, alice_dir, 'alice', alice_domain, alice_port, session_alice, alice_dir, 'alice', alice_domain, alice_port,
@ -1308,7 +1311,7 @@ def test_post_message_between_servers(base_dir: str) -> None:
languages_understood, languages_understood,
alice_shared_items_federated_domains, alice_shared_items_federated_domains,
alice_shared_item_federation_tokens, low_bandwidth, alice_shared_item_federation_tokens, low_bandwidth,
content_license_url, content_license_url, translate,
in_reply_to, in_reply_to_atom_uri, subject) in_reply_to, in_reply_to_atom_uri, subject)
print('send_result: ' + str(send_result)) print('send_result: ' + str(send_result))
@ -1665,6 +1668,7 @@ def test_follow_between_servers(base_dir: str) -> None:
city = 'London, England' city = 'London, England'
low_bandwidth = False low_bandwidth = False
signing_priv_key_pem = None signing_priv_key_pem = None
translate = {}
send_result = \ send_result = \
send_post(signing_priv_key_pem, __version__, send_post(signing_priv_key_pem, __version__,
session_alice, alice_dir, 'alice', alice_domain, alice_port, session_alice, alice_dir, 'alice', alice_domain, alice_port,
@ -1677,7 +1681,7 @@ def test_follow_between_servers(base_dir: str) -> None:
languages_understood, languages_understood,
alice_shared_items_federated_domains, alice_shared_items_federated_domains,
alice_shared_item_federation_tokens, low_bandwidth, alice_shared_item_federation_tokens, low_bandwidth,
content_license_url, content_license_url, translate,
in_reply_to, in_reply_to_atom_uri, subject) in_reply_to, in_reply_to_atom_uri, subject)
print('send_result: ' + str(send_result)) print('send_result: ' + str(send_result))
@ -2029,6 +2033,7 @@ def test_shared_items_federation(base_dir: str) -> None:
city = 'London, England' city = 'London, England'
low_bandwidth = False low_bandwidth = False
signing_priv_key_pem = None signing_priv_key_pem = None
translate = {}
send_result = \ send_result = \
send_post(signing_priv_key_pem, __version__, send_post(signing_priv_key_pem, __version__,
session_alice, alice_dir, 'alice', alice_domain, alice_port, session_alice, alice_dir, 'alice', alice_domain, alice_port,
@ -2041,7 +2046,7 @@ def test_shared_items_federation(base_dir: str) -> None:
languages_understood, languages_understood,
alice_shared_items_federated_domains, alice_shared_items_federated_domains,
alice_shared_item_federation_tokens, low_bandwidth, alice_shared_item_federation_tokens, low_bandwidth,
content_license_url, True, content_license_url, translate, True,
in_reply_to, in_reply_to_atom_uri, subject) in_reply_to, in_reply_to_atom_uri, subject)
print('send_result: ' + str(send_result)) print('send_result: ' + str(send_result))
@ -2458,6 +2463,7 @@ def test_group_follow(base_dir: str) -> None:
len([name for name in os.listdir(outbox_path) len([name for name in os.listdir(outbox_path)
if os.path.isfile(os.path.join(outbox_path, name))]) if os.path.isfile(os.path.join(outbox_path, name))])
translate = {}
send_result = \ send_result = \
send_post(signing_priv_key_pem, __version__, send_post(signing_priv_key_pem, __version__,
session_alice, alice_dir, 'alice', alice_domain, alice_port, session_alice, alice_dir, 'alice', alice_domain, alice_port,
@ -2470,7 +2476,7 @@ def test_group_follow(base_dir: str) -> None:
languages_understood, languages_understood,
alice_shared_items_federated_domains, alice_shared_items_federated_domains,
alice_shared_item_federation_tokens, low_bandwidth, alice_shared_item_federation_tokens, low_bandwidth,
content_license_url, content_license_url, translate,
in_reply_to, in_reply_to_atom_uri, subject) in_reply_to, in_reply_to_atom_uri, subject)
print('send_result: ' + str(send_result)) print('send_result: ' + str(send_result))
@ -2838,6 +2844,7 @@ def _test_create_person_account(base_dir: str):
media_type = None media_type = None
conversation_id = None conversation_id = None
low_bandwidth = True low_bandwidth = True
translate = {}
content_license_url = 'https://creativecommons.org/licenses/by/4.0' content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content = \ content = \
"If your \"independent organization\" is government funded...\n\n" + \ "If your \"independent organization\" is government funded...\n\n" + \
@ -2856,7 +2863,7 @@ def _test_create_person_account(base_dir: str):
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, system_language, conversation_id, test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
languages_understood) languages_understood, translate)
assert test_post_json assert test_post_json
assert test_post_json.get('object') assert test_post_json.get('object')
assert test_post_json['object']['content'] assert test_post_json['object']['content']
@ -2882,7 +2889,7 @@ def _test_create_person_account(base_dir: str):
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, system_language, conversation_id, test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
languages_understood) languages_understood, translate)
assert test_post_json assert test_post_json
assert test_post_json.get('object') assert test_post_json.get('object')
assert test_post_json['object']['content'] assert test_post_json['object']['content']
@ -3082,6 +3089,7 @@ def test_client_to_server(base_dir: str):
event_time = '11:45' event_time = '11:45'
event_end_time = '12:30' event_end_time = '12:30'
location = "Kinshasa" location = "Kinshasa"
translate = {}
send_result = \ send_result = \
send_post_via_server(signing_priv_key_pem, __version__, send_post_via_server(signing_priv_key_pem, __version__,
alice_dir, session_alice, 'alice', password, alice_dir, session_alice, 'alice', password,
@ -3094,7 +3102,7 @@ def test_client_to_server(base_dir: str):
system_language, languages_understood, system_language, languages_understood,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
event_date, event_time, event_end_time, location, event_date, event_time, event_end_time, location,
True, None, None, translate, True, None, None,
conversation_id, None) conversation_id, None)
print('send_result: ' + str(send_result)) print('send_result: ' + str(send_result))
@ -3683,6 +3691,7 @@ def _test_addemoji(base_dir: str):
domain = 'testdomain.net' domain = 'testdomain.net'
port = 3682 port = 3682
recipients = [] recipients = []
translate = {}
hashtags = {} hashtags = {}
base_dir_original = base_dir base_dir_original = base_dir
path = base_dir + '/.tests' path = base_dir + '/.tests'
@ -3709,7 +3718,7 @@ def _test_addemoji(base_dir: str):
content_modified = \ content_modified = \
add_html_tags(base_dir, http_prefix, add_html_tags(base_dir, http_prefix,
nickname, domain, content, nickname, domain, content,
recipients, hashtags, True) recipients, hashtags, translate, True)
assert ':lemon:' in content_modified assert ':lemon:' in content_modified
assert content_modified.startswith('<p>') assert content_modified.startswith('<p>')
assert content_modified.endswith('</p>') assert content_modified.endswith('</p>')
@ -4657,6 +4666,7 @@ def _test_reply_to_public_post(base_dir: str) -> None:
conversation_id = None conversation_id = None
low_bandwidth = True low_bandwidth = True
content_license_url = 'https://creativecommons.org/licenses/by/4.0' content_license_url = 'https://creativecommons.org/licenses/by/4.0'
translate = {}
reply = \ reply = \
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
content, save_to_file, content, save_to_file,
@ -4669,7 +4679,7 @@ def _test_reply_to_public_post(base_dir: str) -> None:
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, system_language, conversation_id, test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
languages_understood) languages_understood, translate)
# print(str(reply)) # print(str(reply))
expected_str = \ expected_str = \
'<p><span class=\"h-card\">' + \ '<p><span class=\"h-card\">' + \
@ -5588,6 +5598,7 @@ def _test_links_within_post(base_dir: str) -> None:
conversation_id = None conversation_id = None
low_bandwidth = True low_bandwidth = True
content_license_url = 'https://creativecommons.org/licenses/by/4.0' content_license_url = 'https://creativecommons.org/licenses/by/4.0'
translate = {}
post_json_object = \ post_json_object = \
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
@ -5601,7 +5612,7 @@ def _test_links_within_post(base_dir: str) -> None:
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, system_language, conversation_id, test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
languages_understood) languages_understood, translate)
expected_str = \ expected_str = \
'<p>This is a test post with links.<br><br>' + \ '<p>This is a test post with links.<br><br>' + \
@ -5645,7 +5656,7 @@ def _test_links_within_post(base_dir: str) -> None:
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, system_language, conversation_id, test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
languages_understood) languages_understood, translate)
assert post_json_object['object']['content'] == content assert post_json_object['object']['content'] == content
assert post_json_object['object']['contentMap'][system_language] == content assert post_json_object['object']['contentMap'][system_language] == content
@ -6676,6 +6687,7 @@ def _test_can_replyto(base_dir: str) -> None:
conversation_id = None conversation_id = None
low_bandwidth = True low_bandwidth = True
content_license_url = 'https://creativecommons.org/licenses/by/4.0' content_license_url = 'https://creativecommons.org/licenses/by/4.0'
translate = {}
post_json_object = \ post_json_object = \
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
@ -6689,7 +6701,7 @@ def _test_can_replyto(base_dir: str) -> None:
test_event_end_time, test_location, test_event_end_time, test_location,
test_is_article, system_language, conversation_id, test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
languages_understood) languages_understood, translate)
# set the date on the post # set the date on the post
curr_date_str = "2021-09-08T20:45:00Z" curr_date_str = "2021-09-08T20:45:00Z"
post_json_object['published'] = curr_date_str post_json_object['published'] = curr_date_str

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "عرض الوسائط", "SHOW MEDIA": "عرض الوسائط",
"ActivityPub Specification": "مواصفات ActivityPub", "ActivityPub Specification": "مواصفات ActivityPub",
"Dogwhistle words": "كلمات Dogwhistle", "Dogwhistle words": "كلمات Dogwhistle",
"Content warnings will be added for the following": "ستتم إضافة تحذيرات المحتوى لما يلي" "Content warnings will be added for the following": "ستتم إضافة تحذيرات المحتوى لما يلي",
"nowplaying": "الان العب",
"NowPlaying": "الان العب"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "মিডিয়া দেখান", "SHOW MEDIA": "মিডিয়া দেখান",
"ActivityPub Specification": "ActivityPub স্পেসিফিকেশন", "ActivityPub Specification": "ActivityPub স্পেসিফিকেশন",
"Dogwhistle words": "কুকুরের হুইসেল শব্দ", "Dogwhistle words": "কুকুরের হুইসেল শব্দ",
"Content warnings will be added for the following": "নিম্নলিখিত জন্য বিষয়বস্তু সতর্কতা যোগ করা হবে" "Content warnings will be added for the following": "নিম্নলিখিত জন্য বিষয়বস্তু সতর্কতা যোগ করা হবে",
"nowplaying": "এখন চলছে",
"NowPlaying": "এখন চলছে"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "MOSTRA ELS MITJANS", "SHOW MEDIA": "MOSTRA ELS MITJANS",
"ActivityPub Specification": "Especificació d'ActivityPub", "ActivityPub Specification": "Especificació d'ActivityPub",
"Dogwhistle words": "Paraules de xiulet", "Dogwhistle words": "Paraules de xiulet",
"Content warnings will be added for the following": "S'afegiran advertències de contingut per al següent" "Content warnings will be added for the following": "S'afegiran advertències de contingut per al següent",
"nowplaying": "arajugant",
"NowPlaying": "AraJugant"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "DANGOS CYFRYNGAU", "SHOW MEDIA": "DANGOS CYFRYNGAU",
"ActivityPub Specification": "Manyleb GweithgareddPub", "ActivityPub Specification": "Manyleb GweithgareddPub",
"Dogwhistle words": "Geiriau chwibanogl", "Dogwhistle words": "Geiriau chwibanogl",
"Content warnings will be added for the following": "Bydd rhybuddion cynnwys yn cael eu hychwanegu ar gyfer y canlynol" "Content warnings will be added for the following": "Bydd rhybuddion cynnwys yn cael eu hychwanegu ar gyfer y canlynol",
"nowplaying": "nawrynchwarae",
"NowPlaying": "NawrYnChwarae"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "MEDIEN ZEIGEN", "SHOW MEDIA": "MEDIEN ZEIGEN",
"ActivityPub Specification": "ActivityPub-Spezifikation", "ActivityPub Specification": "ActivityPub-Spezifikation",
"Dogwhistle words": "Hundepfeife Worte", "Dogwhistle words": "Hundepfeife Worte",
"Content warnings will be added for the following": "Inhaltswarnungen werden für Folgendes hinzugefügt" "Content warnings will be added for the following": "Inhaltswarnungen werden für Folgendes hinzugefügt",
"nowplaying": "läuftgerade",
"NowPlaying": "LäuftGerade"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "ΔΕΙΤΕ ΜΕΣΑ", "SHOW MEDIA": "ΔΕΙΤΕ ΜΕΣΑ",
"ActivityPub Specification": "Προδιαγραφές ActivityPub", "ActivityPub Specification": "Προδιαγραφές ActivityPub",
"Dogwhistle words": "Σφυρίχτρα λέξεις", "Dogwhistle words": "Σφυρίχτρα λέξεις",
"Content warnings will be added for the following": "Θα προστεθούν προειδοποιήσεις περιεχομένου για τα ακόλουθα" "Content warnings will be added for the following": "Θα προστεθούν προειδοποιήσεις περιεχομένου για τα ακόλουθα",
"nowplaying": "τώραπαίζει",
"NowPlaying": "ΤώραΠαίζει"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "SHOW MEDIA", "SHOW MEDIA": "SHOW MEDIA",
"ActivityPub Specification": "ActivityPub Specification", "ActivityPub Specification": "ActivityPub Specification",
"Dogwhistle words": "Dogwhistle words", "Dogwhistle words": "Dogwhistle words",
"Content warnings will be added for the following": "Content warnings will be added for the following" "Content warnings will be added for the following": "Content warnings will be added for the following",
"nowplaying": "nowplaying",
"NowPlaying": "NowPlaying"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "MOSTRAR MEDIOS", "SHOW MEDIA": "MOSTRAR MEDIOS",
"ActivityPub Specification": "Especificación de ActivityPub", "ActivityPub Specification": "Especificación de ActivityPub",
"Dogwhistle words": "Palabras de silbato para perros", "Dogwhistle words": "Palabras de silbato para perros",
"Content warnings will be added for the following": "Se agregarán advertencias de contenido para lo siguiente" "Content warnings will be added for the following": "Se agregarán advertencias de contenido para lo siguiente",
"nowplaying": "jugandoahora",
"NowPlaying": "JugandoAhora"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "AFFICHER LES MÉDIAS", "SHOW MEDIA": "AFFICHER LES MÉDIAS",
"ActivityPub Specification": "Spécification ActivityPub", "ActivityPub Specification": "Spécification ActivityPub",
"Dogwhistle words": "Mots de sifflet de chien", "Dogwhistle words": "Mots de sifflet de chien",
"Content warnings will be added for the following": "Des avertissements de contenu seront ajoutés pour les éléments suivants" "Content warnings will be added for the following": "Des avertissements de contenu seront ajoutés pour les éléments suivants",
"nowplaying": "lectureencours",
"NowPlaying": "LectureEnCours"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "Taispeáin MEÁIN", "SHOW MEDIA": "Taispeáin MEÁIN",
"ActivityPub Specification": "Sonraíocht ActivityPub", "ActivityPub Specification": "Sonraíocht ActivityPub",
"Dogwhistle words": "Focail feadóg mhadra", "Dogwhistle words": "Focail feadóg mhadra",
"Content warnings will be added for the following": "Cuirfear rabhaidh ábhair leis maidir leis na nithe seo a leanas" "Content warnings will be added for the following": "Cuirfear rabhaidh ábhair leis maidir leis na nithe seo a leanas",
"nowplaying": "anoisagimirt",
"NowPlaying": "AnoisAgImirt"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "मीडिया दिखाएं", "SHOW MEDIA": "मीडिया दिखाएं",
"ActivityPub Specification": "गतिविधिपब विशिष्टता", "ActivityPub Specification": "गतिविधिपब विशिष्टता",
"Dogwhistle words": "कुत्ते की सीटी शब्द", "Dogwhistle words": "कुत्ते की सीटी शब्द",
"Content warnings will be added for the following": "निम्नलिखित के लिए सामग्री चेतावनियां जोड़ दी जाएंगी" "Content warnings will be added for the following": "निम्नलिखित के लिए सामग्री चेतावनियां जोड़ दी जाएंगी",
"nowplaying": "अब खेल रहे हैं",
"NowPlaying": "अब खेल रहे हैं"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "MOSTRA MEDIA", "SHOW MEDIA": "MOSTRA MEDIA",
"ActivityPub Specification": "Specifica ActivityPub", "ActivityPub Specification": "Specifica ActivityPub",
"Dogwhistle words": "Parole da fischietto", "Dogwhistle words": "Parole da fischietto",
"Content warnings will be added for the following": "Verranno aggiunti avvisi sui contenuti per quanto segue" "Content warnings will be added for the following": "Verranno aggiunti avvisi sui contenuti per quanto segue",
"nowplaying": "ora giocando",
"NowPlaying": "OraGiocando"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "メディアを表示", "SHOW MEDIA": "メディアを表示",
"ActivityPub Specification": "ActivityPubの仕様", "ActivityPub Specification": "ActivityPubの仕様",
"Dogwhistle words": "犬笛の言葉", "Dogwhistle words": "犬笛の言葉",
"Content warnings will be added for the following": "以下のコンテンツ警告が追加されます" "Content warnings will be added for the following": "以下のコンテンツ警告が追加されます",
"nowplaying": "再生中",
"NowPlaying": "再生中"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "미디어 표시", "SHOW MEDIA": "미디어 표시",
"ActivityPub Specification": "ActivityPub 사양", "ActivityPub Specification": "ActivityPub 사양",
"Dogwhistle words": "개 휘파람 단어", "Dogwhistle words": "개 휘파람 단어",
"Content warnings will be added for the following": "다음에 대한 콘텐츠 경고가 추가됩니다." "Content warnings will be added for the following": "다음에 대한 콘텐츠 경고가 추가됩니다.",
"nowplaying": "지금 재생",
"NowPlaying": "지금 재생"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "MEDYA NÎŞAN DE", "SHOW MEDIA": "MEDYA NÎŞAN DE",
"ActivityPub Specification": "Specification ActivityPub", "ActivityPub Specification": "Specification ActivityPub",
"Dogwhistle words": "Peyvên kûçikê", "Dogwhistle words": "Peyvên kûçikê",
"Content warnings will be added for the following": "Hişyariyên naverokê dê ji bo jêrîn werin zêdekirin" "Content warnings will be added for the following": "Hişyariyên naverokê dê ji bo jêrîn werin zêdekirin",
"nowplaying": "nihadilîze",
"NowPlaying": "NihaDilîze"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "TOON MEDIA", "SHOW MEDIA": "TOON MEDIA",
"ActivityPub Specification": "ActivityPub-specificatie", "ActivityPub Specification": "ActivityPub-specificatie",
"Dogwhistle words": "Hondenfluitwoorden", "Dogwhistle words": "Hondenfluitwoorden",
"Content warnings will be added for the following": "Er worden inhoudswaarschuwingen toegevoegd voor het volgende:" "Content warnings will be added for the following": "Er worden inhoudswaarschuwingen toegevoegd voor het volgende:",
"nowplaying": "nuaanhetspelen",
"NowPlaying": "NuAanHetSpelen"
} }

View File

@ -563,5 +563,7 @@
"SHOW MEDIA": "SHOW MEDIA", "SHOW MEDIA": "SHOW MEDIA",
"ActivityPub Specification": "ActivityPub Specification", "ActivityPub Specification": "ActivityPub Specification",
"Dogwhistle words": "Dogwhistle words", "Dogwhistle words": "Dogwhistle words",
"Content warnings will be added for the following": "Content warnings will be added for the following" "Content warnings will be added for the following": "Content warnings will be added for the following",
"nowplaying": "nowplaying",
"NowPlaying": "NowPlaying"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "POKAŻ MEDIA", "SHOW MEDIA": "POKAŻ MEDIA",
"ActivityPub Specification": "Specyfikacja ActivityPub", "ActivityPub Specification": "Specyfikacja ActivityPub",
"Dogwhistle words": "Słowa gwizdka na psa", "Dogwhistle words": "Słowa gwizdka na psa",
"Content warnings will be added for the following": "Ostrzeżenia dotyczące treści zostaną dodane do następujących" "Content warnings will be added for the following": "Ostrzeżenia dotyczące treści zostaną dodane do następujących",
"nowplaying": "terazgra",
"NowPlaying": "TerazGra"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "MOSTRAR MÍDIA", "SHOW MEDIA": "MOSTRAR MÍDIA",
"ActivityPub Specification": "Especificação do ActivityPub", "ActivityPub Specification": "Especificação do ActivityPub",
"Dogwhistle words": "Palavras de apito", "Dogwhistle words": "Palavras de apito",
"Content warnings will be added for the following": "Avisos de conteúdo serão adicionados para os seguintes" "Content warnings will be added for the following": "Avisos de conteúdo serão adicionados para os seguintes",
"nowplaying": "agorajogando",
"NowPlaying": "AgoraJogando"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "ПОКАЗАТЬ МЕДИА", "SHOW MEDIA": "ПОКАЗАТЬ МЕДИА",
"ActivityPub Specification": "Спецификация ActivityPub", "ActivityPub Specification": "Спецификация ActivityPub",
"Dogwhistle words": "Собачий свисток", "Dogwhistle words": "Собачий свисток",
"Content warnings will be added for the following": "Предупреждения о содержании будут добавлены для следующих" "Content warnings will be added for the following": "Предупреждения о содержании будут добавлены для следующих",
"nowplaying": "сейчасиграет",
"NowPlaying": "СейчасИграет"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "ONESHA VYOMBO VYA HABARI", "SHOW MEDIA": "ONESHA VYOMBO VYA HABARI",
"ActivityPub Specification": "Vipimo vya ActivityPub", "ActivityPub Specification": "Vipimo vya ActivityPub",
"Dogwhistle words": "Maneno ya mbwa", "Dogwhistle words": "Maneno ya mbwa",
"Content warnings will be added for the following": "Maonyo ya maudhui yataongezwa kwa yafuatayo" "Content warnings will be added for the following": "Maonyo ya maudhui yataongezwa kwa yafuatayo",
"nowplaying": "inachezasasa",
"NowPlaying": "InachezaSasa"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "MEDYA GÖSTER", "SHOW MEDIA": "MEDYA GÖSTER",
"ActivityPub Specification": "ActivityPub Spesifikasyonu", "ActivityPub Specification": "ActivityPub Spesifikasyonu",
"Dogwhistle words": "İtiraf sözleri", "Dogwhistle words": "İtiraf sözleri",
"Content warnings will be added for the following": "Aşağıdakiler için içerik uyarıları eklenecek" "Content warnings will be added for the following": "Aşağıdakiler için içerik uyarıları eklenecek",
"nowplaying": "şimdioynuyor",
"NowPlaying": "ŞimdiOynuyor"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "ПОКАЗАТИ ЗМІ", "SHOW MEDIA": "ПОКАЗАТИ ЗМІ",
"ActivityPub Specification": "Специфікація ActivityPub", "ActivityPub Specification": "Специфікація ActivityPub",
"Dogwhistle words": "Собачі слова", "Dogwhistle words": "Собачі слова",
"Content warnings will be added for the following": "Попередження про вміст буде додано для наступних" "Content warnings will be added for the following": "Попередження про вміст буде додано для наступних",
"nowplaying": "заразграє",
"NowPlaying": "ЗаразГрає"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "ווייַז מעדיע", "SHOW MEDIA": "ווייַז מעדיע",
"ActivityPub Specification": "ActivityPub באַשרייַבונג", "ActivityPub Specification": "ActivityPub באַשרייַבונג",
"Dogwhistle words": "דאָגווהיסטלע ווערטער", "Dogwhistle words": "דאָגווהיסטלע ווערטער",
"Content warnings will be added for the following": "אינהאַלט וואָרנינגז וועט זיין מוסיף פֿאַר די פאלגענדע" "Content warnings will be added for the following": "אינהאַלט וואָרנינגז וועט זיין מוסיף פֿאַר די פאלגענדע",
"nowplaying": "איצט פּלייַינג",
"NowPlaying": "איצט פּלייַינג"
} }

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "展示媒体", "SHOW MEDIA": "展示媒体",
"ActivityPub Specification": "ActivityPub 规范", "ActivityPub Specification": "ActivityPub 规范",
"Dogwhistle words": "狗哨的话", "Dogwhistle words": "狗哨的话",
"Content warnings will be added for the following": "将为以下内容添加内容警告" "Content warnings will be added for the following": "将为以下内容添加内容警告",
"nowplaying": "现在玩",
"NowPlaying": "现在玩"
} }

View File

@ -1070,6 +1070,32 @@ def _is_dangerous_string_simple(content: str, allow_local_network_access: bool,
return False return False
def _html_tag_has_closing(tag_name: str, content: str) -> bool:
"""Does the given tag have opening and closing labels?
"""
content_lower = content.lower()
if '<' + tag_name not in content_lower:
return True
sections = content_lower.split('<' + tag_name)
ctr = 0
end_tag = '</' + tag_name + '>'
for section in sections:
if ctr == 0:
ctr += 1
continue
# check that an ending tag exists
if end_tag not in section:
return False
if tag_name == 'code':
# check that lines are not too long
code_lines = section.split('\n')
for line in code_lines:
if len(line) >= 60:
return False
ctr += 1
return True
def dangerous_markup(content: str, allow_local_network_access: bool) -> bool: def dangerous_markup(content: str, allow_local_network_access: bool) -> bool:
"""Returns true if the given content contains dangerous html markup """Returns true if the given content contains dangerous html markup
""" """
@ -1080,8 +1106,10 @@ def dangerous_markup(content: str, allow_local_network_access: bool) -> bool:
if _is_dangerous_string_simple(content, allow_local_network_access, if _is_dangerous_string_simple(content, allow_local_network_access,
separators, invalid_strings): separators, invalid_strings):
return True return True
if not _html_tag_has_closing('code', content):
return True
invalid_strings = [ invalid_strings = [
'script', 'noscript', 'code', 'pre', 'script', 'noscript', 'pre',
'canvas', 'style', 'abbr', 'canvas', 'style', 'abbr',
'frame', 'iframe', 'html', 'body', 'frame', 'iframe', 'html', 'body',
'hr', 'allow-popups', 'allow-scripts', 'hr', 'allow-popups', 'allow-scripts',

View File

@ -142,7 +142,8 @@ def html_likers_of_post(base_dir: str, nickname: str,
add_emoji_to_display_name(session, base_dir, add_emoji_to_display_name(session, base_dir,
http_prefix, http_prefix,
nickname, domain, nickname, domain,
liker_name, False) liker_name, False,
translate)
else: else:
liker_name = get_nickname_from_actor(liker_actor) liker_name = get_nickname_from_actor(liker_actor)
if not liker_name: if not liker_name:

View File

@ -1134,7 +1134,8 @@ def _get_post_title_announce_html(base_dir: str,
announce_display_name = \ announce_display_name = \
add_emoji_to_display_name(None, base_dir, http_prefix, add_emoji_to_display_name(None, base_dir, http_prefix,
nickname, domain, nickname, domain,
announce_display_name, False) announce_display_name, False,
translate)
_log_post_timing(enable_timing_log, post_start_time, '13.3.1') _log_post_timing(enable_timing_log, post_start_time, '13.3.1')
title_str += \ title_str += \
_announce_with_display_name_html(translate, post_json_object, _announce_with_display_name_html(translate, post_json_object,
@ -1341,7 +1342,7 @@ def _get_post_title_reply_html(base_dir: str,
reply_display_name = \ reply_display_name = \
add_emoji_to_display_name(None, base_dir, http_prefix, add_emoji_to_display_name(None, base_dir, http_prefix,
nickname, domain, nickname, domain,
reply_display_name, False) reply_display_name, False, translate)
_log_post_timing(enable_timing_log, post_start_time, '13.6') _log_post_timing(enable_timing_log, post_start_time, '13.6')
title_str += _get_reply_html(translate, in_reply_to, reply_display_name) title_str += _get_reply_html(translate, in_reply_to, reply_display_name)
@ -1739,7 +1740,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
display_name = \ display_name = \
add_emoji_to_display_name(session, base_dir, http_prefix, add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain, nickname, domain,
display_name, False) display_name, False, translate)
_log_post_timing(enable_timing_log, post_start_time, '7') _log_post_timing(enable_timing_log, post_start_time, '7')
@ -1872,7 +1873,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
display_name = \ display_name = \
add_emoji_to_display_name(session, base_dir, http_prefix, add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain, nickname, domain,
display_name, False) display_name, False, translate)
title_str += \ title_str += \
' <a class="imageAnchor" href="/users/' + \ ' <a class="imageAnchor" href="/users/' + \
nickname + '?options=' + post_actor + \ nickname + '?options=' + post_actor + \
@ -2262,7 +2263,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
cw_str = \ cw_str = \
add_emoji_to_display_name(session, base_dir, http_prefix, add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain, nickname, domain,
summary_str, False) summary_str, False, translate)
content_str += \ content_str += \
'<label class="cw"><span itemprop="description">' + \ '<label class="cw"><span itemprop="description">' + \
cw_str + '</span></label>\n' cw_str + '</span></label>\n'

View File

@ -646,12 +646,12 @@ def html_profile(signing_priv_key_pem: str,
display_name = \ display_name = \
add_emoji_to_display_name(session, base_dir, http_prefix, add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain, nickname, domain,
profile_json['name'], True) profile_json['name'], True, translate)
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
profile_description = \ profile_description = \
add_emoji_to_display_name(session, base_dir, http_prefix, add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain, nickname, domain,
profile_json['summary'], False) profile_json['summary'], False, translate)
if profile_description: if profile_description:
profile_description = standardize_text(profile_description) profile_description = standardize_text(profile_description)
posts_button = 'button' posts_button = 'button'
@ -2517,7 +2517,7 @@ def _individual_follow_as_html(signing_priv_key_pem: str,
display_name = \ display_name = \
add_emoji_to_display_name(None, base_dir, http_prefix, add_emoji_to_display_name(None, base_dir, http_prefix,
actor_nickname, domain, actor_nickname, domain,
display_name, False) display_name, False, translate)
title_str = display_name title_str = display_name
if dormant: if dormant:

View File

@ -1006,7 +1006,8 @@ def load_individual_post_as_html_from_cache(base_dir: str,
def add_emoji_to_display_name(session, base_dir: str, http_prefix: str, def add_emoji_to_display_name(session, base_dir: str, http_prefix: str,
nickname: str, domain: str, nickname: str, domain: str,
display_name: str, in_profile_name: bool) -> str: display_name: str, in_profile_name: bool,
translate: {}) -> str:
"""Adds emoji icons to display names or CW on individual posts """Adds emoji icons to display names or CW on individual posts
""" """
if ':' not in display_name: if ':' not in display_name:
@ -1017,7 +1018,8 @@ def add_emoji_to_display_name(session, base_dir: str, http_prefix: str,
# print('TAG: display_name before tags: ' + display_name) # print('TAG: display_name before tags: ' + display_name)
display_name = \ display_name = \
add_html_tags(base_dir, http_prefix, add_html_tags(base_dir, http_prefix,
nickname, domain, display_name, [], emoji_tags) nickname, domain, display_name, [],
emoji_tags, translate)
display_name = display_name.replace('<p>', '').replace('</p>', '') display_name = display_name.replace('<p>', '').replace('</p>', '')
# print('TAG: display_name after tags: ' + display_name) # print('TAG: display_name after tags: ' + display_name)
# convert the emoji dictionary to a list # convert the emoji dictionary to a list