merge-requests/30/head
Bob Mottram 2024-04-14 13:50:58 +01:00
parent 8e5e5dfd71
commit f58c1cf053
2 changed files with 39 additions and 22 deletions

View File

@ -328,7 +328,19 @@ def daemon_http_post(self) -> None:
self.server.http_prefix, self.server.http_prefix,
self.server.domain, self.server.domain,
self.server.port, self.server.port,
self.server.debug) self.server.debug,
self.server.domain_full,
self.server.onion_domain,
self.server.i2p_domain,
self.server.translate,
self.server.system_language,
self.server.signing_priv_key_pem,
self.server.block_federated,
self.server.theme_name,
self.server.access_keys,
self.server.person_cache,
self.server.recent_posts_cache,
self.server.blocked_cache)
self.server.postreq_busy = False self.server.postreq_busy = False
return return

View File

@ -37,17 +37,25 @@ from blocking import remove_global_block
def moderator_actions(self, path: str, calling_domain: str, cookie: str, def moderator_actions(self, path: str, calling_domain: str, cookie: str,
base_dir: str, http_prefix: str, base_dir: str, http_prefix: str,
domain: str, port: int, debug: bool) -> None: domain: str, port: int, debug: bool,
domain_full: str,
onion_domain: str, i2p_domain: str,
translate: {},
system_language: str,
signing_priv_key_pem: str,
block_federated: [],
theme_name: str,
access_keys: {}, person_cache: {},
recent_posts_cache: {},
blocked_cache: {}) -> None:
"""Actions on the moderator screen """Actions on the moderator screen
""" """
users_path = path.replace('/moderationaction', '') users_path = path.replace('/moderationaction', '')
nickname = users_path.replace('/users/', '') nickname = users_path.replace('/users/', '')
actor_str = \ actor_str = \
get_instance_url(calling_domain, get_instance_url(calling_domain,
http_prefix, http_prefix, domain_full,
self.server.domain_full, onion_domain, i2p_domain) + \
self.server.onion_domain,
self.server.i2p_domain) + \
users_path users_path
if not is_moderator(base_dir, nickname): if not is_moderator(base_dir, nickname):
redirect_headers(self, actor_str + '/moderation', redirect_headers(self, actor_str + '/moderation',
@ -137,7 +145,7 @@ def moderator_actions(self, path: str, calling_domain: str, cookie: str,
if '@' not in search_handle: if '@' not in search_handle:
# is this a local nickname on this instance? # is this a local nickname on this instance?
local_handle = \ local_handle = \
search_handle + '@' + self.server.domain search_handle + '@' + domain
if os.path.isdir(base_dir + if os.path.isdir(base_dir +
'/accounts/' + local_handle): '/accounts/' + local_handle):
search_handle = local_handle search_handle = local_handle
@ -147,23 +155,23 @@ def moderator_actions(self, path: str, calling_domain: str, cookie: str,
search_handle = '' search_handle = ''
if '@' in search_handle: if '@' in search_handle:
msg = \ msg = \
html_account_info(self.server.translate, html_account_info(translate,
base_dir, http_prefix, base_dir, http_prefix,
nickname, nickname,
domain, domain,
search_handle, search_handle,
debug, debug,
self.server.system_language, system_language,
self.server.signing_priv_key_pem, signing_priv_key_pem,
None, None,
self.server.block_federated) block_federated)
else: else:
msg = \ msg = \
html_moderation_info(self.server.translate, html_moderation_info(translate,
base_dir, nickname, base_dir, nickname,
domain, domain,
self.server.theme_name, theme_name,
self.server.access_keys) access_keys)
if msg: if msg:
msg = msg.encode('utf-8') msg = msg.encode('utf-8')
msglen = len(msg) msglen = len(msg)
@ -209,8 +217,7 @@ def moderator_actions(self, path: str, calling_domain: str, cookie: str,
if moderation_button == 'unfilter': if moderation_button == 'unfilter':
remove_global_filter(base_dir, moderation_text) remove_global_filter(base_dir, moderation_text)
if moderation_button == 'clearcache': if moderation_button == 'clearcache':
clear_actor_cache(base_dir, clear_actor_cache(base_dir, person_cache,
self.server.person_cache,
moderation_text) moderation_text)
if moderation_button == 'block': if moderation_button == 'block':
full_block_domain = None full_block_domain = None
@ -249,8 +256,7 @@ def moderator_actions(self, path: str, calling_domain: str, cookie: str,
blocked_cache_last_updated = \ blocked_cache_last_updated = \
self.server.blocked_cache_last_updated self.server.blocked_cache_last_updated
self.server.blocked_cache_last_updated = \ self.server.blocked_cache_last_updated = \
update_blocked_cache(base_dir, update_blocked_cache(base_dir, blocked_cache,
self.server.blocked_cache,
blocked_cache_last_updated, 0) blocked_cache_last_updated, 0)
if moderation_button == 'unblock': if moderation_button == 'unblock':
full_block_domain = None full_block_domain = None
@ -284,8 +290,7 @@ def moderator_actions(self, path: str, calling_domain: str, cookie: str,
blocked_cache_last_updated = \ blocked_cache_last_updated = \
self.server.blocked_cache_last_updated self.server.blocked_cache_last_updated
self.server.blocked_cache_last_updated = \ self.server.blocked_cache_last_updated = \
update_blocked_cache(base_dir, update_blocked_cache(base_dir, blocked_cache,
self.server.blocked_cache,
blocked_cache_last_updated, 0) blocked_cache_last_updated, 0)
if moderation_button == 'remove': if moderation_button == 'remove':
if '/statuses/' not in moderation_text: if '/statuses/' not in moderation_text:
@ -303,7 +308,7 @@ def moderator_actions(self, path: str, calling_domain: str, cookie: str,
nickname, domain, nickname, domain,
post_filename, post_filename,
debug, debug,
self.server.recent_posts_cache, recent_posts_cache,
True) True)
if nickname != 'news': if nickname != 'news':
# if this is a local blog post then also remove it # if this is a local blog post then also remove it
@ -319,7 +324,7 @@ def moderator_actions(self, path: str, calling_domain: str, cookie: str,
'news', domain, 'news', domain,
post_filename, post_filename,
debug, debug,
self.server.recent_posts_cache, recent_posts_cache,
True) True)
redirect_headers(self, actor_str + '/moderation', redirect_headers(self, actor_str + '/moderation',