forked from indymedia/epicyon
Sending to followers thread
parent
0b6c6f16e2
commit
543f0b4d7d
32
daemon.py
32
daemon.py
|
@ -34,7 +34,7 @@ from person import removeAccount
|
|||
from person import canRemovePost
|
||||
from posts import outboxMessageCreateWrap
|
||||
from posts import savePostToBox
|
||||
from posts import sendToFollowers
|
||||
from posts import sendToFollowersThread
|
||||
from posts import postIsAddressedToPublic
|
||||
from posts import sendToNamedAddresses
|
||||
from posts import createPublicPost
|
||||
|
@ -468,17 +468,23 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
createSession(self.server.domain,self.server.port,self.server.useTor)
|
||||
if self.server.debug:
|
||||
print('DEBUG: sending c2s post to followers')
|
||||
sendToFollowers(self.server.session,self.server.baseDir, \
|
||||
self.postToNickname,self.server.domain, \
|
||||
self.server.port, \
|
||||
self.server.httpPrefix, \
|
||||
self.server.federationList, \
|
||||
self.server.sendThreads, \
|
||||
self.server.postLog, \
|
||||
self.server.cachedWebfingers, \
|
||||
self.server.personCache, \
|
||||
messageJson,self.server.debug, \
|
||||
self.server.projectVersion)
|
||||
followersThread=sendToFollowersThread(self.server.session, \
|
||||
self.server.baseDir, \
|
||||
self.postToNickname, \
|
||||
self.server.domain, \
|
||||
self.server.port, \
|
||||
self.server.httpPrefix, \
|
||||
self.server.federationList, \
|
||||
self.server.sendThreads, \
|
||||
self.server.postLog, \
|
||||
self.server.cachedWebfingers, \
|
||||
self.server.personCache, \
|
||||
messageJson,self.server.debug, \
|
||||
self.server.projectVersion)
|
||||
self.server.followersThreads.append(followersThread)
|
||||
# retain up to 10 threads
|
||||
if len(self.server.followersThreads)>10:
|
||||
self.server.followersThreads.pop(0)
|
||||
if self.server.debug:
|
||||
print('DEBUG: handle any unfollow requests')
|
||||
outboxUndoFollow(self.server.baseDir,messageJson,self.server.debug)
|
||||
|
@ -4449,6 +4455,8 @@ def runDaemon(projectVersion, \
|
|||
loadTokens(baseDir,httpd.tokens,httpd.tokensLookup)
|
||||
httpd.instanceOnlySkillsSearch=instanceOnlySkillsSearch
|
||||
httpd.acceptedCaps=["inbox:write","objects:read"]
|
||||
# contains threads used to send posts to followers
|
||||
httpd.followersThreads=[]
|
||||
if noreply:
|
||||
httpd.acceptedCaps.append('inbox:noreply')
|
||||
if nolike:
|
||||
|
|
26
posts.py
26
posts.py
|
@ -1620,7 +1620,7 @@ def hasSharedInbox(session,httpPrefix: str,domain: str) -> bool:
|
|||
if not wfRequest.get('errors'):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def sendToFollowers(session,baseDir: str, \
|
||||
nickname: str, domain: str, port: int, \
|
||||
httpPrefix: str,federationList: [], \
|
||||
|
@ -1654,7 +1654,6 @@ def sendToFollowers(session,baseDir: str, \
|
|||
|
||||
# for each instance
|
||||
for followerDomain,followerHandles in grouped.items():
|
||||
time.sleep(4)
|
||||
if debug:
|
||||
print('DEBUG: follower handles for '+followerDomain)
|
||||
pprint(followerHandles)
|
||||
|
@ -1720,7 +1719,28 @@ def sendToFollowers(session,baseDir: str, \
|
|||
|
||||
if debug:
|
||||
print('DEBUG: End of sendToFollowers')
|
||||
|
||||
time.sleep(4)
|
||||
|
||||
def sendToFollowersThread(session,baseDir: str, \
|
||||
nickname: str, domain: str, port: int, \
|
||||
httpPrefix: str,federationList: [], \
|
||||
sendThreads: [],postLog: [], \
|
||||
cachedWebfingers: {},personCache: {}, \
|
||||
postJsonObject: {},debug: bool, \
|
||||
projectVersion: str):
|
||||
"""Returns a thread used to send a post to followers
|
||||
"""
|
||||
sendThread= \
|
||||
threadWithTrace(target=sendToFollowers, \
|
||||
args=(session,baseDir, \
|
||||
nickname,domain,port, \
|
||||
httpPrefix,federationList, \
|
||||
sendThreads,postLog, \
|
||||
cachedWebfingers,personCache, \
|
||||
postJsonObject.copy(),debug, \
|
||||
projectVersion),daemon=True)
|
||||
sendThread.start()
|
||||
return sendThread
|
||||
|
||||
def createInbox(session,baseDir: str,nickname: str,domain: str,port: int,httpPrefix: str, \
|
||||
itemsPerPage: int,headerOnly: bool,ocapAlways: bool,pageNumber=None) -> {}:
|
||||
|
|
Loading…
Reference in New Issue