mirror of https://gitlab.com/bashrc2/epicyon
Maximum replies per post
parent
7ed36fa9d5
commit
7105c0cd79
|
@ -661,7 +661,7 @@ def runDaemon(clientToServer: bool,baseDir: str,domain: str, \
|
|||
port=80,httpPrefix='https', \
|
||||
fedList=[],noreply=False,nolike=False,nopics=False, \
|
||||
noannounce=False,cw=False,ocapAlways=False, \
|
||||
useTor=False,debug=False) -> None:
|
||||
useTor=False,maxReplies=64,debug=False) -> None:
|
||||
if len(domain)==0:
|
||||
domain='localhost'
|
||||
if '.' not in domain:
|
||||
|
@ -713,7 +713,7 @@ def runDaemon(clientToServer: bool,baseDir: str,domain: str, \
|
|||
httpd.postLog,httpd.cachedWebfingers, \
|
||||
httpd.personCache,httpd.inboxQueue, \
|
||||
domain,port,useTor,httpd.federationList, \
|
||||
httpd.ocapAlways, \
|
||||
httpd.ocapAlways,maxReplies, \
|
||||
debug,httpd.acceptedCaps),daemon=True)
|
||||
httpd.thrInboxQueue.start()
|
||||
if clientToServer:
|
||||
|
|
|
@ -169,6 +169,8 @@ parser.add_argument("--followersonly", type=str2bool, nargs='?', \
|
|||
parser.add_argument("-c","--client", type=str2bool, nargs='?', \
|
||||
const=True, default=False, \
|
||||
help="Use as an ActivityPub client")
|
||||
parser.add_argument('--maxreplies', dest='maxReplies', type=int,default=64, \
|
||||
help='Maximum number of replies to a post')
|
||||
args = parser.parse_args()
|
||||
|
||||
debug=False
|
||||
|
@ -555,4 +557,5 @@ if args.testdata:
|
|||
runDaemon(args.client,baseDir,domain,port,httpPrefix, \
|
||||
federationList, \
|
||||
args.noreply,args.nolike,args.nopics, \
|
||||
args.noannounce,args.cw,ocapAlways,useTor,debug)
|
||||
args.noannounce,args.cw,ocapAlways, \
|
||||
useTor,args.maxReplies,debug)
|
||||
|
|
18
inbox.py
18
inbox.py
|
@ -636,7 +636,7 @@ def receiveUndoAnnounce(session,handle: str,baseDir: str, \
|
|||
return True
|
||||
|
||||
def populateReplies(baseDir :str,httpPrefix :str,domain :str, \
|
||||
messageJson :{},debug :bool) -> bool:
|
||||
messageJson :{},maxReplies: int,debug :bool) -> bool:
|
||||
"""Updates the list of replies for a post on this domain if
|
||||
a reply to it arrives
|
||||
"""
|
||||
|
@ -677,6 +677,9 @@ def populateReplies(baseDir :str,httpPrefix :str,domain :str, \
|
|||
postRepliesFilename=postFilename.replace('.json','.replies')
|
||||
messageId=messageJson['id'].replace('/activity','')
|
||||
if os.path.isfile(postRepliesFilename):
|
||||
numLines = sum(1 for line in open(postRepliesFilename))
|
||||
if numlines>maxReplies:
|
||||
return False
|
||||
if messageId not in open(postRepliesFilename).read():
|
||||
repliesFile=open(postRepliesFilename, "a")
|
||||
repliesFile.write(messageId+'\n')
|
||||
|
@ -693,7 +696,8 @@ def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \
|
|||
queue: [],domain: str,port: int,useTor: bool, \
|
||||
federationList: [],ocapAlways: bool,debug: bool, \
|
||||
acceptedCaps: [],
|
||||
queueFilename :str,destinationFilename :str) -> bool:
|
||||
queueFilename :str,destinationFilename :str,
|
||||
maxReplies: int) -> bool:
|
||||
""" Anything which needs to be done after capabilities checks have passed
|
||||
"""
|
||||
if receiveLike(session,handle, \
|
||||
|
@ -760,7 +764,7 @@ def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \
|
|||
print('DEBUG: Delete accepted from '+keyId)
|
||||
return False
|
||||
|
||||
populateReplies(baseDir,httpPrefix,domain,messageJson,debug)
|
||||
populateReplies(baseDir,httpPrefix,domain,messageJson,maxReplies,debug)
|
||||
|
||||
if debug:
|
||||
print('DEBUG: object capabilities passed')
|
||||
|
@ -783,7 +787,7 @@ def restoreQueueItems(baseDir: str,queue: []) -> None:
|
|||
def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \
|
||||
cachedWebfingers: {},personCache: {},queue: [], \
|
||||
domain: str,port: int,useTor: bool,federationList: [], \
|
||||
ocapAlways: bool,debug: bool, \
|
||||
ocapAlways: bool,maxReplies: int,debug: bool, \
|
||||
acceptedCaps=["inbox:write","objects:read"]) -> None:
|
||||
"""Processes received items and moves them to
|
||||
the appropriate directories
|
||||
|
@ -983,7 +987,8 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \
|
|||
port,useTor, \
|
||||
federationList,ocapAlways, \
|
||||
debug,acceptedCaps, \
|
||||
queueFilename,destination)
|
||||
queueFilename,destination, \
|
||||
maxReplies)
|
||||
else:
|
||||
if debug:
|
||||
print('DEBUG: object capabilities check failed')
|
||||
|
@ -999,7 +1004,8 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \
|
|||
port,useTor, \
|
||||
federationList,ocapAlways, \
|
||||
debug,acceptedCaps, \
|
||||
queueFilename,destination)
|
||||
queueFilename,destination, \
|
||||
maxReplies)
|
||||
if debug:
|
||||
print('DEBUG: object capabilities check failed')
|
||||
|
||||
|
|
12
tests.py
12
tests.py
|
@ -142,6 +142,7 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [], \
|
|||
noannounce=False
|
||||
cw=False
|
||||
useBlurhash=True
|
||||
maxReplies=64
|
||||
privateKeyPem,publicKeyPem,person,wfEndpoint= \
|
||||
createPerson(path,nickname,domain,port,httpPrefix,True,password)
|
||||
deleteAllPosts(path,nickname,domain,'inbox')
|
||||
|
@ -165,7 +166,8 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [], \
|
|||
testServerAliceRunning = True
|
||||
print('Server running: Alice')
|
||||
runDaemon(False,path,domain,port,httpPrefix,federationList, \
|
||||
noreply,nolike,nopics,noannounce,cw,ocapAlways,useTor,True)
|
||||
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
|
||||
useTor,maxReplies,True)
|
||||
|
||||
def createServerBob(path: str,domain: str,port: int,federationList: [], \
|
||||
hasFollows: bool,hasPosts :bool,ocapAlways :bool):
|
||||
|
@ -185,6 +187,7 @@ def createServerBob(path: str,domain: str,port: int,federationList: [], \
|
|||
noannounce=False
|
||||
cw=False
|
||||
useBlurhash=False
|
||||
maxReplies=64
|
||||
privateKeyPem,publicKeyPem,person,wfEndpoint= \
|
||||
createPerson(path,nickname,domain,port,httpPrefix,True,password)
|
||||
deleteAllPosts(path,nickname,domain,'inbox')
|
||||
|
@ -208,7 +211,8 @@ def createServerBob(path: str,domain: str,port: int,federationList: [], \
|
|||
testServerBobRunning = True
|
||||
print('Server running: Bob')
|
||||
runDaemon(False,path,domain,port,httpPrefix,federationList, \
|
||||
noreply,nolike,nopics,noannounce,cw,ocapAlways,useTor,True)
|
||||
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
|
||||
useTor,maxReplies,True)
|
||||
|
||||
def createServerEve(path: str,domain: str,port: int,federationList: [], \
|
||||
hasFollows: bool,hasPosts :bool,ocapAlways :bool):
|
||||
|
@ -227,6 +231,7 @@ def createServerEve(path: str,domain: str,port: int,federationList: [], \
|
|||
nopics=False
|
||||
noannounce=False
|
||||
cw=False
|
||||
maxReplies=64
|
||||
privateKeyPem,publicKeyPem,person,wfEndpoint= \
|
||||
createPerson(path,nickname,domain,port,httpPrefix,True,password)
|
||||
deleteAllPosts(path,nickname,domain,'inbox')
|
||||
|
@ -235,7 +240,8 @@ def createServerEve(path: str,domain: str,port: int,federationList: [], \
|
|||
testServerEveRunning = True
|
||||
print('Server running: Eve')
|
||||
runDaemon(False,path,domain,port,httpPrefix,federationList, \
|
||||
noreply,nolike,nopics,noannounce,cw,ocapAlways,useTor,True)
|
||||
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
|
||||
useTor,maxReplies,True)
|
||||
|
||||
def testPostMessageBetweenServers():
|
||||
print('Testing sending message from one server to the inbox of another')
|
||||
|
|
Loading…
Reference in New Issue