users path

merge-requests/30/head
Bob Mottram 2024-05-27 13:45:01 +01:00
parent 12ce4b7df3
commit 7254c2636a
3 changed files with 37 additions and 8 deletions

View File

@ -10,6 +10,7 @@ __status__ = "Production"
__module_group__ = "ActivityPub" __module_group__ = "ActivityPub"
import os import os
from utils import get_user_paths
from utils import text_in_file from utils import text_in_file
from utils import has_object_string_object from utils import has_object_string_object
from utils import has_users_path from utils import has_users_path
@ -131,7 +132,14 @@ def _accept_follow(base_dir: str, message_json: {},
print('DEBUG: unrecognized actor ' + this_actor) print('DEBUG: unrecognized actor ' + this_actor)
return return
else: 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: if debug:
print('Expected: /' + accepted_domain + '/users/' + nickname) print('Expected: /' + accepted_domain + '/users/' + nickname)
print('Actual: ' + this_actor) print('Actual: ' + this_actor)

View File

@ -9,6 +9,7 @@ __email__ = "bob@libreserver.org"
__status__ = "Production" __status__ = "Production"
__module_group__ = "ActivityPub" __module_group__ = "ActivityPub"
from utils import get_user_paths
from utils import has_object_string_object from utils import has_object_string_object
from utils import has_group_type from utils import has_group_type
from utils import has_object_dict from utils import has_object_dict
@ -149,9 +150,11 @@ def announced_by_person(is_announced: bool, post_actor: str,
""" """
if not post_actor: if not post_actor:
return False return False
if is_announced and \ if is_announced:
post_actor.endswith(domain_full + '/users/' + nickname): users_paths = get_user_paths()
return True for possible_path in users_paths:
if post_actor.endswith(domain_full + possible_path + nickname):
return True
return False return False

View File

@ -12,6 +12,8 @@ import json
import time import time
from session import get_json_valid from session import get_json_valid
from session import create_session from session import create_session
from utils import get_user_paths
from utils import contains_statuses
from utils import data_dir from utils import data_dir
from utils import string_contains from utils import string_contains
from utils import date_from_string_format from utils import date_from_string_format
@ -1469,7 +1471,15 @@ def outbox_mute(base_dir: str, http_prefix: str,
return return
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
actor_url = get_actor_from_post(message_json) 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 return
if not message_json['type'] == 'Ignore': if not message_json['type'] == 'Ignore':
return return
@ -1479,7 +1489,7 @@ def outbox_mute(base_dir: str, http_prefix: str,
print('DEBUG: c2s mute request arrived in outbox') print('DEBUG: c2s mute request arrived in outbox')
message_id = remove_id_ending(message_json['object']) message_id = remove_id_ending(message_json['object'])
if '/statuses/' not in message_id: if not contains_statuses(message_id):
if debug: if debug:
print('DEBUG: c2s mute object is not a status') print('DEBUG: c2s mute object is not a status')
return return
@ -1519,7 +1529,15 @@ def outbox_undo_mute(base_dir: str, http_prefix: str,
return return
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
actor_url = get_actor_from_post(message_json) 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 return
if not message_json['type'] == 'Undo': if not message_json['type'] == 'Undo':
return return
@ -1535,7 +1553,7 @@ def outbox_undo_mute(base_dir: str, http_prefix: str,
print('DEBUG: c2s undo mute request arrived in outbox') print('DEBUG: c2s undo mute request arrived in outbox')
message_id = remove_id_ending(message_json['object']['object']) message_id = remove_id_ending(message_json['object']['object'])
if '/statuses/' not in message_id: if not contains_statuses(message_id):
if debug: if debug:
print('DEBUG: c2s undo mute object is not a status') print('DEBUG: c2s undo mute object is not a status')
return return