mirror of https://gitlab.com/bashrc2/epicyon
Handle none return valued from nickname
parent
aab90e75da
commit
f55f7a258f
15
announce.py
15
announce.py
|
@ -187,13 +187,14 @@ def create_announce(session, base_dir: str, federation_list: [],
|
|||
group_account = False
|
||||
if has_users_path(object_url):
|
||||
announce_nickname = get_nickname_from_actor(object_url)
|
||||
announce_domain, announce_port = get_domain_from_actor(object_url)
|
||||
if '/' + str(announce_nickname) + '/' in object_url:
|
||||
announce_actor = \
|
||||
object_url.split('/' + announce_nickname + '/')[0] + \
|
||||
'/' + announce_nickname
|
||||
if has_group_type(base_dir, announce_actor, person_cache):
|
||||
group_account = True
|
||||
if announce_nickname:
|
||||
announce_domain, announce_port = get_domain_from_actor(object_url)
|
||||
if '/' + str(announce_nickname) + '/' in object_url:
|
||||
announce_actor = \
|
||||
object_url.split('/' + announce_nickname + '/')[0] + \
|
||||
'/' + announce_nickname
|
||||
if has_group_type(base_dir, announce_actor, person_cache):
|
||||
group_account = True
|
||||
|
||||
if announce_nickname and announce_domain:
|
||||
send_signed_json(new_announce, session, base_dir,
|
||||
|
|
|
@ -68,6 +68,8 @@ def outbox_availability(base_dir: str, nickname: str, message_json: {},
|
|||
return False
|
||||
|
||||
actor_nickname = get_nickname_from_actor(message_json['actor'])
|
||||
if not actor_nickname:
|
||||
return False
|
||||
if actor_nickname != nickname:
|
||||
return False
|
||||
domain, _ = get_domain_from_actor(message_json['actor'])
|
||||
|
|
|
@ -46,6 +46,8 @@ def undo_bookmarks_collection_entry(recent_posts_cache: {},
|
|||
# remove any cached version of this post so that the
|
||||
# bookmark icon is changed
|
||||
nickname = get_nickname_from_actor(actor)
|
||||
if not nickname:
|
||||
return
|
||||
cached_post_filename = \
|
||||
get_cached_post_filename(base_dir, nickname,
|
||||
domain, post_json_object)
|
||||
|
@ -166,6 +168,8 @@ def update_bookmarks_collection(recent_posts_cache: {},
|
|||
# remove any cached version of this post so that the
|
||||
# bookmark icon is changed
|
||||
nickname = get_nickname_from_actor(actor)
|
||||
if not nickname:
|
||||
return
|
||||
cached_post_filename = \
|
||||
get_cached_post_filename(base_dir, nickname,
|
||||
domain, post_json_object)
|
||||
|
|
215
daemon.py
215
daemon.py
|
@ -2195,18 +2195,24 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if '/@' in search_handle:
|
||||
search_nickname = \
|
||||
get_nickname_from_actor(search_handle)
|
||||
search_domain, _ = \
|
||||
get_domain_from_actor(search_handle)
|
||||
search_handle = \
|
||||
search_nickname + '@' + search_domain
|
||||
if '@' not in search_handle:
|
||||
if search_handle.startswith('http'):
|
||||
search_nickname = \
|
||||
get_nickname_from_actor(search_handle)
|
||||
if search_nickname:
|
||||
search_domain, _ = \
|
||||
get_domain_from_actor(search_handle)
|
||||
search_handle = \
|
||||
search_nickname + '@' + search_domain
|
||||
else:
|
||||
search_handle = None
|
||||
if '@' not in search_handle:
|
||||
if search_handle.startswith('http'):
|
||||
search_nickname = \
|
||||
get_nickname_from_actor(search_handle)
|
||||
if search_nickname:
|
||||
search_domain, _ = \
|
||||
get_domain_from_actor(search_handle)
|
||||
search_handle = \
|
||||
search_nickname + '@' + search_domain
|
||||
else:
|
||||
search_handle = None
|
||||
if '@' not in search_handle:
|
||||
# is this a local nickname on this instance?
|
||||
local_handle = \
|
||||
|
@ -2234,11 +2240,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.translate,
|
||||
base_dir, http_prefix,
|
||||
nickname)
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._login_headers('text/html',
|
||||
msglen, calling_domain)
|
||||
self._write(msg)
|
||||
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
|
||||
elif moderation_str.startswith('submitBlock'):
|
||||
|
@ -3088,11 +3095,13 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
options_actor,
|
||||
self.server.debug,
|
||||
self.server.system_language,
|
||||
signing_priv_key_pem).encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._set_headers('text/html', msglen,
|
||||
cookie, calling_domain, False)
|
||||
self._write(msg)
|
||||
signing_priv_key_pem)
|
||||
if msg:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._set_headers('text/html', msglen,
|
||||
cookie, calling_domain, False)
|
||||
self._write(msg)
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
else:
|
||||
|
@ -3227,6 +3236,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
users_path = path.split('/unfollowconfirm')[0]
|
||||
origin_path_str = http_prefix + '://' + domain_full + users_path
|
||||
follower_nickname = get_nickname_from_actor(origin_path_str)
|
||||
if not follower_nickname:
|
||||
self.send_response(400)
|
||||
self.end_headers()
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
|
||||
length = int(self.headers['Content-length'])
|
||||
|
||||
|
@ -3257,6 +3271,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if '&' in following_actor:
|
||||
following_actor = following_actor.split('&')[0]
|
||||
following_nickname = get_nickname_from_actor(following_actor)
|
||||
if not following_nickname:
|
||||
self.send_response(400)
|
||||
self.end_headers()
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
following_domain, following_port = \
|
||||
get_domain_from_actor(following_actor)
|
||||
following_domain_full = \
|
||||
|
@ -3318,6 +3337,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
users_path = path.split('/followconfirm')[0]
|
||||
origin_path_str = http_prefix + '://' + domain_full + users_path
|
||||
follower_nickname = get_nickname_from_actor(origin_path_str)
|
||||
if not follower_nickname:
|
||||
self.send_response(400)
|
||||
self.end_headers()
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
|
||||
length = int(self.headers['Content-length'])
|
||||
|
||||
|
@ -3358,6 +3382,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if '&' in following_actor:
|
||||
following_actor = following_actor.split('&')[0]
|
||||
following_nickname = get_nickname_from_actor(following_actor)
|
||||
if not following_nickname:
|
||||
self.send_response(400)
|
||||
self.end_headers()
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
following_domain, following_port = \
|
||||
get_domain_from_actor(following_actor)
|
||||
if follower_nickname == following_nickname and \
|
||||
|
@ -3664,6 +3693,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
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
|
||||
|
||||
# hashtag search
|
||||
timezone = None
|
||||
if self.server.account_timezone.get(nickname):
|
||||
|
@ -3761,6 +3796,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
break
|
||||
# your post history search
|
||||
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 self.server.account_timezone.get(nickname):
|
||||
|
@ -3834,6 +3874,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
break
|
||||
# bookmark search
|
||||
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 self.server.account_timezone.get(nickname):
|
||||
|
@ -3890,6 +3935,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
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', '')
|
||||
|
||||
# are we already following the searched for handle?
|
||||
|
@ -3897,6 +3947,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
# get the actor
|
||||
if not has_users_path(search_str):
|
||||
search_nickname = get_nickname_from_actor(search_str)
|
||||
if not search_nickname:
|
||||
self.send_response(400)
|
||||
self.end_headers()
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
search_domain, search_port = \
|
||||
get_domain_from_actor(search_str)
|
||||
search_domain_full = \
|
||||
|
@ -4310,6 +4365,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
local_actor_url(http_prefix, admin_nickname, domain_full)
|
||||
actor = origin_path_str
|
||||
actor_nickname = get_nickname_from_actor(actor)
|
||||
if not actor_nickname:
|
||||
self.send_response(400)
|
||||
self.end_headers()
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
if actor == share_actor or actor == admin_actor or \
|
||||
is_moderator(base_dir, actor_nickname):
|
||||
item_id = remove_share_confirm_params.split('itemID=')[1]
|
||||
|
@ -4378,6 +4438,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
local_actor_url(http_prefix, admin_nickname, domain_full)
|
||||
actor = origin_path_str
|
||||
actor_nickname = get_nickname_from_actor(actor)
|
||||
if not actor_nickname:
|
||||
self.send_response(400)
|
||||
self.end_headers()
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
if actor == share_actor or actor == admin_actor or \
|
||||
is_moderator(base_dir, actor_nickname):
|
||||
item_id = remove_share_confirm_params.split('itemID=')[1]
|
||||
|
@ -4921,6 +4986,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
users_path = path.replace('/citationsdata', '')
|
||||
actor_str = self._get_instance_url(calling_domain) + users_path
|
||||
nickname = get_nickname_from_actor(actor_str)
|
||||
if not nickname:
|
||||
self.server.postreq_busy = False
|
||||
return
|
||||
|
||||
citations_filename = \
|
||||
acct_dir(base_dir, nickname, domain) + '/.citations.txt'
|
||||
|
@ -7764,8 +7832,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.text_mode_banner,
|
||||
self.server.news_instance,
|
||||
authorized,
|
||||
access_keys, is_group).encode('utf-8')
|
||||
access_keys, is_group)
|
||||
if msg:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._set_headers('text/html', msglen,
|
||||
cookie, calling_domain, False)
|
||||
|
@ -8547,6 +8616,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
following_handle = path.split('/followapprove=')[1]
|
||||
if '://' in following_handle:
|
||||
handle_nickname = get_nickname_from_actor(following_handle)
|
||||
if not handle_nickname:
|
||||
self._404()
|
||||
return
|
||||
handle_domain, handle_port = \
|
||||
get_domain_from_actor(following_handle)
|
||||
following_handle = \
|
||||
|
@ -8733,6 +8805,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
following_handle = path.split('/followdeny=')[1]
|
||||
if '://' in following_handle:
|
||||
handle_nickname = get_nickname_from_actor(following_handle)
|
||||
if not handle_nickname:
|
||||
self._404()
|
||||
return
|
||||
handle_domain, handle_port = \
|
||||
get_domain_from_actor(following_handle)
|
||||
following_handle = \
|
||||
|
@ -10105,6 +10180,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
actor = \
|
||||
http_prefix + '://' + domain_full + path.split('?mute=')[0]
|
||||
nickname = get_nickname_from_actor(actor)
|
||||
if not nickname:
|
||||
self._404()
|
||||
return
|
||||
mute_post(base_dir, nickname, domain, port,
|
||||
http_prefix, mute_url,
|
||||
self.server.recent_posts_cache, debug)
|
||||
|
@ -10226,6 +10304,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
actor = \
|
||||
http_prefix + '://' + domain_full + path.split('?unmute=')[0]
|
||||
nickname = get_nickname_from_actor(actor)
|
||||
if not nickname:
|
||||
self._404()
|
||||
return
|
||||
unmute_post(base_dir, nickname, domain, port,
|
||||
http_prefix, mute_url,
|
||||
self.server.recent_posts_cache, debug)
|
||||
|
@ -13817,6 +13898,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
"""Shows a QR code for an account
|
||||
"""
|
||||
nickname = get_nickname_from_actor(path)
|
||||
if not nickname:
|
||||
self._404()
|
||||
return True
|
||||
if onion_domain:
|
||||
qrcode_domain = onion_domain
|
||||
port = 80
|
||||
|
@ -13866,6 +13950,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
"""Shows a banner image on the search screen
|
||||
"""
|
||||
nickname = get_nickname_from_actor(path)
|
||||
if not nickname:
|
||||
self._404()
|
||||
return True
|
||||
banner_filename = \
|
||||
acct_dir(base_dir, nickname, domain) + '/search_banner.png'
|
||||
if not os.path.isfile(banner_filename):
|
||||
|
@ -14256,7 +14343,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
break
|
||||
if is_new_post_endpoint:
|
||||
nickname = get_nickname_from_actor(path)
|
||||
|
||||
if not nickname:
|
||||
self._404()
|
||||
return True
|
||||
if in_reply_to_url:
|
||||
reply_interval_hours = self.server.default_reply_interval_hrs
|
||||
if not can_reply_to(base_dir, nickname, domain,
|
||||
|
@ -14403,8 +14492,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
access_keys,
|
||||
default_reply_interval_hrs,
|
||||
self.server.cw_lists,
|
||||
self.server.lists_enabled).encode('utf-8')
|
||||
self.server.lists_enabled)
|
||||
if msg:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._set_headers('text/html', msglen,
|
||||
cookie, calling_domain, False)
|
||||
|
@ -14436,8 +14526,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
port,
|
||||
http_prefix,
|
||||
self.server.default_timeline,
|
||||
theme, access_keys).encode('utf-8')
|
||||
theme, access_keys)
|
||||
if msg:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._set_headers('text/html', msglen,
|
||||
cookie, calling_domain, False)
|
||||
|
@ -14470,8 +14561,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
http_prefix,
|
||||
self.server.default_timeline,
|
||||
self.server.theme_name,
|
||||
access_keys).encode('utf-8')
|
||||
access_keys)
|
||||
if msg:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._set_headers('text/html', msglen,
|
||||
cookie, calling_domain, False)
|
||||
|
@ -15810,6 +15902,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if html_getreq and authorized and users_in_path and \
|
||||
self.path.endswith('/followingaccounts'):
|
||||
nickname = get_nickname_from_actor(self.path)
|
||||
if not nickname:
|
||||
self._404()
|
||||
return
|
||||
following_filename = \
|
||||
acct_dir(self.server.base_dir,
|
||||
nickname, self.server.domain) + '/following.txt'
|
||||
|
@ -16574,14 +16669,16 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.default_timeline,
|
||||
self.server.theme_name,
|
||||
self.server.text_mode_banner,
|
||||
access_keys).encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._set_headers('text/html', msglen, cookie, calling_domain,
|
||||
False)
|
||||
self._write(msg)
|
||||
fitness_performance(getreq_start_time, self.server.fitness,
|
||||
'_GET', 'search screen shown',
|
||||
self.server.debug)
|
||||
access_keys)
|
||||
if msg:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._set_headers('text/html', msglen, cookie,
|
||||
calling_domain, False)
|
||||
self._write(msg)
|
||||
fitness_performance(getreq_start_time, self.server.fitness,
|
||||
'_GET', 'search screen shown',
|
||||
self.server.debug)
|
||||
self.server.getreq_busy = False
|
||||
return
|
||||
|
||||
|
@ -16628,20 +16725,24 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.domain_full,
|
||||
self.server.text_mode_banner,
|
||||
access_keys,
|
||||
False).encode('utf-8')
|
||||
msglen = len(msg)
|
||||
if 'ical=true' in self.path:
|
||||
self._set_headers('text/calendar',
|
||||
msglen, cookie, calling_domain,
|
||||
False)
|
||||
False)
|
||||
if msg:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
if 'ical=true' in self.path:
|
||||
self._set_headers('text/calendar',
|
||||
msglen, cookie, calling_domain,
|
||||
False)
|
||||
else:
|
||||
self._set_headers('text/html',
|
||||
msglen, cookie, calling_domain,
|
||||
False)
|
||||
self._write(msg)
|
||||
fitness_performance(getreq_start_time, self.server.fitness,
|
||||
'_GET', 'calendar shown',
|
||||
self.server.debug)
|
||||
else:
|
||||
self._set_headers('text/html',
|
||||
msglen, cookie, calling_domain,
|
||||
False)
|
||||
self._write(msg)
|
||||
fitness_performance(getreq_start_time, self.server.fitness,
|
||||
'_GET', 'calendar shown',
|
||||
self.server.debug)
|
||||
self._404()
|
||||
self.server.getreq_busy = False
|
||||
return
|
||||
|
||||
|
@ -17213,6 +17314,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if ';' in actor:
|
||||
actor = actor.split(';')[0]
|
||||
nickname = get_nickname_from_actor(self.path.split('?')[0])
|
||||
if not nickname:
|
||||
self._404()
|
||||
self.server.getreq_busy = False
|
||||
return
|
||||
if nickname == actor:
|
||||
post_url = \
|
||||
local_actor_url(self.server.http_prefix, nickname,
|
||||
|
@ -17715,11 +17820,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.debug,
|
||||
self.server.system_language,
|
||||
self.server.signing_priv_key_pem)
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._login_headers('text/html',
|
||||
msglen, calling_domain)
|
||||
self._write(msg)
|
||||
if msg:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._login_headers('text/html',
|
||||
msglen, calling_domain)
|
||||
self._write(msg)
|
||||
self.server.getreq_busy = False
|
||||
return
|
||||
|
||||
|
@ -17752,11 +17858,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.debug,
|
||||
self.server.system_language,
|
||||
self.server.signing_priv_key_pem)
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._login_headers('text/html',
|
||||
msglen, calling_domain)
|
||||
self._write(msg)
|
||||
if msg:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._login_headers('text/html',
|
||||
msglen, calling_domain)
|
||||
self._write(msg)
|
||||
self.server.getreq_busy = False
|
||||
return
|
||||
|
||||
|
|
18
inbox.py
18
inbox.py
|
@ -1941,6 +1941,9 @@ def _receive_announce(recent_posts_cache: {},
|
|||
# is the announce actor blocked?
|
||||
nickname = handle.split('@')[0]
|
||||
actor_nickname = get_nickname_from_actor(message_json['actor'])
|
||||
if not actor_nickname:
|
||||
print('WARN: _receive_announce no actor_nickname')
|
||||
return False
|
||||
actor_domain, _ = get_domain_from_actor(message_json['actor'])
|
||||
if is_blocked(base_dir, nickname, domain, actor_nickname, actor_domain):
|
||||
print('Receive announce blocked for actor: ' +
|
||||
|
@ -1948,13 +1951,16 @@ def _receive_announce(recent_posts_cache: {},
|
|||
return False
|
||||
|
||||
# also check the actor for the url being announced
|
||||
announcedActorNickname = get_nickname_from_actor(message_json['object'])
|
||||
announced_actor_nickname = get_nickname_from_actor(message_json['object'])
|
||||
if not announced_actor_nickname:
|
||||
print('WARN: _receive_announce no announced_actor_nickname')
|
||||
return False
|
||||
announcedActorDomain, announcedActorPort = \
|
||||
get_domain_from_actor(message_json['object'])
|
||||
if is_blocked(base_dir, nickname, domain,
|
||||
announcedActorNickname, announcedActorDomain):
|
||||
announced_actor_nickname, announcedActorDomain):
|
||||
print('Receive announce object blocked for actor: ' +
|
||||
announcedActorNickname + '@' + announcedActorDomain)
|
||||
announced_actor_nickname + '@' + announcedActorDomain)
|
||||
return False
|
||||
|
||||
# is this post in the outbox of the person?
|
||||
|
@ -2788,6 +2794,8 @@ def _inbox_update_calendar(base_dir: str, handle: str,
|
|||
|
||||
actor = post_json_object['actor']
|
||||
actor_nickname = get_nickname_from_actor(actor)
|
||||
if not actor_nickname:
|
||||
return
|
||||
actor_domain, _ = get_domain_from_actor(actor)
|
||||
handle_nickname = handle.split('@')[0]
|
||||
handle_domain = handle.split('@')[1]
|
||||
|
@ -3254,6 +3262,8 @@ def _low_frequency_post_notification(base_dir: str, http_prefix: str,
|
|||
if not isinstance(attributed_to, str):
|
||||
return
|
||||
from_nickname = get_nickname_from_actor(attributed_to)
|
||||
if not from_nickname:
|
||||
return
|
||||
from_domain, from_port = get_domain_from_actor(attributed_to)
|
||||
from_domain_full = get_full_domain(from_domain, from_port)
|
||||
if notify_when_person_posts(base_dir, nickname, domain,
|
||||
|
@ -3282,6 +3292,8 @@ def _check_for_git_patches(base_dir: str, nickname: str, domain: str,
|
|||
if not isinstance(attributed_to, str):
|
||||
return 0
|
||||
from_nickname = get_nickname_from_actor(attributed_to)
|
||||
if not from_nickname:
|
||||
return 0
|
||||
from_domain, from_port = get_domain_from_actor(attributed_to)
|
||||
from_domain_full = get_full_domain(from_domain, from_port)
|
||||
if receive_git_patch(base_dir, nickname, domain,
|
||||
|
|
3
posts.py
3
posts.py
|
@ -4815,6 +4815,9 @@ def download_announce(session, base_dir: str, http_prefix: str,
|
|||
'Accept': accept_str
|
||||
}
|
||||
actor_nickname = get_nickname_from_actor(post_json_object['actor'])
|
||||
if not actor_nickname:
|
||||
print('WARN: download_announce no actor_nickname')
|
||||
return None
|
||||
actor_domain, actor_port = \
|
||||
get_domain_from_actor(post_json_object['actor'])
|
||||
if not actor_domain:
|
||||
|
|
|
@ -541,6 +541,8 @@ def html_emoji_reactions(post_json_object: {}, interactive: bool,
|
|||
emoji_content = item['content']
|
||||
emoji_actor = item['actor']
|
||||
emoji_nickname = get_nickname_from_actor(emoji_actor)
|
||||
if not emoji_nickname:
|
||||
return ''
|
||||
emoji_domain, _ = get_domain_from_actor(emoji_actor)
|
||||
emoji_handle = emoji_nickname + '@' + emoji_domain
|
||||
if emoji_actor == actor:
|
||||
|
|
|
@ -158,6 +158,8 @@ def outbox_skills(base_dir: str, nickname: str, message_json: {},
|
|||
return False
|
||||
|
||||
actor_nickname = get_nickname_from_actor(message_json['actor'])
|
||||
if not actor_nickname:
|
||||
return False
|
||||
if actor_nickname != nickname:
|
||||
return False
|
||||
domain, _ = get_domain_from_actor(message_json['actor'])
|
||||
|
|
6
utils.py
6
utils.py
|
@ -2343,6 +2343,8 @@ def undo_likes_collection_entry(recent_posts_cache: {},
|
|||
# remove any cached version of this post so that the
|
||||
# like icon is changed
|
||||
nickname = get_nickname_from_actor(actor)
|
||||
if not nickname:
|
||||
return
|
||||
cached_post_filename = \
|
||||
get_cached_post_filename(base_dir, nickname,
|
||||
domain, post_json_object)
|
||||
|
@ -2409,6 +2411,8 @@ def undo_reaction_collection_entry(recent_posts_cache: {},
|
|||
# remove any cached version of this post so that the
|
||||
# like icon is changed
|
||||
nickname = get_nickname_from_actor(actor)
|
||||
if not nickname:
|
||||
return
|
||||
cached_post_filename = \
|
||||
get_cached_post_filename(base_dir, nickname,
|
||||
domain, post_json_object)
|
||||
|
@ -2476,6 +2480,8 @@ def undo_announce_collection_entry(recent_posts_cache: {},
|
|||
# remove any cached version of this announce so that the announce
|
||||
# icon is changed
|
||||
nickname = get_nickname_from_actor(actor)
|
||||
if not nickname:
|
||||
return
|
||||
cached_post_filename = \
|
||||
get_cached_post_filename(base_dir, nickname, domain,
|
||||
post_json_object)
|
||||
|
|
|
@ -42,6 +42,8 @@ def html_calendar_delete_confirm(css_cache: {}, translate: {}, base_dir: str,
|
|||
"""Shows a screen asking to confirm the deletion of a calendar event
|
||||
"""
|
||||
nickname = get_nickname_from_actor(path)
|
||||
if not nickname:
|
||||
return None
|
||||
actor = local_actor_url(http_prefix, nickname, domain_full)
|
||||
domain, _ = get_domain_from_actor(actor)
|
||||
message_id = actor + '/statuses/' + post_id
|
||||
|
@ -304,6 +306,8 @@ def html_calendar(person_cache: {}, css_cache: {}, translate: {},
|
|||
month_number = curr_date.month
|
||||
|
||||
nickname = get_nickname_from_actor(actor)
|
||||
if not nickname:
|
||||
return ''
|
||||
|
||||
set_custom_background(base_dir, 'calendar-background',
|
||||
'calendar-background')
|
||||
|
|
|
@ -45,6 +45,8 @@ def html_confirm_delete(css_cache: {},
|
|||
return None
|
||||
actor = message_id.split('/statuses/')[0]
|
||||
nickname = get_nickname_from_actor(actor)
|
||||
if not nickname:
|
||||
return None
|
||||
domain, port = get_domain_from_actor(actor)
|
||||
domain_full = get_full_domain(domain, port)
|
||||
|
||||
|
@ -119,6 +121,8 @@ def html_confirm_remove_shared_item(css_cache: {}, translate: {},
|
|||
"""Shows a screen asking to confirm the removal of a shared item
|
||||
"""
|
||||
nickname = get_nickname_from_actor(actor)
|
||||
if not nickname:
|
||||
return None
|
||||
domain, port = get_domain_from_actor(actor)
|
||||
domain_full = get_full_domain(domain, port)
|
||||
shares_file = \
|
||||
|
@ -207,10 +211,11 @@ def html_confirm_follow(css_cache: {}, translate: {}, base_dir: str,
|
|||
follow_str += ' <a href="' + follow_actor + '">\n'
|
||||
follow_str += \
|
||||
' <img loading="lazy" src="' + follow_profile_url + '"/></a>\n'
|
||||
follow_str += \
|
||||
' <p class="followText">' + translate['Follow'] + ' ' + \
|
||||
get_nickname_from_actor(follow_actor) + \
|
||||
'@' + follow_domain + ' ?</p>\n'
|
||||
follow_actor_nick = get_nickname_from_actor(follow_actor)
|
||||
if follow_actor_nick:
|
||||
follow_str += \
|
||||
' <p class="followText">' + translate['Follow'] + ' ' + \
|
||||
follow_actor_nick + '@' + follow_domain + ' ?</p>\n'
|
||||
follow_str += ' <form method="POST" action="' + \
|
||||
origin_path_str + '/followconfirm">\n'
|
||||
follow_str += ' <input type="hidden" name="actor" value="' + \
|
||||
|
@ -255,10 +260,11 @@ def html_confirm_unfollow(css_cache: {}, translate: {}, base_dir: str,
|
|||
follow_str += ' <a href="' + follow_actor + '">\n'
|
||||
follow_str += \
|
||||
' <img loading="lazy" src="' + follow_profile_url + '"/></a>\n'
|
||||
follow_str += \
|
||||
' <p class="followText">' + translate['Stop following'] + \
|
||||
' ' + get_nickname_from_actor(follow_actor) + \
|
||||
'@' + follow_domain + ' ?</p>\n'
|
||||
follow_actor_nick = get_nickname_from_actor(follow_actor)
|
||||
if follow_actor_nick:
|
||||
follow_str += \
|
||||
' <p class="followText">' + translate['Stop following'] + \
|
||||
' ' + follow_actor_nick + '@' + follow_domain + ' ?</p>\n'
|
||||
follow_str += ' <form method="POST" action="' + \
|
||||
origin_path_str + '/unfollowconfirm">\n'
|
||||
follow_str += ' <input type="hidden" name="actor" value="' + \
|
||||
|
@ -300,9 +306,11 @@ def html_confirm_unblock(css_cache: {}, translate: {}, base_dir: str,
|
|||
block_str += ' <a href="' + block_actor + '">\n'
|
||||
block_str += \
|
||||
' <img loading="lazy" src="' + block_profile_url + '"/></a>\n'
|
||||
block_str += \
|
||||
' <p class="blockText">' + translate['Stop blocking'] + ' ' + \
|
||||
get_nickname_from_actor(block_actor) + '@' + block_domain + ' ?</p>\n'
|
||||
block_actor_nick = get_nickname_from_actor(block_actor)
|
||||
if block_actor_nick:
|
||||
block_str += \
|
||||
' <p class="blockText">' + translate['Stop blocking'] + ' ' + \
|
||||
block_actor_nick + '@' + block_domain + ' ?</p>\n'
|
||||
block_str += ' <form method="POST" action="' + \
|
||||
origin_path_str + '/unblockconfirm">\n'
|
||||
block_str += ' <input type="hidden" name="actor" value="' + \
|
||||
|
|
|
@ -200,6 +200,8 @@ def html_search_hashtag_category(css_cache: {}, translate: {},
|
|||
actor = path.split('/category/')[0]
|
||||
category_str = path.split('/category/')[1].strip()
|
||||
search_nickname = get_nickname_from_actor(actor)
|
||||
if not search_nickname:
|
||||
return ''
|
||||
|
||||
set_custom_background(base_dir, 'search-background', 'follow-background')
|
||||
|
||||
|
|
|
@ -142,6 +142,8 @@ def html_likers_of_post(base_dir: str, nickname: str,
|
|||
liker_name, False)
|
||||
else:
|
||||
liker_name = get_nickname_from_actor(liker_actor)
|
||||
if not liker_name:
|
||||
liker_name = 'unknown'
|
||||
if likers_list:
|
||||
likers_list += ' '
|
||||
liker_avatar_url = \
|
||||
|
|
|
@ -107,6 +107,8 @@ def html_account_info(css_cache: {}, translate: {},
|
|||
html_header_with_external_style(css_filename, instance_title, None)
|
||||
|
||||
search_nickname = get_nickname_from_actor(search_handle)
|
||||
if not search_nickname:
|
||||
return ''
|
||||
search_domain, search_port = get_domain_from_actor(search_handle)
|
||||
|
||||
search_handle = search_nickname + '@' + search_domain
|
||||
|
@ -146,6 +148,8 @@ def html_account_info(css_cache: {}, translate: {},
|
|||
blocked_followers = []
|
||||
for follower_actor in followers_list:
|
||||
follower_nickname = get_nickname_from_actor(follower_actor)
|
||||
if not follower_nickname:
|
||||
return ''
|
||||
follower_domain, follower_port = get_domain_from_actor(follower_actor)
|
||||
follower_domain_full = get_full_domain(follower_domain, follower_port)
|
||||
if is_blocked(base_dir, nickname, domain,
|
||||
|
@ -160,6 +164,8 @@ def html_account_info(css_cache: {}, translate: {},
|
|||
blocked_following = []
|
||||
for following_actor in following_list:
|
||||
following_nickname = get_nickname_from_actor(following_actor)
|
||||
if not following_nickname:
|
||||
return ''
|
||||
following_domain, following_port = \
|
||||
get_domain_from_actor(following_actor)
|
||||
following_domain_full = \
|
||||
|
@ -224,6 +230,8 @@ def html_account_info(css_cache: {}, translate: {},
|
|||
':</p>\n'
|
||||
for actor in blocked_following:
|
||||
following_nickname = get_nickname_from_actor(actor)
|
||||
if not following_nickname:
|
||||
return ''
|
||||
following_domain, following_port = get_domain_from_actor(actor)
|
||||
following_domain_full = \
|
||||
get_full_domain(following_domain, following_port)
|
||||
|
@ -243,6 +251,8 @@ def html_account_info(css_cache: {}, translate: {},
|
|||
':</p>\n'
|
||||
for actor in blocked_followers:
|
||||
follower_nickname = get_nickname_from_actor(actor)
|
||||
if not follower_nickname:
|
||||
return ''
|
||||
follower_domain, follower_port = get_domain_from_actor(actor)
|
||||
follower_domain_full = \
|
||||
get_full_domain(follower_domain, follower_port)
|
||||
|
|
|
@ -99,6 +99,8 @@ def html_person_options(default_timeline: str,
|
|||
dormant_months)
|
||||
|
||||
options_nickname = get_nickname_from_actor(options_actor)
|
||||
if not options_nickname:
|
||||
return None
|
||||
options_domain_full = get_full_domain(options_domain, options_port)
|
||||
follows_you = \
|
||||
is_follower_of_person(base_dir,
|
||||
|
@ -142,7 +144,10 @@ def html_person_options(default_timeline: str,
|
|||
options_str += ' <a href="' + options_actor + '">\n'
|
||||
options_str += ' <img loading="lazy" src="' + options_profile_url + \
|
||||
'" alt="" ' + get_broken_link_substitute() + '/></a>\n'
|
||||
handle = get_nickname_from_actor(options_actor) + '@' + options_domain
|
||||
handle_nick = get_nickname_from_actor(options_actor)
|
||||
if not handle_nick:
|
||||
return None
|
||||
handle = handle_nick + '@' + options_domain
|
||||
handle_shown = handle
|
||||
if locked_account:
|
||||
handle_shown += '🔒'
|
||||
|
|
|
@ -104,11 +104,12 @@ def _html_post_metadata_open_graph(domain: str, post_json_object: {}) -> str:
|
|||
if isinstance(obj_json['attributedTo'], str):
|
||||
attrib = obj_json['attributedTo']
|
||||
actor_nick = get_nickname_from_actor(attrib)
|
||||
actor_domain, _ = get_domain_from_actor(attrib)
|
||||
actor_handle = actor_nick + '@' + actor_domain
|
||||
metadata += \
|
||||
" <meta content=\"@" + actor_handle + \
|
||||
"\" property=\"og:title\" />\n"
|
||||
if actor_nick:
|
||||
actor_domain, _ = get_domain_from_actor(attrib)
|
||||
actor_handle = actor_nick + '@' + actor_domain
|
||||
metadata += \
|
||||
" <meta content=\"@" + actor_handle + \
|
||||
"\" property=\"og:title\" />\n"
|
||||
if obj_json.get('url'):
|
||||
metadata += \
|
||||
" <meta content=\"" + obj_json['url'] + \
|
||||
|
@ -410,6 +411,8 @@ def _get_reply_icon_html(base_dir: str, nickname: str, domain: str,
|
|||
# check that the alternative replyTo url is not blocked
|
||||
block_nickname = \
|
||||
get_nickname_from_actor(post_json_object['object']['replyTo'])
|
||||
if not block_nickname:
|
||||
return reply_str
|
||||
block_domain, _ = \
|
||||
get_domain_from_actor(post_json_object['object']['replyTo'])
|
||||
if not is_blocked(base_dir, nickname, domain,
|
||||
|
@ -1516,6 +1519,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
|||
if domain_full not in post_actor:
|
||||
# lookup the correct webfinger for the post_actor
|
||||
post_actor_nickname = get_nickname_from_actor(post_actor)
|
||||
if not post_actor_nickname:
|
||||
return ''
|
||||
post_actor_domain, post_actor_port = get_domain_from_actor(post_actor)
|
||||
post_actor_domain_full = \
|
||||
get_full_domain(post_actor_domain, post_actor_port)
|
||||
|
@ -2132,6 +2137,8 @@ def html_individual_post(css_cache: {},
|
|||
|
||||
if by_str:
|
||||
by_str_nickname = get_nickname_from_actor(by_str)
|
||||
if not by_str_nickname:
|
||||
return ''
|
||||
by_str_domain, by_str_port = get_domain_from_actor(by_str)
|
||||
by_str_domain = get_full_domain(by_str_domain, by_str_port)
|
||||
by_str_handle = by_str_nickname + '@' + by_str_domain
|
||||
|
|
|
@ -2429,6 +2429,8 @@ def _individual_follow_as_html(signing_priv_key_pem: str,
|
|||
"""An individual follow entry on the profile screen
|
||||
"""
|
||||
follow_url_nickname = get_nickname_from_actor(followUrl)
|
||||
if not follow_url_nickname:
|
||||
return ''
|
||||
follow_url_domain, follow_url_port = get_domain_from_actor(followUrl)
|
||||
follow_url_domain_full = \
|
||||
get_full_domain(follow_url_domain, follow_url_port)
|
||||
|
|
|
@ -380,6 +380,8 @@ def html_search(css_cache: {}, translate: {},
|
|||
"""
|
||||
actor = path.replace('/search', '')
|
||||
search_nickname = get_nickname_from_actor(actor)
|
||||
if not search_nickname:
|
||||
return ''
|
||||
|
||||
set_custom_background(base_dir, 'search-background', 'follow-background')
|
||||
|
||||
|
|
|
@ -418,6 +418,8 @@ def shares_timeline_json(actor: str, pageNumber: int, items_per_page: int,
|
|||
share_actor = share_actor.replace('___', '://')
|
||||
share_actor = share_actor.replace('--', '/')
|
||||
share_nickname = get_nickname_from_actor(share_actor)
|
||||
if not share_nickname:
|
||||
continue
|
||||
if is_blocked(base_dir, nickname, domain,
|
||||
share_nickname, federated_domain, None):
|
||||
continue
|
||||
|
@ -1538,6 +1540,8 @@ def html_search_result_share(base_dir: str, shared_item: {}, translate: {},
|
|||
# should the remove button be shown?
|
||||
show_remove_button = False
|
||||
nickname = get_nickname_from_actor(actor)
|
||||
if not nickname:
|
||||
return ''
|
||||
if actor.endswith('/users/' + contact_nickname):
|
||||
show_remove_button = True
|
||||
elif is_moderator(base_dir, nickname):
|
||||
|
|
Loading…
Reference in New Issue