mirror of https://gitlab.com/bashrc2/epicyon
Separate function for search of your posts
parent
7b080accc8
commit
a232af9a09
|
@ -181,6 +181,117 @@ def _receive_search_skills(self, search_str: str,
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def _receive_search_my_posts(self, search_str: str,
|
||||||
|
actor_str: str,
|
||||||
|
account_timezone: {},
|
||||||
|
bold_reading_nicknames: {},
|
||||||
|
translate: {},
|
||||||
|
base_dir: str,
|
||||||
|
http_prefix: str,
|
||||||
|
domain: str,
|
||||||
|
max_posts_in_feed: int,
|
||||||
|
page_number: int,
|
||||||
|
project_version: str,
|
||||||
|
recent_posts_cache: {},
|
||||||
|
max_recent_posts: int,
|
||||||
|
curr_session,
|
||||||
|
cached_webfingers: {},
|
||||||
|
person_cache: {},
|
||||||
|
port: int,
|
||||||
|
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: {},
|
||||||
|
access_keys: {},
|
||||||
|
min_images_for_accounts: {},
|
||||||
|
buy_sites: [],
|
||||||
|
auto_cw_cache: {},
|
||||||
|
calling_domain: str) -> bool:
|
||||||
|
"""Receive a search for your own posts from the search screen
|
||||||
|
"""
|
||||||
|
# your post history search
|
||||||
|
possible_endings = (
|
||||||
|
' in my posts',
|
||||||
|
' in my history',
|
||||||
|
' in my outbox',
|
||||||
|
' in sent posts',
|
||||||
|
' in outgoing posts',
|
||||||
|
' in sent items',
|
||||||
|
' in history',
|
||||||
|
' in outbox',
|
||||||
|
' in outgoing',
|
||||||
|
' in sent',
|
||||||
|
' history'
|
||||||
|
)
|
||||||
|
for poss_ending in possible_endings:
|
||||||
|
if search_str.endswith(poss_ending):
|
||||||
|
search_str = search_str.replace(poss_ending, '')
|
||||||
|
break
|
||||||
|
nickname = get_nickname_from_actor(actor_str)
|
||||||
|
if not nickname:
|
||||||
|
self.send_response(400)
|
||||||
|
self.end_headers()
|
||||||
|
self.server.postreq_busy = False
|
||||||
|
return True
|
||||||
|
search_str = search_str.replace("'", '', 1).strip()
|
||||||
|
timezone = None
|
||||||
|
if account_timezone.get(nickname):
|
||||||
|
timezone = account_timezone.get(nickname)
|
||||||
|
bold_reading = False
|
||||||
|
if bold_reading_nicknames.get(nickname):
|
||||||
|
bold_reading = True
|
||||||
|
history_str = \
|
||||||
|
html_history_search(translate,
|
||||||
|
base_dir,
|
||||||
|
http_prefix,
|
||||||
|
nickname,
|
||||||
|
domain,
|
||||||
|
search_str,
|
||||||
|
max_posts_in_feed,
|
||||||
|
page_number,
|
||||||
|
project_version,
|
||||||
|
recent_posts_cache,
|
||||||
|
max_recent_posts,
|
||||||
|
curr_session,
|
||||||
|
cached_webfingers,
|
||||||
|
person_cache,
|
||||||
|
port,
|
||||||
|
yt_replace_domain,
|
||||||
|
twitter_replacement_domain,
|
||||||
|
show_published_date_only,
|
||||||
|
peertube_instances,
|
||||||
|
allow_local_network_access,
|
||||||
|
theme_name, 'outbox',
|
||||||
|
system_language,
|
||||||
|
max_like_count,
|
||||||
|
signing_priv_key_pem,
|
||||||
|
cw_lists,
|
||||||
|
lists_enabled,
|
||||||
|
timezone, bold_reading,
|
||||||
|
dogwhistles,
|
||||||
|
access_keys,
|
||||||
|
min_images_for_accounts,
|
||||||
|
buy_sites,
|
||||||
|
auto_cw_cache)
|
||||||
|
if history_str:
|
||||||
|
msg = history_str.encode('utf-8')
|
||||||
|
msglen = len(msg)
|
||||||
|
login_headers(self, 'text/html',
|
||||||
|
msglen, calling_domain)
|
||||||
|
write2(self, msg)
|
||||||
|
self.server.postreq_busy = False
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def receive_search_query(self, calling_domain: str, cookie: str,
|
def receive_search_query(self, calling_domain: str, cookie: str,
|
||||||
authorized: bool, path: str,
|
authorized: bool, path: str,
|
||||||
base_dir: str, http_prefix: str,
|
base_dir: str, http_prefix: str,
|
||||||
|
@ -341,77 +452,40 @@ def receive_search_query(self, calling_domain: str, cookie: str,
|
||||||
return
|
return
|
||||||
elif (search_str.startswith("'") or
|
elif (search_str.startswith("'") or
|
||||||
string_ends_with(search_str, my_posts_endings)):
|
string_ends_with(search_str, my_posts_endings)):
|
||||||
# your post history search
|
if _receive_search_my_posts(self, search_str,
|
||||||
possible_endings = (
|
actor_str,
|
||||||
' in my posts',
|
account_timezone,
|
||||||
' in my history',
|
bold_reading_nicknames,
|
||||||
' in my outbox',
|
translate,
|
||||||
' in sent posts',
|
base_dir,
|
||||||
' in outgoing posts',
|
http_prefix,
|
||||||
' in sent items',
|
domain,
|
||||||
' in history',
|
max_posts_in_feed,
|
||||||
' in outbox',
|
page_number,
|
||||||
' in outgoing',
|
project_version,
|
||||||
' in sent',
|
recent_posts_cache,
|
||||||
' history'
|
max_recent_posts,
|
||||||
)
|
curr_session,
|
||||||
for poss_ending in possible_endings:
|
cached_webfingers,
|
||||||
if search_str.endswith(poss_ending):
|
person_cache,
|
||||||
search_str = search_str.replace(poss_ending, '')
|
port,
|
||||||
break
|
yt_replace_domain,
|
||||||
nickname = get_nickname_from_actor(actor_str)
|
twitter_replacement_domain,
|
||||||
if not nickname:
|
show_published_date_only,
|
||||||
self.send_response(400)
|
peertube_instances,
|
||||||
self.end_headers()
|
allow_local_network_access,
|
||||||
self.server.postreq_busy = False
|
theme_name,
|
||||||
return
|
system_language,
|
||||||
search_str = search_str.replace("'", '', 1).strip()
|
max_like_count,
|
||||||
timezone = None
|
signing_priv_key_pem,
|
||||||
if account_timezone.get(nickname):
|
cw_lists,
|
||||||
timezone = account_timezone.get(nickname)
|
lists_enabled,
|
||||||
bold_reading = False
|
dogwhistles,
|
||||||
if bold_reading_nicknames.get(nickname):
|
access_keys,
|
||||||
bold_reading = True
|
min_images_for_accounts,
|
||||||
history_str = \
|
buy_sites,
|
||||||
html_history_search(translate,
|
auto_cw_cache,
|
||||||
base_dir,
|
calling_domain):
|
||||||
http_prefix,
|
|
||||||
nickname,
|
|
||||||
domain,
|
|
||||||
search_str,
|
|
||||||
max_posts_in_feed,
|
|
||||||
page_number,
|
|
||||||
project_version,
|
|
||||||
recent_posts_cache,
|
|
||||||
max_recent_posts,
|
|
||||||
curr_session,
|
|
||||||
cached_webfingers,
|
|
||||||
person_cache,
|
|
||||||
port,
|
|
||||||
yt_replace_domain,
|
|
||||||
twitter_replacement_domain,
|
|
||||||
show_published_date_only,
|
|
||||||
peertube_instances,
|
|
||||||
allow_local_network_access,
|
|
||||||
theme_name, 'outbox',
|
|
||||||
system_language,
|
|
||||||
max_like_count,
|
|
||||||
signing_priv_key_pem,
|
|
||||||
cw_lists,
|
|
||||||
lists_enabled,
|
|
||||||
timezone, bold_reading,
|
|
||||||
dogwhistles,
|
|
||||||
access_keys,
|
|
||||||
min_images_for_accounts,
|
|
||||||
buy_sites,
|
|
||||||
auto_cw_cache)
|
|
||||||
if history_str:
|
|
||||||
msg = history_str.encode('utf-8')
|
|
||||||
msglen = len(msg)
|
|
||||||
login_headers(self, 'text/html',
|
|
||||||
msglen, calling_domain)
|
|
||||||
write2(self, msg)
|
|
||||||
self.server.postreq_busy = False
|
|
||||||
return
|
return
|
||||||
elif (search_str.startswith('-') or
|
elif (search_str.startswith('-') or
|
||||||
string_ends_with(search_str, bookmark_endings)):
|
string_ends_with(search_str, bookmark_endings)):
|
||||||
|
|
Loading…
Reference in New Issue