Etra default capabilities

master
Bob Mottram 2019-07-09 19:11:23 +01:00
parent 21a72b59fc
commit a671ceb952
3 changed files with 32 additions and 5 deletions

View File

@ -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, \

View File

@ -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)

View File

@ -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')