main
Bob Mottram 2024-04-13 12:57:29 +01:00
parent 8b0b378d3a
commit 95fe071622
2 changed files with 180 additions and 158 deletions

View File

@ -337,7 +337,39 @@ def daemon_http_post(self) -> None:
self.server.debug, self.server.debug,
curr_session, curr_session,
proxy_type, MAX_POSTS_IN_HASHTAG_FEED, proxy_type, MAX_POSTS_IN_HASHTAG_FEED,
MAX_POSTS_IN_FEED) MAX_POSTS_IN_FEED,
self.server.default_timeline,
self.server.account_timezone,
self.server.bold_reading,
self.server.recent_posts_cache,
self.server.max_recent_posts,
self.server.translate,
self.server.cached_webfingers,
self.server.person_cache,
self.server.project_version,
self.server.yt_replace_domain,
self.server.twitter_replacement_domain,
self.server.show_published_date_only,
self.server.peertube_instances,
self.server.allow_local_network_access,
self.server.theme_name,
self.server.system_language,
self.server.max_like_count,
self.server.signing_priv_key_pem,
self.server.cw_lists,
self.server.lists_enabled,
self.server.dogwhistles,
self.server.map_format,
self.server.access_keys,
self.server.min_images_for_accounts,
self.server.buy_sites,
self.server.auto_cw_cache,
self.server.instance_only_skills_search,
self.server.key_shortcuts,
self.server.max_shares_on_profile,
self.server.no_of_books,
self.server.shared_items_federated_domains)
self.server.postreq_busy = False self.server.postreq_busy = False
return return

View File

@ -43,7 +43,38 @@ def receive_search_query(self, calling_domain: str, cookie: str,
getreq_start_time, debug: bool, getreq_start_time, debug: bool,
curr_session, proxy_type: str, curr_session, proxy_type: str,
max_posts_in_hashtag_feed: int, max_posts_in_hashtag_feed: int,
max_posts_in_feed: int) -> None: max_posts_in_feed: int,
default_timeline: str,
account_timezone: {},
bold_reading_nicknames: {},
recent_posts_cache: {},
max_recent_posts: int,
translate: {},
cached_webfingers: {},
person_cache: {},
project_version: str,
yt_replace_domain: str,
twitter_replacement_domain: str,
show_published_date_only: bool,
peertube_instances: [],
allow_local_network_access: bool,
theme_name: str,
system_language: str,
max_like_count: int,
signing_priv_key_pem: str,
cw_lists: {},
lists_enabled: {},
dogwhistles: {},
map_format: str,
access_keys: {},
min_images_for_accounts: bool,
buy_sites: [],
auto_cw_cache: {},
instance_only_skills_search: bool,
key_shortcuts: {},
max_shares_on_profile: int,
no_of_books: int,
shared_items_federated_domains: []) -> None:
"""Receive a search query """Receive a search query
""" """
# get the page number # get the page number
@ -60,11 +91,8 @@ def receive_search_query(self, calling_domain: str, cookie: str,
users_path = path.replace('/searchhandle', '') users_path = path.replace('/searchhandle', '')
actor_str = \ actor_str = \
get_instance_url(calling_domain, get_instance_url(calling_domain, http_prefix, domain_full,
http_prefix, onion_domain, i2p_domain) + \
domain_full,
onion_domain,
i2p_domain) + \
users_path users_path
length = int(self.headers['Content-length']) length = int(self.headers['Content-length'])
try: try:
@ -87,8 +115,7 @@ def receive_search_query(self, calling_domain: str, cookie: str,
if 'submitBack=' in search_params: if 'submitBack=' in search_params:
# go back on search screen # go back on search screen
redirect_headers(self, actor_str + '/' + redirect_headers(self, actor_str + '/' +
self.server.default_timeline, default_timeline, cookie, calling_domain)
cookie, calling_domain)
self.server.postreq_busy = False self.server.postreq_busy = False
return return
if 'searchtext=' in search_params: if 'searchtext=' in search_params:
@ -122,44 +149,43 @@ def receive_search_query(self, calling_domain: str, cookie: str,
# hashtag search # hashtag search
timezone = None timezone = None
if self.server.account_timezone.get(nickname): if account_timezone.get(nickname):
timezone = \ timezone = account_timezone.get(nickname)
self.server.account_timezone.get(nickname)
bold_reading = False bold_reading = False
if self.server.bold_reading.get(nickname): if bold_reading_nicknames.get(nickname):
bold_reading = True bold_reading = True
hashtag_str = \ hashtag_str = \
html_hashtag_search(nickname, domain, port, html_hashtag_search(nickname, domain, port,
self.server.recent_posts_cache, recent_posts_cache,
self.server.max_recent_posts, max_recent_posts,
self.server.translate, translate,
base_dir, base_dir,
search_str[1:], 1, search_str[1:], 1,
max_posts_in_hashtag_feed, max_posts_in_hashtag_feed,
curr_session, curr_session,
self.server.cached_webfingers, cached_webfingers,
self.server.person_cache, person_cache,
http_prefix, http_prefix,
self.server.project_version, project_version,
self.server.yt_replace_domain, yt_replace_domain,
self.server.twitter_replacement_domain, twitter_replacement_domain,
self.server.show_published_date_only, show_published_date_only,
self.server.peertube_instances, peertube_instances,
self.server.allow_local_network_access, allow_local_network_access,
self.server.theme_name, theme_name,
self.server.system_language, system_language,
self.server.max_like_count, max_like_count,
self.server.signing_priv_key_pem, signing_priv_key_pem,
self.server.cw_lists, cw_lists,
self.server.lists_enabled, lists_enabled,
timezone, bold_reading, timezone, bold_reading,
self.server.dogwhistles, dogwhistles,
self.server.map_format, map_format,
self.server.access_keys, access_keys,
'search', 'search',
self.server.min_images_for_accounts, min_images_for_accounts,
self.server.buy_sites, buy_sites,
self.server.auto_cw_cache) auto_cw_cache)
if hashtag_str: if hashtag_str:
msg = hashtag_str.encode('utf-8') msg = hashtag_str.encode('utf-8')
msglen = len(msg) msglen = len(msg)
@ -181,14 +207,11 @@ def receive_search_query(self, calling_domain: str, cookie: str,
search_str = search_str.replace('*', '').strip() search_str = search_str.replace('*', '').strip()
nickname = get_nickname_from_actor(actor_str) nickname = get_nickname_from_actor(actor_str)
skill_str = \ skill_str = \
html_skills_search(actor_str, html_skills_search(actor_str, translate,
self.server.translate, base_dir, search_str,
base_dir, instance_only_skills_search,
search_str,
self.server.instance_only_skills_search,
64, nickname, domain, 64, nickname, domain,
self.server.theme_name, theme_name, access_keys)
self.server.access_keys)
if skill_str: if skill_str:
msg = skill_str.encode('utf-8') msg = skill_str.encode('utf-8')
msglen = len(msg) msglen = len(msg)
@ -225,14 +248,13 @@ def receive_search_query(self, calling_domain: str, cookie: str,
return return
search_str = search_str.replace("'", '', 1).strip() search_str = search_str.replace("'", '', 1).strip()
timezone = None timezone = None
if self.server.account_timezone.get(nickname): if account_timezone.get(nickname):
timezone = \ timezone = account_timezone.get(nickname)
self.server.account_timezone.get(nickname)
bold_reading = False bold_reading = False
if self.server.bold_reading.get(nickname): if bold_reading_nicknames.get(nickname):
bold_reading = True bold_reading = True
history_str = \ history_str = \
html_history_search(self.server.translate, html_history_search(translate,
base_dir, base_dir,
http_prefix, http_prefix,
nickname, nickname,
@ -240,30 +262,30 @@ def receive_search_query(self, calling_domain: str, cookie: str,
search_str, search_str,
max_posts_in_feed, max_posts_in_feed,
page_number, page_number,
self.server.project_version, project_version,
self.server.recent_posts_cache, recent_posts_cache,
self.server.max_recent_posts, max_recent_posts,
curr_session, curr_session,
self.server.cached_webfingers, cached_webfingers,
self.server.person_cache, person_cache,
port, port,
self.server.yt_replace_domain, yt_replace_domain,
self.server.twitter_replacement_domain, twitter_replacement_domain,
self.server.show_published_date_only, show_published_date_only,
self.server.peertube_instances, peertube_instances,
self.server.allow_local_network_access, allow_local_network_access,
self.server.theme_name, 'outbox', theme_name, 'outbox',
self.server.system_language, system_language,
self.server.max_like_count, max_like_count,
self.server.signing_priv_key_pem, signing_priv_key_pem,
self.server.cw_lists, cw_lists,
self.server.lists_enabled, lists_enabled,
timezone, bold_reading, timezone, bold_reading,
self.server.dogwhistles, dogwhistles,
self.server.access_keys, access_keys,
self.server.min_images_for_accounts, min_images_for_accounts,
self.server.buy_sites, buy_sites,
self.server.auto_cw_cache) auto_cw_cache)
if history_str: if history_str:
msg = history_str.encode('utf-8') msg = history_str.encode('utf-8')
msglen = len(msg) msglen = len(msg)
@ -300,14 +322,13 @@ def receive_search_query(self, calling_domain: str, cookie: str,
return return
search_str = search_str.replace('-', '', 1).strip() search_str = search_str.replace('-', '', 1).strip()
timezone = None timezone = None
if self.server.account_timezone.get(nickname): if account_timezone.get(nickname):
timezone = \ timezone = account_timezone.get(nickname)
self.server.account_timezone.get(nickname)
bold_reading = False bold_reading = False
if self.server.bold_reading.get(nickname): if bold_reading_nicknames.get(nickname):
bold_reading = True bold_reading = True
bookmarks_str = \ bookmarks_str = \
html_history_search(self.server.translate, html_history_search(translate,
base_dir, base_dir,
http_prefix, http_prefix,
nickname, nickname,
@ -315,30 +336,30 @@ def receive_search_query(self, calling_domain: str, cookie: str,
search_str, search_str,
max_posts_in_feed, max_posts_in_feed,
page_number, page_number,
self.server.project_version, project_version,
self.server.recent_posts_cache, recent_posts_cache,
self.server.max_recent_posts, max_recent_posts,
curr_session, curr_session,
self.server.cached_webfingers, cached_webfingers,
self.server.person_cache, person_cache,
port, port,
self.server.yt_replace_domain, yt_replace_domain,
self.server.twitter_replacement_domain, twitter_replacement_domain,
self.server.show_published_date_only, show_published_date_only,
self.server.peertube_instances, peertube_instances,
self.server.allow_local_network_access, allow_local_network_access,
self.server.theme_name, 'bookmarks', theme_name, 'bookmarks',
self.server.system_language, system_language,
self.server.max_like_count, max_like_count,
self.server.signing_priv_key_pem, signing_priv_key_pem,
self.server.cw_lists, cw_lists,
self.server.lists_enabled, lists_enabled,
timezone, bold_reading, timezone, bold_reading,
self.server.dogwhistles, dogwhistles,
self.server.access_keys, access_keys,
self.server.min_images_for_accounts, min_images_for_accounts,
self.server.buy_sites, buy_sites,
self.server.auto_cw_cache) auto_cw_cache)
if bookmarks_str: if bookmarks_str:
msg = bookmarks_str.encode('utf-8') msg = bookmarks_str.encode('utf-8')
msglen = len(msg) msglen = len(msg)
@ -422,9 +443,9 @@ def receive_search_query(self, calling_domain: str, cookie: str,
get_avatar_image_url(curr_session, get_avatar_image_url(curr_session,
base_dir, http_prefix, base_dir, http_prefix,
actor, actor,
self.server.person_cache, person_cache,
None, True, None, True,
self.server.signing_priv_key_pem) signing_priv_key_pem)
profile_path_str += \ profile_path_str += \
'?options=' + actor + ';1;' + avatar_url '?options=' + actor + ';1;' + avatar_url
@ -436,31 +457,12 @@ def receive_search_query(self, calling_domain: str, cookie: str,
curr_session) curr_session)
return return
else: else:
show_published_date_only = \ if key_shortcuts.get(nickname):
self.server.show_published_date_only access_keys = key_shortcuts[nickname]
allow_local_network_access = \
self.server.allow_local_network_access
access_keys = self.server.access_keys
if self.server.key_shortcuts.get(nickname):
access_keys = self.server.key_shortcuts[nickname]
signing_priv_key_pem = \
self.server.signing_priv_key_pem
twitter_replacement_domain = \
self.server.twitter_replacement_domain
peertube_instances = \
self.server.peertube_instances
yt_replace_domain = \
self.server.yt_replace_domain
cached_webfingers = \
self.server.cached_webfingers
recent_posts_cache = \
self.server.recent_posts_cache
timezone = None timezone = None
if self.server.account_timezone.get(nickname): if account_timezone.get(nickname):
timezone = \ timezone = account_timezone.get(nickname)
self.server.account_timezone.get(nickname)
profile_handle = remove_eol(search_str).strip() profile_handle = remove_eol(search_str).strip()
@ -485,18 +487,14 @@ def receive_search_query(self, calling_domain: str, cookie: str,
return return
bold_reading = False bold_reading = False
if self.server.bold_reading.get(nickname): if bold_reading_nicknames.get(nickname):
bold_reading = True bold_reading = True
min_images_for_accounts = \
self.server.min_images_for_accounts
max_shares_on_profile = \
self.server.max_shares_on_profile
profile_str = \ profile_str = \
html_profile_after_search(authorized, html_profile_after_search(authorized,
recent_posts_cache, recent_posts_cache,
self.server.max_recent_posts, max_recent_posts,
self.server.translate, translate,
base_dir, base_dir,
profile_path_str, profile_path_str,
http_prefix, http_prefix,
@ -506,32 +504,32 @@ def receive_search_query(self, calling_domain: str, cookie: str,
profile_handle, profile_handle,
curr_session, curr_session,
cached_webfingers, cached_webfingers,
self.server.person_cache, person_cache,
debug, debug,
self.server.project_version, project_version,
yt_replace_domain, yt_replace_domain,
twitter_replacement_domain, twitter_replacement_domain,
show_published_date_only, show_published_date_only,
self.server.default_timeline, default_timeline,
peertube_instances, peertube_instances,
allow_local_network_access, allow_local_network_access,
self.server.theme_name, theme_name,
access_keys, access_keys,
self.server.system_language, system_language,
self.server.max_like_count, max_like_count,
signing_priv_key_pem, signing_priv_key_pem,
self.server.cw_lists, cw_lists,
self.server.lists_enabled, lists_enabled,
timezone, timezone,
onion_domain, onion_domain,
i2p_domain, i2p_domain,
bold_reading, bold_reading,
self.server.dogwhistles, dogwhistles,
min_images_for_accounts, min_images_for_accounts,
self.server.buy_sites, buy_sites,
max_shares_on_profile, max_shares_on_profile,
self.server.no_of_books, no_of_books,
self.server.auto_cw_cache) auto_cw_cache)
if profile_str: if profile_str:
msg = profile_str.encode('utf-8') msg = profile_str.encode('utf-8')
msglen = len(msg) msglen = len(msg)
@ -558,26 +556,22 @@ def receive_search_query(self, calling_domain: str, cookie: str,
# emoji search # emoji search
nickname = get_nickname_from_actor(actor_str) nickname = get_nickname_from_actor(actor_str)
emoji_str = \ emoji_str = \
html_search_emoji(self.server.translate, html_search_emoji(translate,
base_dir, search_str, base_dir, search_str,
nickname, domain, nickname, domain,
self.server.theme_name, theme_name, access_keys)
self.server.access_keys)
if emoji_str: if emoji_str:
msg = emoji_str.encode('utf-8') msg = emoji_str.encode('utf-8')
msglen = len(msg) msglen = len(msg)
login_headers(self, 'text/html', login_headers(self, 'text/html', msglen, calling_domain)
msglen, calling_domain)
write2(self, msg) write2(self, msg)
self.server.postreq_busy = False self.server.postreq_busy = False
return return
elif search_str.startswith('.'): elif search_str.startswith('.'):
# wanted items search # wanted items search
shared_items_federated_domains = \
self.server.shared_items_federated_domains
nickname = get_nickname_from_actor(actor_str) nickname = get_nickname_from_actor(actor_str)
wanted_items_str = \ wanted_items_str = \
html_search_shared_items(self.server.translate, html_search_shared_items(translate,
base_dir, base_dir,
search_str[1:], page_number, search_str[1:], page_number,
max_posts_in_feed, max_posts_in_feed,
@ -586,23 +580,20 @@ def receive_search_query(self, calling_domain: str, cookie: str,
actor_str, calling_domain, actor_str, calling_domain,
shared_items_federated_domains, shared_items_federated_domains,
'wanted', nickname, domain, 'wanted', nickname, domain,
self.server.theme_name, theme_name,
self.server.access_keys) access_keys)
if wanted_items_str: if wanted_items_str:
msg = wanted_items_str.encode('utf-8') msg = wanted_items_str.encode('utf-8')
msglen = len(msg) msglen = len(msg)
login_headers(self, 'text/html', login_headers(self, 'text/html', msglen, calling_domain)
msglen, calling_domain)
write2(self, msg) write2(self, msg)
self.server.postreq_busy = False self.server.postreq_busy = False
return return
else: else:
# shared items search # shared items search
shared_items_federated_domains = \
self.server.shared_items_federated_domains
nickname = get_nickname_from_actor(actor_str) nickname = get_nickname_from_actor(actor_str)
shared_items_str = \ shared_items_str = \
html_search_shared_items(self.server.translate, html_search_shared_items(translate,
base_dir, base_dir,
search_str, page_number, search_str, page_number,
max_posts_in_feed, max_posts_in_feed,
@ -611,8 +602,8 @@ def receive_search_query(self, calling_domain: str, cookie: str,
actor_str, calling_domain, actor_str, calling_domain,
shared_items_federated_domains, shared_items_federated_domains,
'shares', nickname, domain, 'shares', nickname, domain,
self.server.theme_name, theme_name,
self.server.access_keys) access_keys)
if shared_items_str: if shared_items_str:
msg = shared_items_str.encode('utf-8') msg = shared_items_str.encode('utf-8')
msglen = len(msg) msglen = len(msg)
@ -625,7 +616,6 @@ def receive_search_query(self, calling_domain: str, cookie: str,
get_instance_url(calling_domain, http_prefix, get_instance_url(calling_domain, http_prefix,
domain_full, onion_domain, i2p_domain) + \ domain_full, onion_domain, i2p_domain) + \
users_path users_path
redirect_headers(self, actor_str + '/' + redirect_headers(self, actor_str + '/' + default_timeline,
self.server.default_timeline,
cookie, calling_domain) cookie, calling_domain)
self.server.postreq_busy = False self.server.postreq_busy = False