mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
cc4ba5db1c
commit
3d5d508533
15
inbox.py
15
inbox.py
|
@ -18,6 +18,7 @@ from languages import understood_post_language
|
|||
from like import update_likes_collection
|
||||
from reaction import update_reaction_collection
|
||||
from reaction import valid_emoji_content
|
||||
from utils import get_actor_from_post_id
|
||||
from utils import contains_invalid_actor_url_chars
|
||||
from utils import is_quote_toot
|
||||
from utils import acct_handle_dir
|
||||
|
@ -3110,19 +3111,7 @@ def _receive_announce(recent_posts_cache: {},
|
|||
if not contains_invalid_actor_url_chars(attrib):
|
||||
lookup_actor = attrib
|
||||
if lookup_actor:
|
||||
if has_users_path(lookup_actor):
|
||||
if '/statuses/' in lookup_actor:
|
||||
lookup_actor = lookup_actor.split('/statuses/')[0]
|
||||
elif '/objects/' in lookup_actor:
|
||||
lookup_actor = lookup_actor.split('/objects/')[0]
|
||||
elif '/p/' in lookup_actor:
|
||||
# pixelfed style post id
|
||||
lookup_nick = lookup_actor.split('/p/')[1]
|
||||
if '/' in lookup_nick:
|
||||
lookup_nick = lookup_nick.split('/')[0]
|
||||
lookup_actor = \
|
||||
lookup_actor.split('/p/')[0] + '/users/' + lookup_nick
|
||||
|
||||
lookup_actor = get_actor_from_post_id(lookup_actor)
|
||||
if lookup_actor:
|
||||
if is_recent_post(post_json_object, 3):
|
||||
if not os.path.isfile(post_filename + '.tts'):
|
||||
|
|
28
utils.py
28
utils.py
|
@ -1265,11 +1265,30 @@ def dangerous_svg(content: str, allow_local_network_access: bool) -> bool:
|
|||
separators, invalid_strings)
|
||||
|
||||
|
||||
def get_actor_from_post_id(post_id: str) -> str:
|
||||
"""Returns an actor url from a post id
|
||||
eg. https://somedomain/users/nick/statuses/123 becomes
|
||||
https://somedomain/users/nick
|
||||
"""
|
||||
actor = post_id
|
||||
if has_users_path(actor):
|
||||
if '/statuses/' in actor:
|
||||
actor = actor.split('/statuses/')[0]
|
||||
elif '/objects/' in actor:
|
||||
actor = actor.split('/objects/')[0]
|
||||
elif '/p/' in actor:
|
||||
# pixelfed style post id
|
||||
nick = actor.split('/p/')[1]
|
||||
if '/' in nick:
|
||||
nick = nick.split('/')[0]
|
||||
actor = actor.split('/p/')[0] + '/users/' + nick
|
||||
return actor
|
||||
|
||||
|
||||
def get_display_name(base_dir: str, actor: str, person_cache: {}) -> str:
|
||||
"""Returns the display name for the given actor
|
||||
"""
|
||||
if '/statuses/' in actor:
|
||||
actor = actor.split('/statuses/')[0]
|
||||
actor = get_actor_from_post_id(actor)
|
||||
if not person_cache.get(actor):
|
||||
return None
|
||||
name_found = None
|
||||
|
@ -1341,8 +1360,7 @@ def get_gender_from_bio(base_dir: str, actor: str, person_cache: {},
|
|||
This is for use by text-to-speech for pitch setting
|
||||
"""
|
||||
default_gender = 'They/Them'
|
||||
if '/statuses/' in actor:
|
||||
actor = actor.split('/statuses/')[0]
|
||||
actor = get_actor_from_post_id(actor)
|
||||
if not person_cache.get(actor):
|
||||
return default_gender
|
||||
bio_found = None
|
||||
|
@ -1820,7 +1838,7 @@ def can_reply_to(base_dir: str, nickname: str, domain: str,
|
|||
post_url: str, reply_interval_hours: int,
|
||||
curr_date_str: str = None,
|
||||
post_json_object: {} = None) -> bool:
|
||||
"""Is replying to the given post permitted?
|
||||
"""Is replying to the given local post permitted?
|
||||
This is a spam mitigation feature, so that spammers can't
|
||||
add a lot of replies to old post which you don't notice.
|
||||
"""
|
||||
|
|
|
@ -11,6 +11,7 @@ import os
|
|||
from shutil import copyfile
|
||||
import urllib.parse
|
||||
from datetime import datetime
|
||||
from utils import get_actor_from_post_id
|
||||
from utils import remove_html
|
||||
from utils import harmless_markup
|
||||
from utils import remove_id_ending
|
||||
|
@ -1182,9 +1183,7 @@ def html_hashtag_search_remote(nickname: str, domain: str, port: int,
|
|||
'cc' in post_json_object:
|
||||
new_url = \
|
||||
remove_id_ending(post_json_object['id'])
|
||||
actor = new_url
|
||||
if '/statuses/' in actor:
|
||||
actor = actor.split('/statuses/')[0]
|
||||
actor = get_actor_from_post_id(new_url)
|
||||
new_post_json_object = {
|
||||
"type": "Create",
|
||||
"id": new_url + '/activity',
|
||||
|
|
Loading…
Reference in New Issue