From 7254c2636ab502cc4ae0ead731ac547618693507 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 27 May 2024 13:45:01 +0100 Subject: [PATCH] users path --- acceptreject.py | 10 +++++++++- announce.py | 9 ++++++--- blocking.py | 26 ++++++++++++++++++++++---- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/acceptreject.py b/acceptreject.py index 57fb6aff0..35939bb5d 100644 --- a/acceptreject.py +++ b/acceptreject.py @@ -10,6 +10,7 @@ __status__ = "Production" __module_group__ = "ActivityPub" import os +from utils import get_user_paths from utils import text_in_file from utils import has_object_string_object from utils import has_users_path @@ -131,7 +132,14 @@ def _accept_follow(base_dir: str, message_json: {}, print('DEBUG: unrecognized actor ' + this_actor) return else: - if not '/' + accepted_domain + '/users/' + nickname in this_actor: + actor_found = False + users_list = get_user_paths() + for users_str in users_list: + if '/' + accepted_domain + users_str + nickname in this_actor: + actor_found = True + break + + if not actor_found: if debug: print('Expected: /' + accepted_domain + '/users/' + nickname) print('Actual: ' + this_actor) diff --git a/announce.py b/announce.py index 8aba08da9..2fc3cb661 100644 --- a/announce.py +++ b/announce.py @@ -9,6 +9,7 @@ __email__ = "bob@libreserver.org" __status__ = "Production" __module_group__ = "ActivityPub" +from utils import get_user_paths from utils import has_object_string_object from utils import has_group_type from utils import has_object_dict @@ -149,9 +150,11 @@ def announced_by_person(is_announced: bool, post_actor: str, """ if not post_actor: return False - if is_announced and \ - post_actor.endswith(domain_full + '/users/' + nickname): - return True + if is_announced: + users_paths = get_user_paths() + for possible_path in users_paths: + if post_actor.endswith(domain_full + possible_path + nickname): + return True return False diff --git a/blocking.py b/blocking.py index c103096ac..0fa2080d1 100644 --- a/blocking.py +++ b/blocking.py @@ -12,6 +12,8 @@ import json import time from session import get_json_valid from session import create_session +from utils import get_user_paths +from utils import contains_statuses from utils import data_dir from utils import string_contains from utils import date_from_string_format @@ -1469,7 +1471,15 @@ def outbox_mute(base_dir: str, http_prefix: str, return domain_full = get_full_domain(domain, port) actor_url = get_actor_from_post(message_json) - if not actor_url.endswith(domain_full + '/users/' + nickname): + + actor_found = False + users_paths = get_user_paths() + for possible_path in users_paths: + if actor_url.endswith(domain_full + possible_path + nickname): + actor_found = True + break + + if not actor_found: return if not message_json['type'] == 'Ignore': return @@ -1479,7 +1489,7 @@ def outbox_mute(base_dir: str, http_prefix: str, print('DEBUG: c2s mute request arrived in outbox') message_id = remove_id_ending(message_json['object']) - if '/statuses/' not in message_id: + if not contains_statuses(message_id): if debug: print('DEBUG: c2s mute object is not a status') return @@ -1519,7 +1529,15 @@ def outbox_undo_mute(base_dir: str, http_prefix: str, return domain_full = get_full_domain(domain, port) actor_url = get_actor_from_post(message_json) - if not actor_url.endswith(domain_full + '/users/' + nickname): + + actor_found = False + users_paths = get_user_paths() + for possible_path in users_paths: + if actor_url.endswith(domain_full + possible_path + nickname): + actor_found = True + break + + if not actor_found: return if not message_json['type'] == 'Undo': return @@ -1535,7 +1553,7 @@ def outbox_undo_mute(base_dir: str, http_prefix: str, print('DEBUG: c2s undo mute request arrived in outbox') message_id = remove_id_ending(message_json['object']['object']) - if '/statuses/' not in message_id: + if not contains_statuses(message_id): if debug: print('DEBUG: c2s undo mute object is not a status') return