mirror of https://gitlab.com/bashrc2/epicyon
Threaded sending to named addresses
parent
d43715ab07
commit
50796afb3c
|
@ -15,7 +15,7 @@ from posts import isImageMedia
|
||||||
from posts import outboxMessageCreateWrap
|
from posts import outboxMessageCreateWrap
|
||||||
from posts import savePostToBox
|
from posts import savePostToBox
|
||||||
from posts import sendToFollowersThread
|
from posts import sendToFollowersThread
|
||||||
from posts import sendToNamedAddresses
|
from posts import sendToNamedAddressesThread
|
||||||
from utils import hasObjectStringType
|
from utils import hasObjectStringType
|
||||||
from utils import getBaseContentFromPost
|
from utils import getBaseContentFromPost
|
||||||
from utils import hasObjectDict
|
from utils import hasObjectDict
|
||||||
|
@ -627,7 +627,8 @@ def postMessageToOutbox(session, translate: {},
|
||||||
else:
|
else:
|
||||||
print('c2s sender: ' +
|
print('c2s sender: ' +
|
||||||
postToNickname + '@' + domain + ':' + str(port))
|
postToNickname + '@' + domain + ':' + str(port))
|
||||||
sendToNamedAddresses(server.session, baseDir,
|
namedAddressesThread = \
|
||||||
|
sendToNamedAddressesThread(server.session, baseDir,
|
||||||
postToNickname,
|
postToNickname,
|
||||||
domain, onionDomain, i2pDomain, port,
|
domain, onionDomain, i2pDomain, port,
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
|
@ -641,4 +642,5 @@ def postMessageToOutbox(session, translate: {},
|
||||||
sharedItemsFederatedDomains,
|
sharedItemsFederatedDomains,
|
||||||
sharedItemFederationTokens,
|
sharedItemFederationTokens,
|
||||||
signingPrivateKeyPem)
|
signingPrivateKeyPem)
|
||||||
|
followersThreads.append(namedAddressesThread)
|
||||||
return True
|
return True
|
||||||
|
|
41
posts.py
41
posts.py
|
@ -2734,7 +2734,7 @@ def _isProfileUpdate(postJsonObject: {}) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def sendToNamedAddresses(session, baseDir: str,
|
def _sendToNamedAddresses(session, baseDir: str,
|
||||||
nickname: str, domain: str,
|
nickname: str, domain: str,
|
||||||
onionDomain: str, i2pDomain: str, port: int,
|
onionDomain: str, i2pDomain: str, port: int,
|
||||||
httpPrefix: str, federationList: [],
|
httpPrefix: str, federationList: [],
|
||||||
|
@ -2885,6 +2885,45 @@ def sendToNamedAddresses(session, baseDir: str,
|
||||||
signingPrivateKeyPem, 34436782)
|
signingPrivateKeyPem, 34436782)
|
||||||
|
|
||||||
|
|
||||||
|
def sendToNamedAddressesThread(session, baseDir: str,
|
||||||
|
nickname: str, domain: str,
|
||||||
|
onionDomain: str, i2pDomain: str, port: int,
|
||||||
|
httpPrefix: str, federationList: [],
|
||||||
|
sendThreads: [], postLog: [],
|
||||||
|
cachedWebfingers: {}, personCache: {},
|
||||||
|
postJsonObject: {}, debug: bool,
|
||||||
|
projectVersion: str,
|
||||||
|
sharedItemsFederatedDomains: [],
|
||||||
|
sharedItemFederationTokens: {},
|
||||||
|
signingPrivateKeyPem: str):
|
||||||
|
"""Returns a thread used to send a post to named addresses
|
||||||
|
"""
|
||||||
|
sendThread = \
|
||||||
|
threadWithTrace(target=_sendToNamedAddresses,
|
||||||
|
args=(session, baseDir,
|
||||||
|
nickname, domain,
|
||||||
|
onionDomain, i2pDomain, port,
|
||||||
|
httpPrefix, federationList,
|
||||||
|
sendThreads, postLog,
|
||||||
|
cachedWebfingers, personCache,
|
||||||
|
postJsonObject, debug,
|
||||||
|
projectVersion,
|
||||||
|
sharedItemsFederatedDomains,
|
||||||
|
sharedItemFederationTokens,
|
||||||
|
signingPrivateKeyPem), daemon=True)
|
||||||
|
try:
|
||||||
|
sendThread.start()
|
||||||
|
except SocketError as e:
|
||||||
|
print('WARN: socket error while starting ' +
|
||||||
|
'thread to send to named addresses. ' + str(e))
|
||||||
|
return None
|
||||||
|
except ValueError as e:
|
||||||
|
print('WARN: error while starting ' +
|
||||||
|
'thread to send to named addresses. ' + str(e))
|
||||||
|
return None
|
||||||
|
return sendThread
|
||||||
|
|
||||||
|
|
||||||
def _hasSharedInbox(session, httpPrefix: str, domain: str,
|
def _hasSharedInbox(session, httpPrefix: str, domain: str,
|
||||||
debug: bool, signingPrivateKeyPem: str) -> bool:
|
debug: bool, signingPrivateKeyPem: str) -> bool:
|
||||||
"""Returns true if the given domain has a shared inbox
|
"""Returns true if the given domain has a shared inbox
|
||||||
|
|
Loading…
Reference in New Issue