users path

main
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"
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)

View File

@ -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

View File

@ -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