From 3fe3dd06a905906e5798c84ab6203e9047b7aa8e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 2 Mar 2020 16:23:30 +0000 Subject: [PATCH] Sending to followers on onion domains --- inbox.py | 2 +- outbox.py | 2 +- posts.py | 26 +++++++++++++++++++------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/inbox.py b/inbox.py index 1eb82ed6..ffd262b3 100644 --- a/inbox.py +++ b/inbox.py @@ -1889,7 +1889,7 @@ def inboxAfterCapabilities(recentPostsCache: {},maxRecentPosts: int, \ # if the votes on a question have changed then send out an update questionJson['type']='Update' sendToFollowersThread(session,baseDir, \ - nickname,domain,port, \ + nickname,domain,onionDomain,port, \ httpPrefix,federationList, \ sendThreads,postLog, \ cachedWebfingers,personCache, \ diff --git a/outbox.py b/outbox.py index 4ca6b3af..6878b35b 100644 --- a/outbox.py +++ b/outbox.py @@ -218,7 +218,7 @@ def postMessageToOutbox(messageJson: {},postToNickname: str, \ sendToFollowersThread(server.session, \ baseDir, \ postToNickname, \ - domain, \ + domain,onionDomain, \ port, \ httpPrefix, \ federationList, \ diff --git a/posts.py b/posts.py index 63af3b60..fed36e81 100644 --- a/posts.py +++ b/posts.py @@ -1841,7 +1841,8 @@ def hasSharedInbox(session,httpPrefix: str,domain: str) -> bool: return False def sendToFollowers(session,baseDir: str, \ - nickname: str, domain: str, port: int, \ + nickname: str, \ + domain: str,onionDomain: str,port: int, \ httpPrefix: str,federationList: [], \ sendThreads: [],postLog: [], \ cachedWebfingers: {},personCache: {}, \ @@ -1892,6 +1893,15 @@ def sendToFollowers(session,baseDir: str, \ cc='' + # if we are sending to an onion domain and we + # have an alt onion domain then use the alt + fromDomain=domain + fromHttpPrefix=httpPrefix + if onionDomain: + if toDomain.endswidth('.onion'): + fromDomain=onionDomain + fromHttpPrefix='http' + if withSharedInbox: toNickname=followerHandles[index].split('@')[0] @@ -1915,10 +1925,11 @@ def sendToFollowers(session,baseDir: str, \ if debug: print('DEBUG: Sending from '+nickname+'@'+domain+ \ ' to '+toNickname+'@'+toDomain) + sendSignedJson(postJsonObject,session,baseDir, \ - nickname,domain,port, \ + nickname,fromDomain,port, \ toNickname,toDomain,toPort, \ - cc,httpPrefix,True,clientToServer, \ + cc,fromHttpPrefix,True,clientToServer, \ federationList, \ sendThreads,postLog,cachedWebfingers, \ personCache,debug,projectVersion) @@ -1940,9 +1951,9 @@ def sendToFollowers(session,baseDir: str, \ toNickname+'@'+toDomain) sendSignedJson(postJsonObject,session,baseDir, \ - nickname,domain,port, \ + nickname,fromDomain,port, \ toNickname,toDomain,toPort, \ - cc,httpPrefix,True,clientToServer, \ + cc,fromHttpPrefix,True,clientToServer, \ federationList, \ sendThreads,postLog,cachedWebfingers, \ personCache,debug,projectVersion) @@ -1953,7 +1964,8 @@ def sendToFollowers(session,baseDir: str, \ print('DEBUG: End of sendToFollowers') def sendToFollowersThread(session,baseDir: str, \ - nickname: str,domain: str,port: int, \ + nickname: str, \ + domain: str,onionDomain: str,port: int, \ httpPrefix: str,federationList: [], \ sendThreads: [],postLog: [], \ cachedWebfingers: {},personCache: {}, \ @@ -1964,7 +1976,7 @@ def sendToFollowersThread(session,baseDir: str, \ sendThread= \ threadWithTrace(target=sendToFollowers, \ args=(session,baseDir, \ - nickname,domain,port, \ + nickname,domain,onionDomain,port, \ httpPrefix,federationList, \ sendThreads,postLog, \ cachedWebfingers,personCache, \