Pass dict through to html generation

main
Bob Mottram 2022-07-05 15:40:26 +01:00
parent d2a39c8b50
commit 542f0c6605
13 changed files with 212 additions and 129 deletions

109
daemon.py
View File

@ -1596,7 +1596,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.max_recent_posts,
self.server.cw_lists,
self.server.lists_enabled,
self.server.content_license_url)
self.server.content_license_url,
self.server.dogwhistles)
def _get_outbox_thread_index(self, nickname: str,
max_outbox_threads_per_account: int) -> int:
@ -3183,7 +3184,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
self.server.default_timeline,
reply_is_chat,
bold_reading).encode('utf-8')
bold_reading,
self.server.dogwhistles).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, calling_domain, False)
@ -3327,7 +3329,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
self.server.default_timeline,
reply_is_chat,
bold_reading).encode('utf-8')
bold_reading,
self.server.dogwhistles).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, calling_domain, False)
@ -3889,7 +3892,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
if hashtag_str:
msg = hashtag_str.encode('utf-8')
msglen = len(msg)
@ -3994,7 +3998,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
if history_str:
msg = history_str.encode('utf-8')
msglen = len(msg)
@ -4074,7 +4079,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
if bookmarks_str:
msg = bookmarks_str.encode('utf-8')
msglen = len(msg)
@ -4244,7 +4250,8 @@ class PubServer(BaseHTTPRequestHandler):
timezone,
self.server.onion_domain,
self.server.i2p_domain,
bold_reading)
bold_reading,
self.server.dogwhistles)
if profile_str:
msg = profile_str.encode('utf-8')
msglen = len(msg)
@ -8472,7 +8479,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
if hashtag_str:
msg = hashtag_str.encode('utf-8')
msglen = len(msg)
@ -8720,7 +8728,8 @@ class PubServer(BaseHTTPRequestHandler):
False, True, False,
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading)
timezone, mitm, bold_reading,
self.server.dogwhistles)
actor_absolute = self._get_instance_url(calling_domain) + actor
actor_path_str = \
@ -9266,7 +9275,8 @@ class PubServer(BaseHTTPRequestHandler):
False, True, False,
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading)
timezone, mitm, bold_reading,
self.server.dogwhistles)
else:
print('WARN: Liked post not found: ' + liked_post_filename)
# clear the icon from the cache so that it gets updated
@ -9451,7 +9461,8 @@ class PubServer(BaseHTTPRequestHandler):
False, True, False,
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading)
timezone, mitm, bold_reading,
self.server.dogwhistles)
else:
print('WARN: Unliked post not found: ' + liked_post_filename)
# clear the icon from the cache so that it gets updated
@ -9665,7 +9676,8 @@ class PubServer(BaseHTTPRequestHandler):
False, True, False,
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading)
timezone, mitm, bold_reading,
self.server.dogwhistles)
else:
print('WARN: Emoji reaction post not found: ' +
reaction_post_filename)
@ -9869,7 +9881,8 @@ class PubServer(BaseHTTPRequestHandler):
False, True, False,
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading)
timezone, mitm, bold_reading,
self.server.dogwhistles)
else:
print('WARN: Unreaction post not found: ' +
reaction_post_filename)
@ -9975,7 +9988,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
timeline_str, page_number,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -10117,7 +10131,8 @@ class PubServer(BaseHTTPRequestHandler):
False, True, False,
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading)
timezone, mitm, bold_reading,
self.server.dogwhistles)
else:
print('WARN: Bookmarked post not found: ' + bookmark_filename)
# self._post_to_outbox(bookmark_json,
@ -10266,7 +10281,8 @@ class PubServer(BaseHTTPRequestHandler):
False, True, False,
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading)
timezone, mitm, bold_reading,
self.server.dogwhistles)
else:
print('WARN: Unbookmarked post not found: ' +
bookmark_filename)
@ -10376,7 +10392,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.max_like_count,
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled)
self.server.lists_enabled,
self.server.dogwhistles)
if delete_str:
delete_str_len = len(delete_str)
self._set_headers('text/html', delete_str_len,
@ -10503,7 +10520,8 @@ class PubServer(BaseHTTPRequestHandler):
use_cache_only,
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading)
timezone, mitm, bold_reading,
self.server.dogwhistles)
else:
print('WARN: Muted post not found: ' + mute_filename)
@ -10630,7 +10648,8 @@ class PubServer(BaseHTTPRequestHandler):
use_cache_only,
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading)
timezone, mitm, bold_reading,
self.server.dogwhistles)
else:
print('WARN: Unmuted post not found: ' + mute_filename)
if calling_domain.endswith('.onion') and onion_domain:
@ -10759,7 +10778,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -10863,7 +10883,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -11317,7 +11338,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
'inbox', self.server.default_timeline,
bold_reading)
bold_reading, self.server.dogwhistles)
if not msg:
self._404()
return True
@ -11384,7 +11405,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.cw_lists,
self.server.lists_enabled,
'inbox', self.server.default_timeline,
bold_reading, 'shares')
bold_reading, self.server.dogwhistles,
'shares')
if not msg:
self._404()
return True
@ -11473,7 +11495,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, mitm, bold_reading)
timezone, mitm, bold_reading,
self.server.dogwhistles)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -11789,7 +11812,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
if getreq_start_time:
fitness_performance(getreq_start_time,
self.server.fitness,
@ -11960,7 +11984,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12120,7 +12145,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.replies)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12278,7 +12304,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12436,7 +12463,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12603,7 +12631,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12773,7 +12802,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12893,7 +12923,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled, timezone,
bold_reading)
bold_reading, self.server.dogwhistles)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12987,7 +13017,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13124,7 +13155,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13275,7 +13307,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13423,7 +13456,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
timezone, bold_reading)
timezone, bold_reading,
self.server.dogwhistles)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -14800,7 +14834,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
self.server.default_timeline,
reply_is_chat,
bold_reading).encode('utf-8')
bold_reading,
self.server.dogwhistles).encode('utf-8')
if not msg:
print('Error replying to ' + in_reply_to_url)
self._404()

View File

@ -131,6 +131,7 @@ from conversation import update_conversation
from webapp_hashtagswarm import html_hash_tag_swarm
from person import valid_sending_actor
from fitnessFunctions import fitness_performance
from content import load_dogwhistles
from content import valid_url_lengths
from content import remove_script
@ -408,7 +409,8 @@ def _inbox_store_post_to_html_cache(recent_posts_cache: {},
lists_enabled: str,
timezone: str,
mitm: bool,
bold_reading: bool) -> None:
bold_reading: bool,
dogwhistles: {}) -> None:
"""Converts the json post into html and stores it in a cache
This enables the post to be quickly displayed later
"""
@ -434,7 +436,7 @@ def _inbox_store_post_to_html_cache(recent_posts_cache: {},
theme_name, system_language, max_like_count,
not_dm, True, True, False, True, False,
cw_lists, lists_enabled, timezone, mitm,
bold_reading)
bold_reading, dogwhistles)
def valid_inbox(base_dir: str, nickname: str, domain: str) -> bool:
@ -1106,7 +1108,7 @@ def _receive_edit_to_post(recent_posts_cache: {}, message_json: {},
show_published_date_only: bool,
peertube_instances: [],
theme_name: str, max_like_count: int,
cw_lists: {}) -> bool:
cw_lists: {}, dogwhistles: {}) -> bool:
"""A post was edited
"""
if not has_object_dict(message_json):
@ -1230,7 +1232,7 @@ def _receive_edit_to_post(recent_posts_cache: {}, message_json: {},
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading)
bold_reading, dogwhistles)
return True
@ -1250,7 +1252,7 @@ def _receive_update_activity(recent_posts_cache: {}, session, base_dir: str,
show_published_date_only: bool,
peertube_instances: [],
theme_name: str, max_like_count: int,
cw_lists: {}) -> bool:
cw_lists: {}, dogwhistles: {}) -> bool:
"""Receives an Update activity within the POST section of HTTPServer
"""
@ -1290,7 +1292,7 @@ def _receive_update_activity(recent_posts_cache: {}, session, base_dir: str,
show_published_date_only,
peertube_instances,
theme_name, max_like_count,
cw_lists):
cw_lists, dogwhistles):
print('EDITPOST: received ' + message_json['object']['id'])
return True
else:
@ -1340,7 +1342,7 @@ def _receive_like(recent_posts_cache: {},
theme_name: str, system_language: str,
max_like_count: int, cw_lists: {},
lists_enabled: str,
bold_reading: bool) -> bool:
bold_reading: bool, dogwhistles: {}) -> bool:
"""Receives a Like activity within the POST section of HTTPServer
"""
if message_json['type'] != 'Like':
@ -1449,7 +1451,7 @@ def _receive_like(recent_posts_cache: {},
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading)
bold_reading, dogwhistles)
return True
@ -1469,7 +1471,7 @@ def _receive_undo_like(recent_posts_cache: {},
theme_name: str, system_language: str,
max_like_count: int, cw_lists: {},
lists_enabled: str,
bold_reading: bool) -> bool:
bold_reading: bool, dogwhistles: {}) -> bool:
"""Receives an undo like activity within the POST section of HTTPServer
"""
if message_json['type'] != 'Undo':
@ -1568,7 +1570,7 @@ def _receive_undo_like(recent_posts_cache: {},
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading)
bold_reading, dogwhistles)
return True
@ -1588,7 +1590,8 @@ def _receive_reaction(recent_posts_cache: {},
allow_local_network_access: bool,
theme_name: str, system_language: str,
max_like_count: int, cw_lists: {},
lists_enabled: str, bold_reading: bool) -> bool:
lists_enabled: str, bold_reading: bool,
dogwhistles: {}) -> bool:
"""Receives an emoji reaction within the POST section of HTTPServer
"""
if message_json['type'] != 'EmojiReact':
@ -1719,7 +1722,7 @@ def _receive_reaction(recent_posts_cache: {},
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading)
bold_reading, dogwhistles)
return True
@ -1741,7 +1744,7 @@ def _receive_undo_reaction(recent_posts_cache: {},
theme_name: str, system_language: str,
max_like_count: int, cw_lists: {},
lists_enabled: str,
bold_reading: bool) -> bool:
bold_reading: bool, dogwhistles: {}) -> bool:
"""Receives an undo emoji reaction within the POST section of HTTPServer
"""
if message_json['type'] != 'Undo':
@ -1858,7 +1861,7 @@ def _receive_undo_reaction(recent_posts_cache: {},
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading)
bold_reading, dogwhistles)
return True
@ -1876,7 +1879,8 @@ def _receive_bookmark(recent_posts_cache: {},
allow_local_network_access: bool,
theme_name: str, system_language: str,
max_like_count: int, cw_lists: {},
lists_enabled: {}, bold_reading: bool) -> bool:
lists_enabled: {}, bold_reading: bool,
dogwhistles: {}) -> bool:
"""Receives a bookmark activity within the POST section of HTTPServer
"""
if not message_json.get('type'):
@ -1973,7 +1977,7 @@ def _receive_bookmark(recent_posts_cache: {},
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading)
bold_reading, dogwhistles)
return True
@ -1993,7 +1997,8 @@ def _receive_undo_bookmark(recent_posts_cache: {},
allow_local_network_access: bool,
theme_name: str, system_language: str,
max_like_count: int, cw_lists: {},
lists_enabled: str, bold_reading: bool) -> bool:
lists_enabled: str, bold_reading: bool,
dogwhistles: {}) -> bool:
"""Receives an undo bookmark activity within the POST section of HTTPServer
"""
if not message_json.get('type'):
@ -2090,7 +2095,8 @@ def _receive_undo_bookmark(recent_posts_cache: {},
show_individual_post_icons,
manually_approve_followers,
False, True, False, cw_lists, lists_enabled,
timezone, mitm, bold_reading)
timezone, mitm, bold_reading,
dogwhistles)
return True
@ -2186,7 +2192,8 @@ def _receive_announce(recent_posts_cache: {},
allow_deletion: bool,
peertube_instances: [],
max_like_count: int, cw_lists: {},
lists_enabled: str, bold_reading: bool) -> bool:
lists_enabled: str, bold_reading: bool,
dogwhistles: {}) -> bool:
"""Receives an announce activity within the POST section of HTTPServer
"""
if message_json['type'] != 'Announce':
@ -2309,7 +2316,7 @@ def _receive_announce(recent_posts_cache: {},
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading)
bold_reading, dogwhistles)
if not announce_html:
print('WARN: Unable to generate html for announce ' +
str(message_json))
@ -3452,7 +3459,7 @@ def _receive_question_vote(server, base_dir: str, nickname: str, domain: str,
theme_name: str, system_language: str,
max_like_count: int,
cw_lists: {}, lists_enabled: bool,
bold_reading: bool) -> None:
bold_reading: bool, dogwhistles: {}) -> None:
"""Updates the votes on a Question/poll
"""
# if this is a reply to a question then update the votes
@ -3505,7 +3512,7 @@ def _receive_question_vote(server, base_dir: str, nickname: str, domain: str,
manually_approve_followers,
False, True, False, cw_lists,
lists_enabled, timezone, mitm,
bold_reading)
bold_reading, dogwhistles)
# add id to inbox index
inbox_update_index('inbox', base_dir, handle,
@ -3676,7 +3683,8 @@ def _inbox_after_initial(server, inbox_start_time,
cw_lists: {}, lists_enabled: str,
content_license_url: str,
languages_understood: [],
mitm: bool, bold_reading: bool) -> bool:
mitm: bool, bold_reading: bool,
dogwhistles: {}) -> bool:
""" Anything which needs to be done after initial checks have passed
"""
# if this is a clearnet instance then replace any onion/i2p
@ -3724,7 +3732,7 @@ def _inbox_after_initial(server, inbox_start_time,
allow_local_network_access,
theme_name, system_language,
max_like_count, cw_lists, lists_enabled,
bold_reading):
bold_reading, dogwhistles):
if debug:
print('DEBUG: Like accepted from ' + actor)
fitness_performance(inbox_start_time, server.fitness,
@ -3749,7 +3757,7 @@ def _inbox_after_initial(server, inbox_start_time,
allow_local_network_access,
theme_name, system_language,
max_like_count, cw_lists, lists_enabled,
bold_reading):
bold_reading, dogwhistles):
if debug:
print('DEBUG: Undo like accepted from ' + actor)
fitness_performance(inbox_start_time, server.fitness,
@ -3775,7 +3783,7 @@ def _inbox_after_initial(server, inbox_start_time,
allow_local_network_access,
theme_name, system_language,
max_like_count, cw_lists, lists_enabled,
bold_reading):
bold_reading, dogwhistles):
if debug:
print('DEBUG: Reaction accepted from ' + actor)
fitness_performance(inbox_start_time, server.fitness,
@ -3802,7 +3810,7 @@ def _inbox_after_initial(server, inbox_start_time,
allow_local_network_access,
theme_name, system_language,
max_like_count, cw_lists, lists_enabled,
bold_reading):
bold_reading, dogwhistles):
if debug:
print('DEBUG: Undo reaction accepted from ' + actor)
fitness_performance(inbox_start_time, server.fitness,
@ -3829,7 +3837,7 @@ def _inbox_after_initial(server, inbox_start_time,
allow_local_network_access,
theme_name, system_language,
max_like_count, cw_lists, lists_enabled,
bold_reading):
bold_reading, dogwhistles):
if debug:
print('DEBUG: Bookmark accepted from ' + actor)
fitness_performance(inbox_start_time, server.fitness,
@ -3856,7 +3864,7 @@ def _inbox_after_initial(server, inbox_start_time,
allow_local_network_access,
theme_name, system_language,
max_like_count, cw_lists, lists_enabled,
bold_reading):
bold_reading, dogwhistles):
if debug:
print('DEBUG: Undo bookmark accepted from ' + actor)
fitness_performance(inbox_start_time, server.fitness,
@ -3891,7 +3899,7 @@ def _inbox_after_initial(server, inbox_start_time,
allow_deletion,
peertube_instances,
max_like_count, cw_lists, lists_enabled,
bold_reading):
bold_reading, dogwhistles):
if debug:
print('DEBUG: Announce accepted from ' + actor)
fitness_performance(inbox_start_time, server.fitness,
@ -4033,7 +4041,7 @@ def _inbox_after_initial(server, inbox_start_time,
theme_name, system_language,
max_like_count,
cw_lists, lists_enabled,
bold_reading)
bold_reading, dogwhistles)
fitness_performance(inbox_start_time, server.fitness,
'INBOX', '_receive_question_vote',
debug)
@ -4277,7 +4285,8 @@ def _inbox_after_initial(server, inbox_start_time,
cw_lists,
lists_enabled,
timezone, mitm,
bold_reading)
bold_reading,
dogwhistles)
fitness_performance(inbox_start_time,
server.fitness,
'INBOX',
@ -5237,6 +5246,11 @@ def run_inbox_queue(server,
debug)
inbox_start_time = time.time()
dogwhistles_filename = base_dir + '/accounts/dogwhistles.txt'
if not os.path.isfile(dogwhistles_filename):
dogwhistles_filename = base_dir + '/default_dogwhistles.txt'
dogwhistles = load_dogwhistles(dogwhistles_filename)
# set the id to the same as the post filename
# This makes the filename and the id consistent
# if queue_json['post'].get('id'):
@ -5328,7 +5342,7 @@ def run_inbox_queue(server,
show_published_date_only,
peertube_instances,
theme_name, max_like_count,
cw_lists):
cw_lists, dogwhistles):
if debug:
print('Queue: Update accepted from ' + key_id)
if os.path.isfile(queue_filename):
@ -5456,7 +5470,7 @@ def run_inbox_queue(server,
cw_lists, lists_enabled,
content_license_url,
languages_understood, mitm,
bold_reading)
bold_reading, dogwhistles)
fitness_performance(inbox_start_time, server.fitness,
'INBOX', 'handle_after_initial',
debug)

View File

@ -213,7 +213,8 @@ def post_message_to_outbox(session, translate: {},
max_like_count: int,
max_recent_posts: int, cw_lists: {},
lists_enabled: str,
content_license_url: str) -> bool:
content_license_url: str,
dogwhistles: {}) -> bool:
"""post is received by the outbox
Client to server message post
https://www.w3.org/TR/activitypub/#client-to-server-outbox-delivery
@ -513,7 +514,7 @@ def post_message_to_outbox(session, translate: {},
False, True, use_cache_only,
cw_lists, lists_enabled,
timezone, mitm,
bold_reading)
bold_reading, dogwhistles)
if outbox_announce(recent_posts_cache,
base_dir, message_json, debug):

View File

@ -142,7 +142,8 @@ def _update_post_schedule(base_dir: str, handle: str, httpd,
httpd.max_recent_posts,
httpd.cw_lists,
httpd.lists_enabled,
httpd.content_license_url):
httpd.content_license_url,
httpd.dogwhistles):
index_lines.remove(line)
try:
os.remove(post_filename)

View File

@ -38,7 +38,8 @@ def html_confirm_delete(server, css_cache: {},
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) -> str:
cw_lists: {}, lists_enabled: str,
dogwhistles: {}) -> str:
"""Shows a screen asking to confirm the deletion of a post
"""
if '/statuses/' not in message_id:
@ -90,7 +91,7 @@ def html_confirm_delete(server, css_cache: {},
theme_name, system_language, max_like_count,
False, False, False, False, False, False,
cw_lists, lists_enabled, timezone, mitm,
bold_reading)
bold_reading, dogwhistles)
delete_post_str += '<center>'
delete_post_str += \
' <p class="followText">' + \

View File

@ -224,7 +224,8 @@ def html_new_post(css_cache: {}, media_instance: bool, translate: {},
max_like_count: int, signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
box_name: str,
reply_is_chat: bool, bold_reading: bool) -> str:
reply_is_chat: bool, bold_reading: bool,
dogwhistles: {}) -> str:
"""New post screen
"""
reply_str = ''
@ -303,7 +304,7 @@ def html_new_post(css_cache: {}, media_instance: bool, translate: {},
False, False, False,
cw_lists, lists_enabled,
timezone, False,
bold_reading)
bold_reading, dogwhistles)
reply_str = '<input type="hidden" ' + \
'name="replyTo" value="' + in_reply_to + '">\n'

View File

@ -38,7 +38,8 @@ def _html_front_screen_posts(recent_posts_cache: {}, max_recent_posts: int,
max_like_count: int,
signing_priv_key_pem: str, cw_lists: {},
lists_enabled: str,
bold_reading: bool) -> str:
bold_reading: bool,
dogwhistles: {}) -> str:
"""Shows posts on the front screen of a news instance
These should only be public blog posts from the features timeline
which is the blog timeline of the news actor
@ -89,7 +90,7 @@ def _html_front_screen_posts(recent_posts_cache: {}, max_recent_posts: int,
True, False, False,
cw_lists, lists_enabled,
timezone, False,
bold_reading)
bold_reading, dogwhistles)
if post_str:
profile_str += post_str + separator_str
ctr += 1
@ -120,7 +121,8 @@ def html_front_screen(signing_priv_key_pem: str,
extra_json: {},
page_number: int,
max_items_per_page: int,
cw_lists: {}, lists_enabled: str) -> str:
cw_lists: {}, lists_enabled: str,
dogwhistles: {}) -> str:
"""Show the news instance front screen
"""
bold_reading = False
@ -195,7 +197,7 @@ def html_front_screen(signing_priv_key_pem: str,
max_like_count,
signing_priv_key_pem,
cw_lists, lists_enabled,
bold_reading) + license_str
bold_reading, dogwhistles) + license_str
# Footer which is only used for system accounts
profile_footer_str = ' </td>\n'

View File

@ -41,7 +41,7 @@ def html_likers_of_post(base_dir: str, nickname: str,
max_like_count: int, signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
box_name: str, default_timeline: str,
bold_reading: bool,
bold_reading: bool, dogwhistles: {},
dict_name: str = 'likes') -> str:
"""Returns html for a screen showing who liked a post
"""
@ -107,7 +107,8 @@ def html_likers_of_post(base_dir: str, nickname: str,
False, False, False,
False, False, False,
cw_lists, lists_enabled,
timezone, mitm, bold_reading)
timezone, mitm, bold_reading,
dogwhistles)
# show likers beneath the post
obj = post_json_object

View File

@ -57,7 +57,8 @@ def html_moderation(css_cache: {}, default_timeline: str,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Show the moderation feed as html
This is what you see when selecting the "mod" timeline
"""
@ -83,7 +84,7 @@ def html_moderation(css_cache: {}, default_timeline: str,
text_mode_banner, access_keys, system_language,
max_like_count, shared_items_federated_domains,
signing_priv_key_pem, cw_lists, lists_enabled,
timezone, bold_reading)
timezone, bold_reading, dogwhistles)
def html_account_info(css_cache: {}, translate: {},

View File

@ -1583,7 +1583,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
cw_lists: {},
lists_enabled: str,
timezone: str,
mitm: bool, bold_reading: bool) -> str:
mitm: bool, bold_reading: bool,
dogwhistles: {}) -> str:
""" Shows a single post as html
"""
if not post_json_object:
@ -2378,7 +2379,7 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
max_like_count: int, signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, mitm: bool,
bold_reading: bool) -> str:
bold_reading: bool, dogwhistles: {}) -> str:
"""Show an individual post as html
"""
original_post_json = post_json_object
@ -2447,7 +2448,7 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
system_language, max_like_count,
False, authorized, False, False, False, False,
cw_lists, lists_enabled, timezone, mitm,
bold_reading)
bold_reading, dogwhistles)
message_id = remove_id_ending(post_json_object['id'])
# show the previous posts
@ -2488,7 +2489,8 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
False, False, False, False,
cw_lists, lists_enabled,
timezone, mitm,
bold_reading) + post_str
bold_reading,
dogwhistles) + post_str
# show the following posts
post_filename = locate_post(base_dir, nickname, domain, message_id)
@ -2527,7 +2529,7 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
False, False, False, False,
cw_lists, lists_enabled,
timezone, False,
bold_reading)
bold_reading, dogwhistles)
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
css_filename = base_dir + '/epicyon.css'
@ -2555,7 +2557,8 @@ def html_post_replies(recent_posts_cache: {}, max_recent_posts: int,
max_like_count: int,
signing_priv_key_pem: str, cw_lists: {},
lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Show the replies to an individual post as html
"""
replies_str = ''
@ -2582,7 +2585,7 @@ def html_post_replies(recent_posts_cache: {}, max_recent_posts: int,
False, False,
cw_lists, lists_enabled,
timezone, False,
bold_reading)
bold_reading, dogwhistles)
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
@ -2611,7 +2614,8 @@ def html_emoji_reaction_picker(recent_posts_cache: {}, max_recent_posts: int,
max_like_count: int, signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
box_name: str, page_number: int,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Returns the emoji picker screen
"""
reacted_to_post_str = \
@ -2635,7 +2639,7 @@ def html_emoji_reaction_picker(recent_posts_cache: {}, max_recent_posts: int,
max_like_count,
False, False, False, False, False, False,
cw_lists, lists_enabled, timezone, False,
bold_reading)
bold_reading, dogwhistles)
reactions_filename = base_dir + '/emoji/reactions.json'
if not os.path.isfile(reactions_filename):

View File

@ -148,7 +148,7 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
cw_lists: {}, lists_enabled: str,
timezone: str,
onion_domain: str, i2p_domain: str,
bold_reading: bool) -> str:
bold_reading: bool, dogwhistles: {}) -> str:
"""Show a profile page after a search for a fediverse address
"""
http = False
@ -388,7 +388,7 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
False, False, False,
cw_lists, lists_enabled,
timezone, False,
bold_reading)
bold_reading, dogwhistles)
i += 1
if i >= 8:
break
@ -636,7 +636,7 @@ def html_profile(signing_priv_key_pem: str,
system_language, max_like_count,
shared_items_federated_domains, None,
page_number, max_items_per_page, cw_lists,
lists_enabled)
lists_enabled, {})
domain, port = get_domain_from_actor(profile_json['id'])
if not domain:
@ -1031,7 +1031,7 @@ def html_profile(signing_priv_key_pem: str,
max_like_count,
signing_priv_key_pem,
cw_lists, lists_enabled,
timezone, bold_reading) + license_str
timezone, bold_reading, {}) + license_str
if not is_group:
if selected == 'following':
profile_str += \
@ -1104,7 +1104,8 @@ def _html_profile_posts(recent_posts_cache: {}, max_recent_posts: int,
max_like_count: int,
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Shows posts on the profile screen
These should only be public posts
"""
@ -1154,7 +1155,7 @@ def _html_profile_posts(recent_posts_cache: {}, max_recent_posts: int,
True, False, False,
cw_lists, lists_enabled,
timezone, False,
bold_reading)
bold_reading, dogwhistles)
if post_str:
profile_str += post_str + separator_str
ctr += 1

View File

@ -621,7 +621,8 @@ def html_history_search(translate: {}, base_dir: str,
signing_priv_key_pem: str,
cw_lists: {},
lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Show a page containing search results for your post history
"""
if historysearch.startswith("'"):
@ -709,7 +710,8 @@ def html_history_search(translate: {}, base_dir: str,
show_individual_post_icons,
False, False, False, False,
cw_lists, lists_enabled,
timezone, False, bold_reading)
timezone, False, bold_reading,
dogwhistles)
if post_str:
history_search_form += separator_str + post_str
index += 1
@ -734,7 +736,8 @@ def html_hashtag_search(nickname: str, domain: str, port: int,
max_like_count: int,
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Show a page containing search results for a hashtag
or after selecting a hashtag from the swarm
"""
@ -897,7 +900,7 @@ def html_hashtag_search(nickname: str, domain: str, port: int,
show_public_only,
store_to_sache, False, cw_lists,
lists_enabled, timezone, False,
bold_reading)
bold_reading, dogwhistles)
if post_str:
hashtag_search_form += separator_str + post_str
index += 1

View File

@ -493,7 +493,8 @@ def html_timeline(css_cache: {}, default_timeline: str,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Show the timeline as html
"""
enable_timing_log = False
@ -1000,7 +1001,7 @@ def html_timeline(css_cache: {}, default_timeline: str,
False, True, use_cache_only,
cw_lists, lists_enabled,
timezone, mitm,
bold_reading)
bold_reading, dogwhistles)
_log_timeline_timing(enable_timing_log,
timeline_start_time, box_name, '12')
@ -1238,7 +1239,8 @@ def html_shares(css_cache: {}, default_timeline: str,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Show the shares timeline as html
"""
manually_approve_followers = \
@ -1269,7 +1271,7 @@ def html_shares(css_cache: {}, default_timeline: str,
shared_items_federated_domains,
signing_priv_key_pem,
cw_lists, lists_enabled, timezone,
bold_reading)
bold_reading, dogwhistles)
def html_wanted(css_cache: {}, default_timeline: str,
@ -1298,7 +1300,8 @@ def html_wanted(css_cache: {}, default_timeline: str,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Show the wanted timeline as html
"""
manually_approve_followers = \
@ -1329,7 +1332,7 @@ def html_wanted(css_cache: {}, default_timeline: str,
shared_items_federated_domains,
signing_priv_key_pem,
cw_lists, lists_enabled, timezone,
bold_reading)
bold_reading, dogwhistles)
def html_inbox(css_cache: {}, default_timeline: str,
@ -1359,7 +1362,8 @@ def html_inbox(css_cache: {}, default_timeline: str,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Show the inbox as html
"""
manually_approve_followers = \
@ -1390,7 +1394,7 @@ def html_inbox(css_cache: {}, default_timeline: str,
shared_items_federated_domains,
signing_priv_key_pem,
cw_lists, lists_enabled, timezone,
bold_reading)
bold_reading, dogwhistles)
def html_bookmarks(css_cache: {}, default_timeline: str,
@ -1420,7 +1424,8 @@ def html_bookmarks(css_cache: {}, default_timeline: str,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Show the bookmarks as html
"""
manually_approve_followers = \
@ -1450,7 +1455,7 @@ def html_bookmarks(css_cache: {}, default_timeline: str,
access_keys, system_language, max_like_count,
shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone,
bold_reading)
bold_reading, dogwhistles)
def html_inbox_dms(css_cache: {}, default_timeline: str,
@ -1480,7 +1485,8 @@ def html_inbox_dms(css_cache: {}, default_timeline: str,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Show the DM timeline as html
"""
artist = is_artist(base_dir, nickname)
@ -1506,7 +1512,7 @@ def html_inbox_dms(css_cache: {}, default_timeline: str,
shared_items_federated_domains,
signing_priv_key_pem,
cw_lists, lists_enabled, timezone,
bold_reading)
bold_reading, dogwhistles)
def html_inbox_replies(css_cache: {}, default_timeline: str,
@ -1536,7 +1542,8 @@ def html_inbox_replies(css_cache: {}, default_timeline: str,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Show the replies timeline as html
"""
artist = is_artist(base_dir, nickname)
@ -1560,7 +1567,8 @@ def html_inbox_replies(css_cache: {}, default_timeline: str,
allow_local_network_access, text_mode_banner,
access_keys, system_language, max_like_count,
shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading)
cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles)
def html_inbox_media(css_cache: {}, default_timeline: str,
@ -1590,7 +1598,8 @@ def html_inbox_media(css_cache: {}, default_timeline: str,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Show the media timeline as html
"""
artist = is_artist(base_dir, nickname)
@ -1614,7 +1623,8 @@ def html_inbox_media(css_cache: {}, default_timeline: str,
allow_local_network_access, text_mode_banner,
access_keys, system_language, max_like_count,
shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading)
cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles)
def html_inbox_blogs(css_cache: {}, default_timeline: str,
@ -1644,7 +1654,8 @@ def html_inbox_blogs(css_cache: {}, default_timeline: str,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Show the blogs timeline as html
"""
artist = is_artist(base_dir, nickname)
@ -1668,7 +1679,8 @@ def html_inbox_blogs(css_cache: {}, default_timeline: str,
allow_local_network_access, text_mode_banner,
access_keys, system_language, max_like_count,
shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading)
cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles)
def html_inbox_features(css_cache: {}, default_timeline: str,
@ -1699,7 +1711,8 @@ def html_inbox_features(css_cache: {}, default_timeline: str,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Show the features timeline as html
"""
return html_timeline(css_cache, default_timeline,
@ -1722,7 +1735,8 @@ def html_inbox_features(css_cache: {}, default_timeline: str,
allow_local_network_access, text_mode_banner,
access_keys, system_language, max_like_count,
shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading)
cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles)
def html_inbox_news(css_cache: {}, default_timeline: str,
@ -1752,7 +1766,8 @@ def html_inbox_news(css_cache: {}, default_timeline: str,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Show the news timeline as html
"""
return html_timeline(css_cache, default_timeline,
@ -1775,7 +1790,8 @@ def html_inbox_news(css_cache: {}, default_timeline: str,
allow_local_network_access, text_mode_banner,
access_keys, system_language, max_like_count,
shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading)
cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles)
def html_outbox(css_cache: {}, default_timeline: str,
@ -1805,7 +1821,8 @@ def html_outbox(css_cache: {}, default_timeline: str,
shared_items_federated_domains: [],
signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
timezone: str, bold_reading: bool) -> str:
timezone: str, bold_reading: bool,
dogwhistles: {}) -> str:
"""Show the Outbox as html
"""
manually_approve_followers = \
@ -1831,4 +1848,5 @@ def html_outbox(css_cache: {}, default_timeline: str,
allow_local_network_access, text_mode_banner,
access_keys, system_language, max_like_count,
shared_items_federated_domains, signing_priv_key_pem,
cw_lists, lists_enabled, timezone, bold_reading)
cw_lists, lists_enabled, timezone, bold_reading,
dogwhistles)