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 person import canRemovePost
|
||||||
from posts import outboxMessageCreateWrap
|
from posts import outboxMessageCreateWrap
|
||||||
from posts import savePostToBox
|
from posts import savePostToBox
|
||||||
from posts import sendToFollowers
|
from posts import sendToFollowersThread
|
||||||
from posts import postIsAddressedToPublic
|
from posts import postIsAddressedToPublic
|
||||||
from posts import sendToNamedAddresses
|
from posts import sendToNamedAddresses
|
||||||
from posts import createPublicPost
|
from posts import createPublicPost
|
||||||
|
@ -468,17 +468,23 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
createSession(self.server.domain,self.server.port,self.server.useTor)
|
createSession(self.server.domain,self.server.port,self.server.useTor)
|
||||||
if self.server.debug:
|
if self.server.debug:
|
||||||
print('DEBUG: sending c2s post to followers')
|
print('DEBUG: sending c2s post to followers')
|
||||||
sendToFollowers(self.server.session,self.server.baseDir, \
|
followersThread=sendToFollowersThread(self.server.session, \
|
||||||
self.postToNickname,self.server.domain, \
|
self.server.baseDir, \
|
||||||
self.server.port, \
|
self.postToNickname, \
|
||||||
self.server.httpPrefix, \
|
self.server.domain, \
|
||||||
self.server.federationList, \
|
self.server.port, \
|
||||||
self.server.sendThreads, \
|
self.server.httpPrefix, \
|
||||||
self.server.postLog, \
|
self.server.federationList, \
|
||||||
self.server.cachedWebfingers, \
|
self.server.sendThreads, \
|
||||||
self.server.personCache, \
|
self.server.postLog, \
|
||||||
messageJson,self.server.debug, \
|
self.server.cachedWebfingers, \
|
||||||
self.server.projectVersion)
|
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:
|
if self.server.debug:
|
||||||
print('DEBUG: handle any unfollow requests')
|
print('DEBUG: handle any unfollow requests')
|
||||||
outboxUndoFollow(self.server.baseDir,messageJson,self.server.debug)
|
outboxUndoFollow(self.server.baseDir,messageJson,self.server.debug)
|
||||||
|
@ -4449,6 +4455,8 @@ def runDaemon(projectVersion, \
|
||||||
loadTokens(baseDir,httpd.tokens,httpd.tokensLookup)
|
loadTokens(baseDir,httpd.tokens,httpd.tokensLookup)
|
||||||
httpd.instanceOnlySkillsSearch=instanceOnlySkillsSearch
|
httpd.instanceOnlySkillsSearch=instanceOnlySkillsSearch
|
||||||
httpd.acceptedCaps=["inbox:write","objects:read"]
|
httpd.acceptedCaps=["inbox:write","objects:read"]
|
||||||
|
# contains threads used to send posts to followers
|
||||||
|
httpd.followersThreads=[]
|
||||||
if noreply:
|
if noreply:
|
||||||
httpd.acceptedCaps.append('inbox:noreply')
|
httpd.acceptedCaps.append('inbox:noreply')
|
||||||
if nolike:
|
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'):
|
if not wfRequest.get('errors'):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def sendToFollowers(session,baseDir: str, \
|
def sendToFollowers(session,baseDir: str, \
|
||||||
nickname: str, domain: str, port: int, \
|
nickname: str, domain: str, port: int, \
|
||||||
httpPrefix: str,federationList: [], \
|
httpPrefix: str,federationList: [], \
|
||||||
|
@ -1654,7 +1654,6 @@ def sendToFollowers(session,baseDir: str, \
|
||||||
|
|
||||||
# for each instance
|
# for each instance
|
||||||
for followerDomain,followerHandles in grouped.items():
|
for followerDomain,followerHandles in grouped.items():
|
||||||
time.sleep(4)
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: follower handles for '+followerDomain)
|
print('DEBUG: follower handles for '+followerDomain)
|
||||||
pprint(followerHandles)
|
pprint(followerHandles)
|
||||||
|
@ -1720,7 +1719,28 @@ def sendToFollowers(session,baseDir: str, \
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: End of sendToFollowers')
|
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, \
|
def createInbox(session,baseDir: str,nickname: str,domain: str,port: int,httpPrefix: str, \
|
||||||
itemsPerPage: int,headerOnly: bool,ocapAlways: bool,pageNumber=None) -> {}:
|
itemsPerPage: int,headerOnly: bool,ocapAlways: bool,pageNumber=None) -> {}:
|
||||||
|
|
Loading…
Reference in New Issue