Sending to followers on onion domains

main
Bob Mottram 2020-03-02 16:23:30 +00:00
parent 63a5c76cbe
commit 3fe3dd06a9
3 changed files with 21 additions and 9 deletions

View File

@ -1889,7 +1889,7 @@ def inboxAfterCapabilities(recentPostsCache: {},maxRecentPosts: int, \
# if the votes on a question have changed then send out an update # if the votes on a question have changed then send out an update
questionJson['type']='Update' questionJson['type']='Update'
sendToFollowersThread(session,baseDir, \ sendToFollowersThread(session,baseDir, \
nickname,domain,port, \ nickname,domain,onionDomain,port, \
httpPrefix,federationList, \ httpPrefix,federationList, \
sendThreads,postLog, \ sendThreads,postLog, \
cachedWebfingers,personCache, \ cachedWebfingers,personCache, \

View File

@ -218,7 +218,7 @@ def postMessageToOutbox(messageJson: {},postToNickname: str, \
sendToFollowersThread(server.session, \ sendToFollowersThread(server.session, \
baseDir, \ baseDir, \
postToNickname, \ postToNickname, \
domain, \ domain,onionDomain, \
port, \ port, \
httpPrefix, \ httpPrefix, \
federationList, \ federationList, \

View File

@ -1841,7 +1841,8 @@ def hasSharedInbox(session,httpPrefix: str,domain: str) -> bool:
return False return False
def sendToFollowers(session,baseDir: str, \ def sendToFollowers(session,baseDir: str, \
nickname: str, domain: str, port: int, \ nickname: str, \
domain: str,onionDomain: str,port: int, \
httpPrefix: str,federationList: [], \ httpPrefix: str,federationList: [], \
sendThreads: [],postLog: [], \ sendThreads: [],postLog: [], \
cachedWebfingers: {},personCache: {}, \ cachedWebfingers: {},personCache: {}, \
@ -1892,6 +1893,15 @@ def sendToFollowers(session,baseDir: str, \
cc='' 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: if withSharedInbox:
toNickname=followerHandles[index].split('@')[0] toNickname=followerHandles[index].split('@')[0]
@ -1915,10 +1925,11 @@ def sendToFollowers(session,baseDir: str, \
if debug: if debug:
print('DEBUG: Sending from '+nickname+'@'+domain+ \ print('DEBUG: Sending from '+nickname+'@'+domain+ \
' to '+toNickname+'@'+toDomain) ' to '+toNickname+'@'+toDomain)
sendSignedJson(postJsonObject,session,baseDir, \ sendSignedJson(postJsonObject,session,baseDir, \
nickname,domain,port, \ nickname,fromDomain,port, \
toNickname,toDomain,toPort, \ toNickname,toDomain,toPort, \
cc,httpPrefix,True,clientToServer, \ cc,fromHttpPrefix,True,clientToServer, \
federationList, \ federationList, \
sendThreads,postLog,cachedWebfingers, \ sendThreads,postLog,cachedWebfingers, \
personCache,debug,projectVersion) personCache,debug,projectVersion)
@ -1940,9 +1951,9 @@ def sendToFollowers(session,baseDir: str, \
toNickname+'@'+toDomain) toNickname+'@'+toDomain)
sendSignedJson(postJsonObject,session,baseDir, \ sendSignedJson(postJsonObject,session,baseDir, \
nickname,domain,port, \ nickname,fromDomain,port, \
toNickname,toDomain,toPort, \ toNickname,toDomain,toPort, \
cc,httpPrefix,True,clientToServer, \ cc,fromHttpPrefix,True,clientToServer, \
federationList, \ federationList, \
sendThreads,postLog,cachedWebfingers, \ sendThreads,postLog,cachedWebfingers, \
personCache,debug,projectVersion) personCache,debug,projectVersion)
@ -1953,7 +1964,8 @@ def sendToFollowers(session,baseDir: str, \
print('DEBUG: End of sendToFollowers') print('DEBUG: End of sendToFollowers')
def sendToFollowersThread(session,baseDir: str, \ def sendToFollowersThread(session,baseDir: str, \
nickname: str,domain: str,port: int, \ nickname: str, \
domain: str,onionDomain: str,port: int, \
httpPrefix: str,federationList: [], \ httpPrefix: str,federationList: [], \
sendThreads: [],postLog: [], \ sendThreads: [],postLog: [], \
cachedWebfingers: {},personCache: {}, \ cachedWebfingers: {},personCache: {}, \
@ -1964,7 +1976,7 @@ def sendToFollowersThread(session,baseDir: str, \
sendThread= \ sendThread= \
threadWithTrace(target=sendToFollowers, \ threadWithTrace(target=sendToFollowers, \
args=(session,baseDir, \ args=(session,baseDir, \
nickname,domain,port, \ nickname,domain,onionDomain,port, \
httpPrefix,federationList, \ httpPrefix,federationList, \
sendThreads,postLog, \ sendThreads,postLog, \
cachedWebfingers,personCache, \ cachedWebfingers,personCache, \