mirror of https://gitlab.com/bashrc2/epicyon
Threaded sending to named addresses
parent
d43715ab07
commit
50796afb3c
32
outbox.py
32
outbox.py
|
@ -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,18 +627,20 @@ 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 = \
|
||||||
postToNickname,
|
sendToNamedAddressesThread(server.session, baseDir,
|
||||||
domain, onionDomain, i2pDomain, port,
|
postToNickname,
|
||||||
httpPrefix,
|
domain, onionDomain, i2pDomain, port,
|
||||||
federationList,
|
httpPrefix,
|
||||||
sendThreads,
|
federationList,
|
||||||
postLog,
|
sendThreads,
|
||||||
cachedWebfingers,
|
postLog,
|
||||||
personCache,
|
cachedWebfingers,
|
||||||
messageJson, debug,
|
personCache,
|
||||||
version,
|
messageJson, debug,
|
||||||
sharedItemsFederatedDomains,
|
version,
|
||||||
sharedItemFederationTokens,
|
sharedItemsFederatedDomains,
|
||||||
signingPrivateKeyPem)
|
sharedItemFederationTokens,
|
||||||
|
signingPrivateKeyPem)
|
||||||
|
followersThreads.append(namedAddressesThread)
|
||||||
return True
|
return True
|
||||||
|
|
61
posts.py
61
posts.py
|
@ -2734,17 +2734,17 @@ 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: [],
|
||||||
sendThreads: [], postLog: [],
|
sendThreads: [], postLog: [],
|
||||||
cachedWebfingers: {}, personCache: {},
|
cachedWebfingers: {}, personCache: {},
|
||||||
postJsonObject: {}, debug: bool,
|
postJsonObject: {}, debug: bool,
|
||||||
projectVersion: str,
|
projectVersion: str,
|
||||||
sharedItemsFederatedDomains: [],
|
sharedItemsFederatedDomains: [],
|
||||||
sharedItemFederationTokens: {},
|
sharedItemFederationTokens: {},
|
||||||
signingPrivateKeyPem: str) -> None:
|
signingPrivateKeyPem: str) -> None:
|
||||||
"""sends a post to the specific named addresses in to/cc
|
"""sends a post to the specific named addresses in to/cc
|
||||||
"""
|
"""
|
||||||
if not session:
|
if not session:
|
||||||
|
@ -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