From a671ceb9521877b98fe576d84bb3fdadb4eec316 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 9 Jul 2019 19:11:23 +0100 Subject: [PATCH] Etra default capabilities --- daemon.py | 9 ++++++++- epicyon.py | 13 ++++++++++++- tests.py | 15 ++++++++++++--- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/daemon.py b/daemon.py index 3c9dafa5..db53ee92 100644 --- a/daemon.py +++ b/daemon.py @@ -497,7 +497,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.POSTbusy=False def runDaemon(baseDir: str,domain: str,port=80,httpPrefix='https', \ - fedList=[],noreply=False,nolike=False,ocapAlways=False, \ + fedList=[],noreply=False,nolike=False,nopics=False, \ + noannounce=False,cw=False,ocapAlways=False, \ useTor=False,debug=False) -> None: if len(domain)==0: domain='localhost' @@ -533,6 +534,12 @@ def runDaemon(baseDir: str,domain: str,port=80,httpPrefix='https', \ httpd.acceptedCaps.append('inbox:noreply') if nolike: httpd.acceptedCaps.append('inbox:nolike') + if nopics: + httpd.acceptedCaps.append('inbox:nopics') + if noannounce: + httpd.acceptedCaps.append('inbox:noannounce') + if cw: + httpd.acceptedCaps.append('inbox:cw') print('Running ActivityPub daemon on ' + domain + ' port ' + str(port)) httpd.thrInboxQueue= \ threadWithTrace(target=runInboxQueue, \ diff --git a/epicyon.py b/epicyon.py index 3b86c920..fe038dac 100644 --- a/epicyon.py +++ b/epicyon.py @@ -123,6 +123,15 @@ parser.add_argument("--noreply", type=str2bool, nargs='?', \ parser.add_argument("--nolike", type=str2bool, nargs='?', \ const=True, default=False, \ help="Default capabilities don't allow likes/favourites on posts") +parser.add_argument("--nopics", type=str2bool, nargs='?', \ + const=True, default=False, \ + help="Default capabilities don't allow attached pictures") +parser.add_argument("--noannounce","--norepeat", type=str2bool, nargs='?', \ + const=True, default=False, \ + help="Default capabilities don't allow announce/repeat") +parser.add_argument("--cw", type=str2bool, nargs='?', \ + const=True, default=False, \ + help="Default capabilities don't allow posts without content warnings") args = parser.parse_args() debug=False @@ -416,4 +425,6 @@ if args.testdata: createPublicPost(baseDir,nickname,domain,port,httpPrefix,"another mystery solved hey",False,True,False) createPublicPost(baseDir,nickname,domain,port,httpPrefix,"let's go bowling",False,True,False) -runDaemon(baseDir,domain,port,httpPrefix,federationList,args.noreply,args.nolike,ocapAlways,useTor,debug) +runDaemon(baseDir,domain,port,httpPrefix,federationList, \ + args.noreply,args.nolike,args.nopics, \ + args.noannounce,args.cw,ocapAlways,useTor,debug) diff --git a/tests.py b/tests.py index db05bcf8..b647cf43 100644 --- a/tests.py +++ b/tests.py @@ -127,6 +127,9 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [],hasFoll password='alicepass' noreply=False nolike=False + nopics=False + noannounce=False + cw=False privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(path,nickname,domain,port,httpPrefix,True,password) deleteAllPosts(path,nickname,domain,'inbox') deleteAllPosts(path,nickname,domain,'outbox') @@ -140,7 +143,7 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [],hasFoll global testServerAliceRunning testServerAliceRunning = True print('Server running: Alice') - runDaemon(path,domain,port,httpPrefix,federationList,noreply,nolike,ocapAlways,useTor,True) + runDaemon(path,domain,port,httpPrefix,federationList,noreply,nolike,nopics,noannounce,cw,ocapAlways,useTor,True) def createServerBob(path: str,domain: str,port: int,federationList: [],hasFollows: bool,hasPosts :bool,ocapAlways :bool): print('Creating test server: Bob on port '+str(port)) @@ -155,6 +158,9 @@ def createServerBob(path: str,domain: str,port: int,federationList: [],hasFollow password='bobpass' noreply=False nolike=False + nopics=False + noannounce=False + cw=False privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(path,nickname,domain,port,httpPrefix,True,password) deleteAllPosts(path,nickname,domain,'inbox') deleteAllPosts(path,nickname,domain,'outbox') @@ -168,7 +174,7 @@ def createServerBob(path: str,domain: str,port: int,federationList: [],hasFollow global testServerBobRunning testServerBobRunning = True print('Server running: Bob') - runDaemon(path,domain,port,httpPrefix,federationList,noreply,nolike,ocapAlways,useTor,True) + runDaemon(path,domain,port,httpPrefix,federationList,noreply,nolike,nopics,noannounce,cw,ocapAlways,useTor,True) def createServerEve(path: str,domain: str,port: int,federationList: [],hasFollows: bool,hasPosts :bool,ocapAlways :bool): print('Creating test server: Eve on port '+str(port)) @@ -183,13 +189,16 @@ def createServerEve(path: str,domain: str,port: int,federationList: [],hasFollow password='evepass' noreply=False nolike=False + nopics=False + noannounce=False + cw=False privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(path,nickname,domain,port,httpPrefix,True,password) deleteAllPosts(path,nickname,domain,'inbox') deleteAllPosts(path,nickname,domain,'outbox') global testServerEveRunning testServerEveRunning = True print('Server running: Eve') - runDaemon(path,domain,port,httpPrefix,federationList,noreply,nolike,ocapAlways,useTor,True) + runDaemon(path,domain,port,httpPrefix,federationList,noreply,nolike,nopics,noannounce,cw,ocapAlways,useTor,True) def testPostMessageBetweenServers(): print('Testing sending message from one server to the inbox of another')