mirror of https://gitlab.com/bashrc2/epicyon
Less indentation
parent
53eeb041fd
commit
803fed70b0
|
@ -118,495 +118,503 @@ def receive_search_query(self, calling_domain: str, cookie: str,
|
|||
default_timeline, cookie, calling_domain, 303)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
if 'searchtext=' in search_params:
|
||||
search_str = search_params.split('searchtext=')[1]
|
||||
if '&' in search_str:
|
||||
search_str = search_str.split('&')[0]
|
||||
search_str = \
|
||||
urllib.parse.unquote_plus(search_str.strip())
|
||||
search_str = search_str.strip()
|
||||
print('search_str: ' + search_str)
|
||||
if search_for_emoji:
|
||||
search_str = ':' + search_str + ':'
|
||||
if 'searchtext=' not in search_params:
|
||||
actor_str = \
|
||||
get_instance_url(calling_domain, http_prefix, domain_full,
|
||||
onion_domain, i2p_domain) + users_path
|
||||
redirect_headers(self, actor_str + '/' + default_timeline,
|
||||
cookie, calling_domain, 303)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
|
||||
my_posts_endings = (
|
||||
' history', ' in sent', ' in outbox', ' in outgoing',
|
||||
' in sent items', ' in sent posts', ' in outgoing posts',
|
||||
' in my history', ' in my outbox', ' in my posts')
|
||||
bookmark_endings = (
|
||||
' in my saved items', ' in my saved posts',
|
||||
' in my bookmarks', ' in my saved', ' in my saves',
|
||||
' in saved posts', ' in saved items', ' in bookmarks',
|
||||
' in saved', ' in saves', ' bookmark')
|
||||
search_str = search_params.split('searchtext=')[1]
|
||||
if '&' in search_str:
|
||||
search_str = search_str.split('&')[0]
|
||||
search_str = \
|
||||
urllib.parse.unquote_plus(search_str.strip())
|
||||
search_str = search_str.strip()
|
||||
print('search_str: ' + search_str)
|
||||
if search_for_emoji:
|
||||
search_str = ':' + search_str + ':'
|
||||
|
||||
if search_str.startswith('#'):
|
||||
nickname = get_nickname_from_actor(actor_str)
|
||||
if not nickname:
|
||||
self.send_response(400)
|
||||
self.end_headers()
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
my_posts_endings = (
|
||||
' history', ' in sent', ' in outbox', ' in outgoing',
|
||||
' in sent items', ' in sent posts', ' in outgoing posts',
|
||||
' in my history', ' in my outbox', ' in my posts')
|
||||
bookmark_endings = (
|
||||
' in my saved items', ' in my saved posts',
|
||||
' in my bookmarks', ' in my saved', ' in my saves',
|
||||
' in saved posts', ' in saved items', ' in bookmarks',
|
||||
' in saved', ' in saves', ' bookmark')
|
||||
|
||||
# hashtag search
|
||||
timezone = None
|
||||
if account_timezone.get(nickname):
|
||||
timezone = account_timezone.get(nickname)
|
||||
bold_reading = False
|
||||
if bold_reading_nicknames.get(nickname):
|
||||
bold_reading = True
|
||||
hashtag_str = \
|
||||
html_hashtag_search(nickname, domain, port,
|
||||
recent_posts_cache,
|
||||
max_recent_posts,
|
||||
translate,
|
||||
base_dir,
|
||||
search_str[1:], 1,
|
||||
max_posts_in_hashtag_feed,
|
||||
curr_session,
|
||||
cached_webfingers,
|
||||
person_cache,
|
||||
http_prefix,
|
||||
project_version,
|
||||
yt_replace_domain,
|
||||
twitter_replacement_domain,
|
||||
show_published_date_only,
|
||||
peertube_instances,
|
||||
allow_local_network_access,
|
||||
theme_name,
|
||||
system_language,
|
||||
max_like_count,
|
||||
signing_priv_key_pem,
|
||||
cw_lists,
|
||||
lists_enabled,
|
||||
timezone, bold_reading,
|
||||
dogwhistles,
|
||||
map_format,
|
||||
access_keys,
|
||||
'search',
|
||||
min_images_for_accounts,
|
||||
buy_sites,
|
||||
auto_cw_cache)
|
||||
if hashtag_str:
|
||||
msg = hashtag_str.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
login_headers(self, 'text/html',
|
||||
msglen, calling_domain)
|
||||
write2(self, msg)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
elif (search_str.startswith('*') or
|
||||
search_str.endswith(' skill')):
|
||||
possible_endings = (
|
||||
' skill'
|
||||
)
|
||||
for poss_ending in possible_endings:
|
||||
if search_str.endswith(poss_ending):
|
||||
search_str = search_str.replace(poss_ending, '')
|
||||
break
|
||||
# skill search
|
||||
search_str = search_str.replace('*', '').strip()
|
||||
nickname = get_nickname_from_actor(actor_str)
|
||||
skill_str = \
|
||||
html_skills_search(actor_str, translate,
|
||||
base_dir, search_str,
|
||||
instance_only_skills_search,
|
||||
64, nickname, domain,
|
||||
theme_name, access_keys)
|
||||
if skill_str:
|
||||
msg = skill_str.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
login_headers(self, 'text/html',
|
||||
msglen, calling_domain)
|
||||
write2(self, msg)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
elif (search_str.startswith("'") or
|
||||
string_ends_with(search_str, my_posts_endings)):
|
||||
# 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
|
||||
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
|
||||
elif (search_str.startswith('-') or
|
||||
string_ends_with(search_str, bookmark_endings)):
|
||||
# bookmark search
|
||||
possible_endings = (
|
||||
' in my bookmarks'
|
||||
' in my saved posts'
|
||||
' in my saved items'
|
||||
' in my saved'
|
||||
' in my saves'
|
||||
' in saved posts'
|
||||
' in saved items'
|
||||
' in saved'
|
||||
' in saves'
|
||||
' in bookmarks'
|
||||
' bookmark'
|
||||
)
|
||||
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
|
||||
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
|
||||
bookmarks_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, 'bookmarks',
|
||||
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 bookmarks_str:
|
||||
msg = bookmarks_str.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
login_headers(self, 'text/html',
|
||||
msglen, calling_domain)
|
||||
write2(self, msg)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
elif ('@' in search_str or
|
||||
('://' in search_str and
|
||||
has_users_path(search_str))):
|
||||
remote_only = False
|
||||
if search_str.endswith(';remote'):
|
||||
search_str = search_str.replace(';remote', '')
|
||||
remote_only = True
|
||||
if string_ends_with(search_str, (':', ';', '.')):
|
||||
actor_str = \
|
||||
get_instance_url(calling_domain, http_prefix,
|
||||
domain_full, onion_domain,
|
||||
i2p_domain) + \
|
||||
users_path
|
||||
redirect_headers(self, actor_str + '/search',
|
||||
cookie, calling_domain, 303)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
# profile search
|
||||
nickname = get_nickname_from_actor(actor_str)
|
||||
if not nickname:
|
||||
self.send_response(400)
|
||||
self.end_headers()
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
profile_path_str = path.replace('/searchhandle', '')
|
||||
if search_str.startswith('#'):
|
||||
nickname = get_nickname_from_actor(actor_str)
|
||||
if not nickname:
|
||||
self.send_response(400)
|
||||
self.end_headers()
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
|
||||
# are we already following or followed by the searched
|
||||
# for handle?
|
||||
search_nickname = get_nickname_from_actor(search_str)
|
||||
search_domain, search_port = \
|
||||
get_domain_from_actor(search_str)
|
||||
search_follower = \
|
||||
is_follower_of_person(base_dir, nickname, domain,
|
||||
search_nickname, search_domain)
|
||||
search_following = \
|
||||
is_following_actor(base_dir, nickname, domain, search_str)
|
||||
if not remote_only and (search_follower or search_following):
|
||||
# get the actor
|
||||
if not has_users_path(search_str):
|
||||
if not search_nickname or not search_domain:
|
||||
self.send_response(400)
|
||||
self.end_headers()
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
search_domain_full = \
|
||||
get_full_domain(search_domain, search_port)
|
||||
actor = \
|
||||
local_actor_url(http_prefix, search_nickname,
|
||||
search_domain_full)
|
||||
else:
|
||||
actor = search_str
|
||||
|
||||
# establish the session
|
||||
curr_proxy_type = proxy_type
|
||||
if '.onion/' in actor:
|
||||
curr_proxy_type = 'tor'
|
||||
curr_session = self.server.session_onion
|
||||
elif '.i2p/' in actor:
|
||||
curr_proxy_type = 'i2p'
|
||||
curr_session = self.server.session_i2p
|
||||
|
||||
curr_session = \
|
||||
establish_session("handle search", curr_session,
|
||||
curr_proxy_type, self.server)
|
||||
if not curr_session:
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
|
||||
# get the avatar url for the actor
|
||||
avatar_url = \
|
||||
get_avatar_image_url(curr_session,
|
||||
base_dir, http_prefix,
|
||||
actor, person_cache,
|
||||
None, True,
|
||||
signing_priv_key_pem)
|
||||
profile_path_str += \
|
||||
'?options=' + actor + ';1;' + avatar_url
|
||||
|
||||
show_person_options(self, calling_domain, profile_path_str,
|
||||
base_dir, domain, domain_full,
|
||||
getreq_start_time,
|
||||
cookie, debug, authorized,
|
||||
curr_session)
|
||||
return
|
||||
else:
|
||||
if key_shortcuts.get(nickname):
|
||||
access_keys = key_shortcuts[nickname]
|
||||
|
||||
timezone = None
|
||||
if account_timezone.get(nickname):
|
||||
timezone = account_timezone.get(nickname)
|
||||
|
||||
profile_handle = remove_eol(search_str).strip()
|
||||
|
||||
# establish the session
|
||||
curr_proxy_type = proxy_type
|
||||
if '.onion/' in profile_handle or \
|
||||
profile_handle.endswith('.onion'):
|
||||
curr_proxy_type = 'tor'
|
||||
curr_session = self.server.session_onion
|
||||
elif ('.i2p/' in profile_handle or
|
||||
profile_handle.endswith('.i2p')):
|
||||
curr_proxy_type = 'i2p'
|
||||
curr_session = self.server.session_i2p
|
||||
|
||||
curr_session = \
|
||||
establish_session("handle search", curr_session,
|
||||
curr_proxy_type, self.server)
|
||||
if not curr_session:
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
|
||||
bold_reading = False
|
||||
if bold_reading_nicknames.get(nickname):
|
||||
bold_reading = True
|
||||
|
||||
profile_str = \
|
||||
html_profile_after_search(authorized,
|
||||
recent_posts_cache,
|
||||
max_recent_posts,
|
||||
translate,
|
||||
base_dir,
|
||||
profile_path_str,
|
||||
http_prefix,
|
||||
nickname,
|
||||
domain,
|
||||
port,
|
||||
profile_handle,
|
||||
curr_session,
|
||||
cached_webfingers,
|
||||
person_cache,
|
||||
debug,
|
||||
project_version,
|
||||
yt_replace_domain,
|
||||
twitter_replacement_domain,
|
||||
show_published_date_only,
|
||||
default_timeline,
|
||||
peertube_instances,
|
||||
allow_local_network_access,
|
||||
theme_name,
|
||||
access_keys,
|
||||
system_language,
|
||||
max_like_count,
|
||||
signing_priv_key_pem,
|
||||
cw_lists,
|
||||
lists_enabled,
|
||||
timezone,
|
||||
onion_domain,
|
||||
i2p_domain,
|
||||
bold_reading,
|
||||
dogwhistles,
|
||||
min_images_for_accounts,
|
||||
buy_sites,
|
||||
max_shares_on_profile,
|
||||
no_of_books,
|
||||
auto_cw_cache)
|
||||
if profile_str:
|
||||
msg = profile_str.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
login_headers(self, 'text/html',
|
||||
msglen, calling_domain)
|
||||
write2(self, msg)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
# hashtag search
|
||||
timezone = None
|
||||
if account_timezone.get(nickname):
|
||||
timezone = account_timezone.get(nickname)
|
||||
bold_reading = False
|
||||
if bold_reading_nicknames.get(nickname):
|
||||
bold_reading = True
|
||||
hashtag_str = \
|
||||
html_hashtag_search(nickname, domain, port,
|
||||
recent_posts_cache,
|
||||
max_recent_posts,
|
||||
translate,
|
||||
base_dir,
|
||||
search_str[1:], 1,
|
||||
max_posts_in_hashtag_feed,
|
||||
curr_session,
|
||||
cached_webfingers,
|
||||
person_cache,
|
||||
http_prefix,
|
||||
project_version,
|
||||
yt_replace_domain,
|
||||
twitter_replacement_domain,
|
||||
show_published_date_only,
|
||||
peertube_instances,
|
||||
allow_local_network_access,
|
||||
theme_name,
|
||||
system_language,
|
||||
max_like_count,
|
||||
signing_priv_key_pem,
|
||||
cw_lists,
|
||||
lists_enabled,
|
||||
timezone, bold_reading,
|
||||
dogwhistles,
|
||||
map_format,
|
||||
access_keys,
|
||||
'search',
|
||||
min_images_for_accounts,
|
||||
buy_sites,
|
||||
auto_cw_cache)
|
||||
if hashtag_str:
|
||||
msg = hashtag_str.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
login_headers(self, 'text/html',
|
||||
msglen, calling_domain)
|
||||
write2(self, msg)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
elif (search_str.startswith('*') or
|
||||
search_str.endswith(' skill')):
|
||||
possible_endings = (
|
||||
' skill'
|
||||
)
|
||||
for poss_ending in possible_endings:
|
||||
if search_str.endswith(poss_ending):
|
||||
search_str = search_str.replace(poss_ending, '')
|
||||
break
|
||||
# skill search
|
||||
search_str = search_str.replace('*', '').strip()
|
||||
nickname = get_nickname_from_actor(actor_str)
|
||||
skill_str = \
|
||||
html_skills_search(actor_str, translate,
|
||||
base_dir, search_str,
|
||||
instance_only_skills_search,
|
||||
64, nickname, domain,
|
||||
theme_name, access_keys)
|
||||
if skill_str:
|
||||
msg = skill_str.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
login_headers(self, 'text/html',
|
||||
msglen, calling_domain)
|
||||
write2(self, msg)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
elif (search_str.startswith("'") or
|
||||
string_ends_with(search_str, my_posts_endings)):
|
||||
# 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
|
||||
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
|
||||
elif (search_str.startswith('-') or
|
||||
string_ends_with(search_str, bookmark_endings)):
|
||||
# bookmark search
|
||||
possible_endings = (
|
||||
' in my bookmarks'
|
||||
' in my saved posts'
|
||||
' in my saved items'
|
||||
' in my saved'
|
||||
' in my saves'
|
||||
' in saved posts'
|
||||
' in saved items'
|
||||
' in saved'
|
||||
' in saves'
|
||||
' in bookmarks'
|
||||
' bookmark'
|
||||
)
|
||||
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
|
||||
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
|
||||
bookmarks_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, 'bookmarks',
|
||||
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 bookmarks_str:
|
||||
msg = bookmarks_str.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
login_headers(self, 'text/html',
|
||||
msglen, calling_domain)
|
||||
write2(self, msg)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
elif ('@' in search_str or
|
||||
('://' in search_str and
|
||||
has_users_path(search_str))):
|
||||
remote_only = False
|
||||
if search_str.endswith(';remote'):
|
||||
search_str = search_str.replace(';remote', '')
|
||||
remote_only = True
|
||||
if string_ends_with(search_str, (':', ';', '.')):
|
||||
actor_str = \
|
||||
get_instance_url(calling_domain,
|
||||
http_prefix, domain_full,
|
||||
onion_domain, i2p_domain) + \
|
||||
get_instance_url(calling_domain, http_prefix,
|
||||
domain_full, onion_domain,
|
||||
i2p_domain) + \
|
||||
users_path
|
||||
redirect_headers(self, actor_str + '/search',
|
||||
cookie, calling_domain, 303)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
elif (search_str.startswith(':') or
|
||||
search_str.endswith(' emoji')):
|
||||
# eg. "cat emoji"
|
||||
if search_str.endswith(' emoji'):
|
||||
search_str = \
|
||||
search_str.replace(' emoji', '')
|
||||
# emoji search
|
||||
nickname = get_nickname_from_actor(actor_str)
|
||||
emoji_str = \
|
||||
html_search_emoji(translate,
|
||||
base_dir, search_str,
|
||||
nickname, domain,
|
||||
theme_name, access_keys)
|
||||
if emoji_str:
|
||||
msg = emoji_str.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
login_headers(self, 'text/html', msglen, calling_domain)
|
||||
write2(self, msg)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
elif search_str.startswith('.'):
|
||||
# wanted items search
|
||||
nickname = get_nickname_from_actor(actor_str)
|
||||
wanted_items_str = \
|
||||
html_search_shared_items(translate,
|
||||
base_dir,
|
||||
search_str[1:], page_number,
|
||||
max_posts_in_feed,
|
||||
http_prefix,
|
||||
domain_full,
|
||||
actor_str, calling_domain,
|
||||
shared_items_federated_domains,
|
||||
'wanted', nickname, domain,
|
||||
theme_name,
|
||||
access_keys)
|
||||
if wanted_items_str:
|
||||
msg = wanted_items_str.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
login_headers(self, 'text/html', msglen, calling_domain)
|
||||
write2(self, msg)
|
||||
# profile search
|
||||
nickname = get_nickname_from_actor(actor_str)
|
||||
if not nickname:
|
||||
self.send_response(400)
|
||||
self.end_headers()
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
profile_path_str = path.replace('/searchhandle', '')
|
||||
|
||||
# are we already following or followed by the searched
|
||||
# for handle?
|
||||
search_nickname = get_nickname_from_actor(search_str)
|
||||
search_domain, search_port = \
|
||||
get_domain_from_actor(search_str)
|
||||
search_follower = \
|
||||
is_follower_of_person(base_dir, nickname, domain,
|
||||
search_nickname, search_domain)
|
||||
search_following = \
|
||||
is_following_actor(base_dir, nickname, domain, search_str)
|
||||
if not remote_only and (search_follower or search_following):
|
||||
# get the actor
|
||||
if not has_users_path(search_str):
|
||||
if not search_nickname or not search_domain:
|
||||
self.send_response(400)
|
||||
self.end_headers()
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
search_domain_full = \
|
||||
get_full_domain(search_domain, search_port)
|
||||
actor = \
|
||||
local_actor_url(http_prefix, search_nickname,
|
||||
search_domain_full)
|
||||
else:
|
||||
actor = search_str
|
||||
|
||||
# establish the session
|
||||
curr_proxy_type = proxy_type
|
||||
if '.onion/' in actor:
|
||||
curr_proxy_type = 'tor'
|
||||
curr_session = self.server.session_onion
|
||||
elif '.i2p/' in actor:
|
||||
curr_proxy_type = 'i2p'
|
||||
curr_session = self.server.session_i2p
|
||||
|
||||
curr_session = \
|
||||
establish_session("handle search", curr_session,
|
||||
curr_proxy_type, self.server)
|
||||
if not curr_session:
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
|
||||
# get the avatar url for the actor
|
||||
avatar_url = \
|
||||
get_avatar_image_url(curr_session,
|
||||
base_dir, http_prefix,
|
||||
actor, person_cache,
|
||||
None, True,
|
||||
signing_priv_key_pem)
|
||||
profile_path_str += \
|
||||
'?options=' + actor + ';1;' + avatar_url
|
||||
|
||||
show_person_options(self, calling_domain, profile_path_str,
|
||||
base_dir, domain, domain_full,
|
||||
getreq_start_time,
|
||||
cookie, debug, authorized,
|
||||
curr_session)
|
||||
return
|
||||
else:
|
||||
# shared items search
|
||||
nickname = get_nickname_from_actor(actor_str)
|
||||
shared_items_str = \
|
||||
html_search_shared_items(translate, base_dir,
|
||||
search_str, page_number,
|
||||
max_posts_in_feed,
|
||||
http_prefix, domain_full,
|
||||
actor_str, calling_domain,
|
||||
shared_items_federated_domains,
|
||||
'shares', nickname, domain,
|
||||
theme_name, access_keys)
|
||||
if shared_items_str:
|
||||
msg = shared_items_str.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
login_headers(self, 'text/html',
|
||||
msglen, calling_domain)
|
||||
write2(self, msg)
|
||||
if key_shortcuts.get(nickname):
|
||||
access_keys = key_shortcuts[nickname]
|
||||
|
||||
timezone = None
|
||||
if account_timezone.get(nickname):
|
||||
timezone = account_timezone.get(nickname)
|
||||
|
||||
profile_handle = remove_eol(search_str).strip()
|
||||
|
||||
# establish the session
|
||||
curr_proxy_type = proxy_type
|
||||
if '.onion/' in profile_handle or \
|
||||
profile_handle.endswith('.onion'):
|
||||
curr_proxy_type = 'tor'
|
||||
curr_session = self.server.session_onion
|
||||
elif ('.i2p/' in profile_handle or
|
||||
profile_handle.endswith('.i2p')):
|
||||
curr_proxy_type = 'i2p'
|
||||
curr_session = self.server.session_i2p
|
||||
|
||||
curr_session = \
|
||||
establish_session("handle search", curr_session,
|
||||
curr_proxy_type, self.server)
|
||||
if not curr_session:
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
|
||||
bold_reading = False
|
||||
if bold_reading_nicknames.get(nickname):
|
||||
bold_reading = True
|
||||
|
||||
profile_str = \
|
||||
html_profile_after_search(authorized,
|
||||
recent_posts_cache,
|
||||
max_recent_posts,
|
||||
translate,
|
||||
base_dir,
|
||||
profile_path_str,
|
||||
http_prefix,
|
||||
nickname,
|
||||
domain,
|
||||
port,
|
||||
profile_handle,
|
||||
curr_session,
|
||||
cached_webfingers,
|
||||
person_cache,
|
||||
debug,
|
||||
project_version,
|
||||
yt_replace_domain,
|
||||
twitter_replacement_domain,
|
||||
show_published_date_only,
|
||||
default_timeline,
|
||||
peertube_instances,
|
||||
allow_local_network_access,
|
||||
theme_name,
|
||||
access_keys,
|
||||
system_language,
|
||||
max_like_count,
|
||||
signing_priv_key_pem,
|
||||
cw_lists,
|
||||
lists_enabled,
|
||||
timezone,
|
||||
onion_domain,
|
||||
i2p_domain,
|
||||
bold_reading,
|
||||
dogwhistles,
|
||||
min_images_for_accounts,
|
||||
buy_sites,
|
||||
max_shares_on_profile,
|
||||
no_of_books,
|
||||
auto_cw_cache)
|
||||
if profile_str:
|
||||
msg = profile_str.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
login_headers(self, 'text/html',
|
||||
msglen, calling_domain)
|
||||
write2(self, msg)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
actor_str = \
|
||||
get_instance_url(calling_domain,
|
||||
http_prefix, domain_full,
|
||||
onion_domain, i2p_domain) + \
|
||||
users_path
|
||||
redirect_headers(self, actor_str + '/search',
|
||||
cookie, calling_domain, 303)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
elif (search_str.startswith(':') or
|
||||
search_str.endswith(' emoji')):
|
||||
# eg. "cat emoji"
|
||||
if search_str.endswith(' emoji'):
|
||||
search_str = \
|
||||
search_str.replace(' emoji', '')
|
||||
# emoji search
|
||||
nickname = get_nickname_from_actor(actor_str)
|
||||
emoji_str = \
|
||||
html_search_emoji(translate,
|
||||
base_dir, search_str,
|
||||
nickname, domain,
|
||||
theme_name, access_keys)
|
||||
if emoji_str:
|
||||
msg = emoji_str.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
login_headers(self, 'text/html', msglen, calling_domain)
|
||||
write2(self, msg)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
elif search_str.startswith('.'):
|
||||
# wanted items search
|
||||
nickname = get_nickname_from_actor(actor_str)
|
||||
wanted_items_str = \
|
||||
html_search_shared_items(translate,
|
||||
base_dir,
|
||||
search_str[1:], page_number,
|
||||
max_posts_in_feed,
|
||||
http_prefix,
|
||||
domain_full,
|
||||
actor_str, calling_domain,
|
||||
shared_items_federated_domains,
|
||||
'wanted', nickname, domain,
|
||||
theme_name,
|
||||
access_keys)
|
||||
if wanted_items_str:
|
||||
msg = wanted_items_str.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
login_headers(self, 'text/html', msglen, calling_domain)
|
||||
write2(self, msg)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
else:
|
||||
# shared items search
|
||||
nickname = get_nickname_from_actor(actor_str)
|
||||
shared_items_str = \
|
||||
html_search_shared_items(translate, base_dir,
|
||||
search_str, page_number,
|
||||
max_posts_in_feed,
|
||||
http_prefix, domain_full,
|
||||
actor_str, calling_domain,
|
||||
shared_items_federated_domains,
|
||||
'shares', nickname, domain,
|
||||
theme_name, access_keys)
|
||||
if shared_items_str:
|
||||
msg = shared_items_str.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
login_headers(self, 'text/html',
|
||||
msglen, calling_domain)
|
||||
write2(self, msg)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
|
||||
actor_str = \
|
||||
get_instance_url(calling_domain, http_prefix,
|
||||
domain_full, onion_domain, i2p_domain) + \
|
||||
users_path
|
||||
domain_full, onion_domain, i2p_domain) + users_path
|
||||
redirect_headers(self, actor_str + '/' + default_timeline,
|
||||
cookie, calling_domain, 303)
|
||||
self.server.postreq_busy = False
|
||||
|
|
Loading…
Reference in New Issue