Send follow requests using the appropriate session

merge-requests/30/head
Bob Mottram 2022-03-11 22:59:15 +00:00
parent 1119f10140
commit ca24fa3265
3 changed files with 32 additions and 10 deletions

View File

@ -3275,14 +3275,31 @@ class PubServer(BaseHTTPRequestHandler):
follower_nickname + ' to ' + following_actor)
if not self.server.signing_priv_key_pem:
print('Sending follow request with no signing key')
curr_domain = domain
curr_port = port
curr_http_prefix = http_prefix
if onion_domain:
if following_domain.endswith('.onion'):
curr_session = self.server.session_onion
curr_domain = onion_domain
curr_port = 80
curr_http_prefix = 'http'
if i2p_domain:
if following_domain.endswith('.i2p'):
curr_session = self.server.session_i2p
curr_domain = i2p_domain
curr_port = 80
curr_http_prefix = 'http'
send_follow_request(curr_session,
base_dir, follower_nickname,
domain, port,
http_prefix,
domain, curr_domain, curr_port,
curr_http_prefix,
following_nickname,
following_domain,
following_actor,
following_port, http_prefix,
following_port, curr_http_prefix,
False, self.server.federation_list,
self.server.send_threads,
self.server.postLog,

View File

@ -852,7 +852,8 @@ def followed_account_rejects(session, base_dir: str, http_prefix: str,
def send_follow_request(session, base_dir: str,
nickname: str, domain: str, port: int,
nickname: str, domain: str,
sender_domain: str, sender_port: int,
http_prefix: str,
follow_nickname: str, follow_domain: str,
followedActor: str,
@ -870,7 +871,7 @@ def send_follow_request(session, base_dir: str,
print('You are not permitted to follow the domain ' + follow_domain)
return None
full_domain = get_full_domain(domain, port)
full_domain = get_full_domain(sender_domain, sender_port)
follow_actor = local_actor_url(http_prefix, nickname, full_domain)
request_domain = get_full_domain(follow_domain, followPort)
@ -934,7 +935,7 @@ def send_follow_request(session, base_dir: str,
follow_handle, debug)
send_signed_json(new_follow_json, session, base_dir,
nickname, domain, port,
nickname, sender_domain, sender_port,
follow_nickname, follow_domain, followPort,
'https://www.w3.org/ns/activitystreams#Public',
http_prefix, True, client_to_server,

View File

@ -1590,7 +1590,8 @@ def test_follow_between_servers(base_dir: str) -> None:
signing_priv_key_pem = None
send_result = \
send_follow_request(session_alice, alice_dir,
'alice', alice_domain, alice_port, http_prefix,
'alice', alice_domain,
alice_domain, alice_port, http_prefix,
'bob', bob_domain, bob_actor,
bob_port, http_prefix,
client_to_server, federation_list,
@ -1810,7 +1811,8 @@ def test_shared_items_federation(base_dir: str) -> None:
bob_actor = http_prefix + '://' + bob_address + '/users/bob'
send_result = \
send_follow_request(session_alice, alice_dir,
'alice', alice_domain, alice_port, http_prefix,
'alice', alice_domain,
alice_domain, alice_port, http_prefix,
'bob', bob_domain, bob_actor,
bob_port, http_prefix,
client_to_server, federation_list,
@ -2261,7 +2263,8 @@ def test_group_follow(base_dir: str) -> None:
signing_priv_key_pem = None
send_result = \
send_follow_request(session_alice, alice_dir,
'alice', alice_domain, alice_port, http_prefix,
'alice', alice_domain,
alice_domain, alice_port, http_prefix,
'testgroup', testgroup_domain, testgroup_actor,
testgroupPort, http_prefix,
client_to_server, federation_list,
@ -2338,7 +2341,8 @@ def test_group_follow(base_dir: str) -> None:
signing_priv_key_pem = None
send_result = \
send_follow_request(session_bob, bob_dir,
'bob', bob_domain, bob_port, http_prefix,
'bob', bob_domain,
bob_domain, bob_port, http_prefix,
'testgroup', testgroup_domain, testgroup_actor,
testgroupPort, http_prefix,
client_to_server, federation_list,