main
Bob Mottram 2023-03-16 12:47:48 +00:00
parent 99d3558a46
commit f1ab81b853
2 changed files with 32 additions and 19 deletions

View File

@ -119,7 +119,7 @@ from inbox import run_inbox_queue_watchdog
from inbox import save_post_to_inbox_queue
from inbox import populate_replies
from inbox import receive_edit_to_post
from follow import get_followers_for_domain
from follow import get_followers_sync_json
from follow import follower_approval_active
from follow import is_following_actor
from follow import get_following_feed
@ -16917,20 +16917,12 @@ class PubServer(BaseHTTPRequestHandler):
# check authorized fetch
if self._secure_mode(curr_session, proxy_type):
nickname = get_nickname_from_actor(self.path)
sync_list = \
get_followers_for_domain(self.server.base_dir,
sync_json = \
get_followers_sync_json(self.server.base_dir,
nickname, self.server.domain,
self.server.http_prefix,
self.server.domain_full,
calling_domain)
id_str = self.server.http_prefix + '://' + \
self.server.domain_full + \
self.path.replace('/followers_synchronization',
'/followers?domain=' + calling_domain)
sync_json = {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': id_str,
'orderedItems': sync_list,
'type': 'OrderedCollection'
}
msg_str = json.dumps(sync_json, ensure_ascii=False)
msg_str = self._convert_domains(calling_domain, referer_domain,
msg_str)

View File

@ -28,7 +28,6 @@ from posts import get_person_box
from utils import load_json
from utils import save_json
from utils import is_account_dir
from utils import get_user_paths
from utils import acct_dir
from utils import has_group_type
from utils import local_actor_url
@ -1361,7 +1360,7 @@ def deny_follow_request_via_server(session,
return deny_html
def get_followers_for_domain(base_dir: str,
def _get_followers_for_domain(base_dir: str,
nickname: str, domain: str,
search_domain: str) -> []:
"""Returns the followers for a given domain
@ -1405,6 +1404,28 @@ def get_followers_for_domain(base_dir: str,
return result
def get_followers_sync_json(base_dir: str,
nickname: str, domain: str,
http_prefix: str, domain_full: str,
search_domain: str) -> {}:
"""Returns a response for followers synchronization
See https://github.com/mastodon/mastodon/pull/14510
"""
sync_list = \
_get_followers_for_domain(base_dir,
nickname, domain,
search_domain)
id_str = http_prefix + '://' + domain_full + \
'/users/' + nickname + '/followers?domain=' + search_domain
sync_json = {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': id_str,
'orderedItems': sync_list,
'type': 'OrderedCollection'
}
return sync_json
def get_followers_of_actor(base_dir: str, actor: str, debug: bool) -> {}:
"""In a shared inbox if we receive a post we know who it's from
and if it's addressed to followers then we need to get a list of those.