Merge branch 'infra-provisioning' of ssh://github.com/n4veenkumar/epicyon into infra-provisioning

main
Naveen Kumar 2023-02-17 15:10:50 +05:30
commit 9fffbae0f0
7 changed files with 4311 additions and 2707 deletions

View File

@ -2671,7 +2671,8 @@ class PubServer(BaseHTTPRequestHandler):
search_handle, search_handle,
self.server.debug, self.server.debug,
self.server.system_language, self.server.system_language,
self.server.signing_priv_key_pem) self.server.signing_priv_key_pem,
None)
else: else:
msg = \ msg = \
html_moderation_info(self.server.translate, html_moderation_info(self.server.translate,
@ -3778,7 +3779,8 @@ class PubServer(BaseHTTPRequestHandler):
options_actor, options_actor,
self.server.debug, self.server.debug,
self.server.system_language, self.server.system_language,
signing_priv_key_pem) signing_priv_key_pem,
None)
if msg: if msg:
msg = msg.encode('utf-8') msg = msg.encode('utf-8')
msglen = len(msg) msglen = len(msg)
@ -4080,6 +4082,36 @@ class PubServer(BaseHTTPRequestHandler):
self.server.postreq_busy = False self.server.postreq_busy = False
return return
if '&submitInfo=' in follow_confirm_params:
following_actor = \
urllib.parse.unquote_plus(follow_confirm_params)
following_actor = following_actor.split('actor=')[1]
if '&' in following_actor:
following_actor = following_actor.split('&')[0]
if is_moderator(base_dir, follower_nickname):
msg = \
html_account_info(self.server.translate,
base_dir, http_prefix,
follower_nickname,
self.server.domain,
self.server.port,
following_actor,
self.server.debug,
self.server.system_language,
self.server.signing_priv_key_pem,
users_path)
if msg:
msg = msg.encode('utf-8')
msglen = len(msg)
self._login_headers('text/html',
msglen, calling_domain)
self._write(msg)
self.server.postreq_busy = False
return
self._redirect_headers(following_actor, cookie, calling_domain)
self.server.postreq_busy = False
return
if '&submitYes=' in follow_confirm_params: if '&submitYes=' in follow_confirm_params:
following_actor = \ following_actor = \
urllib.parse.unquote_plus(follow_confirm_params) urllib.parse.unquote_plus(follow_confirm_params)
@ -16392,7 +16424,7 @@ class PubServer(BaseHTTPRequestHandler):
if not can_reply_to(base_dir, nickname, domain, if not can_reply_to(base_dir, nickname, domain,
in_reply_to_url, reply_interval_hours): in_reply_to_url, reply_interval_hours):
print('Reply outside of time window ' + in_reply_to_url + print('Reply outside of time window ' + in_reply_to_url +
str(reply_interval_hours) + ' hours') ' ' + str(reply_interval_hours) + ' hours')
self._403() self._403()
return True return True
if self.server.debug: if self.server.debug:
@ -20122,7 +20154,8 @@ class PubServer(BaseHTTPRequestHandler):
search_handle, search_handle,
self.server.debug, self.server.debug,
self.server.system_language, self.server.system_language,
self.server.signing_priv_key_pem) self.server.signing_priv_key_pem,
None)
if msg: if msg:
msg = msg.encode('utf-8') msg = msg.encode('utf-8')
msglen = len(msg) msglen = len(msg)
@ -20159,7 +20192,8 @@ class PubServer(BaseHTTPRequestHandler):
search_handle, search_handle,
self.server.debug, self.server.debug,
self.server.system_language, self.server.system_language,
self.server.signing_priv_key_pem) self.server.signing_priv_key_pem,
None)
if msg: if msg:
msg = msg.encode('utf-8') msg = msg.encode('utf-8')
msglen = len(msg) msglen = len(msg)

File diff suppressed because one or more lines are too long

6408
sbom.json

File diff suppressed because it is too large Load Diff

View File

@ -1754,7 +1754,8 @@ def can_reply_to(base_dir: str, nickname: str, domain: str,
if not post_json_object: if not post_json_object:
post_filename = locate_post(base_dir, nickname, domain, post_url) post_filename = locate_post(base_dir, nickname, domain, post_url)
if not post_filename: if not post_filename:
return False # the post is not stored locally
return True
post_json_object = load_json(post_filename) post_json_object = load_json(post_filename)
if not post_json_object: if not post_json_object:
return False return False

View File

@ -97,7 +97,8 @@ def html_account_info(translate: {},
base_dir: str, http_prefix: str, base_dir: str, http_prefix: str,
nickname: str, domain: str, port: int, nickname: str, domain: str, port: int,
search_handle: str, debug: bool, search_handle: str, debug: bool,
system_language: str, signing_priv_key_pem: str) -> str: system_language: str, signing_priv_key_pem: str,
back_url: str) -> str:
"""Shows which domains a search handle interacts with. """Shows which domains a search handle interacts with.
This screen is shown if a moderator enters a handle and selects info This screen is shown if a moderator enters a handle and selects info
on the moderation screen on the moderation screen
@ -125,8 +126,10 @@ def html_account_info(translate: {},
search_handle = search_nickname + '@' + search_domain search_handle = search_nickname + '@' + search_domain
search_actor = \ search_actor = \
local_actor_url(http_prefix, search_nickname, search_domain) local_actor_url(http_prefix, search_nickname, search_domain)
if not back_url:
back_url = '/users/' + nickname + '/moderation'
info_form += \ info_form += \
'<center><h1><a href="/users/' + nickname + '/moderation">' + \ '<center><h1><a href="' + back_url + '">' + \
translate['Account Information'] + ':</a> <a href="' + search_actor + \ translate['Account Information'] + ':</a> <a href="' + search_actor + \
'">' + search_handle + '</a></h1><br>\n' '">' + search_handle + '</a></h1><br>\n'

View File

@ -135,8 +135,19 @@ def _valid_profile_preview_post(post_json_object: {},
post_json_object = new_post_json_object post_json_object = new_post_json_object
if not post_json_object.get('actor'): if not post_json_object.get('actor'):
return False, None return False, None
if not is_announced_feed_item: # convert actor back to id
if has_object_dict(post_json_object): if isinstance(post_json_object['actor'], dict):
if post_json_object['actor'].get('id'):
post_json_object['actor'] = post_json_object['actor']['id']
if has_object_dict(post_json_object):
# convert attributedTo actor back to id
if post_json_object['object'].get('attributedTo'):
if isinstance(post_json_object['object']['attributedTo'],
dict):
if post_json_object['object']['attributedTo'].get('id'):
post_json_object['object']['attributedTo'] = \
post_json_object['object']['attributedTo']['id']
if not is_announced_feed_item:
if post_json_object['actor'] != person_url and \ if post_json_object['actor'] != person_url and \
post_json_object['object']['type'] != 'Page': post_json_object['object']['type'] != 'Page':
return False, None return False, None
@ -352,6 +363,12 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
' <input type="hidden" name="actor" value="' + \ ' <input type="hidden" name="actor" value="' + \
person_url + '">\n' person_url + '">\n'
if not is_following_actor(base_dir, nickname, domain, person_url): if not is_following_actor(base_dir, nickname, domain, person_url):
if is_moderator(base_dir, nickname):
profile_str += \
' <button type="submit" class="button" ' + \
'name="submitInfo" ' + \
'accesskey="' + access_keys['infoButton'] + '">' + \
translate['Info'] + '</button>\n'
profile_str += \ profile_str += \
' <button type="submit" class="button" ' + \ ' <button type="submit" class="button" ' + \
'name="submitYes" ' + \ 'name="submitYes" ' + \
@ -401,6 +418,9 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
show_item, post_json_object = \ show_item, post_json_object = \
_valid_profile_preview_post(item, person_url) _valid_profile_preview_post(item, person_url)
if not show_item: if not show_item:
if debug:
print('DEBUG: item not valid in profile posts: ' +
str(item))
continue continue
profile_str += \ profile_str += \

View File

@ -518,7 +518,7 @@ def html_search(translate: {}, base_dir: str, path: str, domain: str,
print('EX: html_search unable to save cached hashtag swarm ' + print('EX: html_search unable to save cached hashtag swarm ' +
cached_hashtag_swarm_filename) cached_hashtag_swarm_filename)
follow_str += ' <p class="hashtagswarm">' + swarm_str + '</p>\n' follow_str += ' <p class="hashtagswarm">' + swarm_str + '</p><br>\n'
follow_str += ' </center>\n' follow_str += ' </center>\n'
follow_str += ' </div>\n' follow_str += ' </div>\n'
follow_str += '</div>\n' follow_str += '</div>\n'