Option to not accept deletions

master
Bob Mottram 2019-07-17 18:44:26 +01:00
parent e2e02cb185
commit 185b9c97c1
4 changed files with 34 additions and 25 deletions

View File

@ -206,6 +206,7 @@ class PubServer(BaseHTTPRequestHandler):
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)
if not self.server.nodeletion:
if self.server.debug: if self.server.debug:
print('DEBUG: handle delete requests') print('DEBUG: handle delete requests')
outboxDelete(self.server.baseDir,self.server.httpPrefix,messageJson,self.server.debug) outboxDelete(self.server.baseDir,self.server.httpPrefix,messageJson,self.server.debug)
@ -812,7 +813,7 @@ def runDaemon(clientToServer: bool,baseDir: str,domain: str, \
noannounce=False,cw=False,ocapAlways=False, \ noannounce=False,cw=False,ocapAlways=False, \
useTor=False,maxReplies=64, \ useTor=False,maxReplies=64, \
domainMaxPostsPerDay=8640,accountMaxPostsPerDay=8640, \ domainMaxPostsPerDay=8640,accountMaxPostsPerDay=8640, \
debug=False) -> None: nodeletion=False,debug=False) -> None:
if len(domain)==0: if len(domain)==0:
domain='localhost' domain='localhost'
if '.' not in domain: if '.' not in domain:
@ -845,6 +846,7 @@ def runDaemon(clientToServer: bool,baseDir: str,domain: str, \
httpd.ocapAlways=ocapAlways httpd.ocapAlways=ocapAlways
httpd.maxMessageLength=5000 httpd.maxMessageLength=5000
httpd.maxImageSize=10*1024*1024 httpd.maxImageSize=10*1024*1024
httpd.nodeletion=nodeletion
httpd.acceptedCaps=["inbox:write","objects:read"] httpd.acceptedCaps=["inbox:write","objects:read"]
if noreply: if noreply:
httpd.acceptedCaps.append('inbox:noreply') httpd.acceptedCaps.append('inbox:noreply')
@ -869,7 +871,7 @@ def runDaemon(clientToServer: bool,baseDir: str,domain: str, \
domain,port,useTor,httpd.federationList, \ domain,port,useTor,httpd.federationList, \
httpd.ocapAlways,maxReplies, \ httpd.ocapAlways,maxReplies, \
domainMaxPostsPerDay,accountMaxPostsPerDay, \ domainMaxPostsPerDay,accountMaxPostsPerDay, \
debug,httpd.acceptedCaps),daemon=True) nodeletion,debug,httpd.acceptedCaps),daemon=True)
httpd.thrInboxQueue.start() httpd.thrInboxQueue.start()
if clientToServer: if clientToServer:
print('Running ActivityPub client on ' + domain + ' port ' + str(port)) print('Running ActivityPub client on ' + domain + ' port ' + str(port))

View File

@ -164,6 +164,9 @@ parser.add_argument('--message', dest='message', type=str,default=None, \
help='Message content') help='Message content')
parser.add_argument('--delete', dest='delete', type=str,default=None, \ parser.add_argument('--delete', dest='delete', type=str,default=None, \
help='Delete a specified post') help='Delete a specified post')
parser.add_argument("--nodeletion", type=str2bool, nargs='?', \
const=True, default=False, \
help="Do not allow deletions")
parser.add_argument('--repeat','--announce', dest='announce', type=str,default=None, \ parser.add_argument('--repeat','--announce', dest='announce', type=str,default=None, \
help='Announce/repeat a url') help='Announce/repeat a url')
parser.add_argument('--sendto', nargs='+',dest='sendto', \ parser.add_argument('--sendto', nargs='+',dest='sendto', \
@ -776,4 +779,4 @@ runDaemon(args.client,baseDir,domain,port,httpPrefix, \
args.noannounce,args.cw,ocapAlways, \ args.noannounce,args.cw,ocapAlways, \
useTor,args.maxReplies, \ useTor,args.maxReplies, \
args.domainMaxPostsPerDay,args.accountMaxPostsPerDay, \ args.domainMaxPostsPerDay,args.accountMaxPostsPerDay, \
debug) args.nodeletion,debug)

View File

@ -823,7 +823,7 @@ def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \
federationList: [],ocapAlways: bool,debug: bool, \ federationList: [],ocapAlways: bool,debug: bool, \
acceptedCaps: [], acceptedCaps: [],
queueFilename :str,destinationFilename :str, queueFilename :str,destinationFilename :str,
maxReplies: int) -> bool: maxReplies: int,nodeletion: bool) -> bool:
""" Anything which needs to be done after capabilities checks have passed """ Anything which needs to be done after capabilities checks have passed
""" """
if receiveLike(session,handle, \ if receiveLike(session,handle, \
@ -877,6 +877,7 @@ def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \
print('DEBUG: Undo announce accepted from '+keyId) print('DEBUG: Undo announce accepted from '+keyId)
return False return False
if not nodeletion:
if receiveDelete(session,handle, \ if receiveDelete(session,handle, \
baseDir,httpPrefix, \ baseDir,httpPrefix, \
domain,port, \ domain,port, \
@ -915,7 +916,7 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \
domain: str,port: int,useTor: bool,federationList: [], \ domain: str,port: int,useTor: bool,federationList: [], \
ocapAlways: bool,maxReplies: int, \ ocapAlways: bool,maxReplies: int, \
domainMaxPostsPerDay: int,accountMaxPostsPerDay: int, \ domainMaxPostsPerDay: int,accountMaxPostsPerDay: int, \
debug: bool, \ nodeletion: bool,debug: bool, \
acceptedCaps=["inbox:write","objects:read"]) -> None: acceptedCaps=["inbox:write","objects:read"]) -> None:
"""Processes received items and moves them to """Processes received items and moves them to
the appropriate directories the appropriate directories
@ -1178,7 +1179,7 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \
federationList,ocapAlways, \ federationList,ocapAlways, \
debug,acceptedCaps, \ debug,acceptedCaps, \
queueFilename,destination, \ queueFilename,destination, \
maxReplies) maxReplies,nodeletion)
else: else:
if debug: if debug:
print('DEBUG: object capabilities check failed') print('DEBUG: object capabilities check failed')
@ -1195,7 +1196,7 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \
federationList,ocapAlways, \ federationList,ocapAlways, \
debug,acceptedCaps, \ debug,acceptedCaps, \
queueFilename,destination, \ queueFilename,destination, \
maxReplies) maxReplies,nodeletion)
if debug: if debug:
print('DEBUG: object capabilities check failed') print('DEBUG: object capabilities check failed')

View File

@ -151,6 +151,7 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [], \
maxReplies=64 maxReplies=64
domainMaxPostsPerDay=1000 domainMaxPostsPerDay=1000
accountMaxPostsPerDay=1000 accountMaxPostsPerDay=1000
nodeletion=False
privateKeyPem,publicKeyPem,person,wfEndpoint= \ privateKeyPem,publicKeyPem,person,wfEndpoint= \
createPerson(path,nickname,domain,port,httpPrefix,True,password) createPerson(path,nickname,domain,port,httpPrefix,True,password)
deleteAllPosts(path,nickname,domain,'inbox') deleteAllPosts(path,nickname,domain,'inbox')
@ -179,7 +180,7 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [], \
noreply,nolike,nopics,noannounce,cw,ocapAlways, \ noreply,nolike,nopics,noannounce,cw,ocapAlways, \
useTor,maxReplies, \ useTor,maxReplies, \
domainMaxPostsPerDay,accountMaxPostsPerDay, \ domainMaxPostsPerDay,accountMaxPostsPerDay, \
True) nodeletion,True)
def createServerBob(path: str,domain: str,port: int,federationList: [], \ def createServerBob(path: str,domain: str,port: int,federationList: [], \
hasFollows: bool,hasPosts :bool,ocapAlways :bool): hasFollows: bool,hasPosts :bool,ocapAlways :bool):
@ -202,6 +203,7 @@ def createServerBob(path: str,domain: str,port: int,federationList: [], \
maxReplies=64 maxReplies=64
domainMaxPostsPerDay=1000 domainMaxPostsPerDay=1000
accountMaxPostsPerDay=1000 accountMaxPostsPerDay=1000
nodeletion=False
privateKeyPem,publicKeyPem,person,wfEndpoint= \ privateKeyPem,publicKeyPem,person,wfEndpoint= \
createPerson(path,nickname,domain,port,httpPrefix,True,password) createPerson(path,nickname,domain,port,httpPrefix,True,password)
deleteAllPosts(path,nickname,domain,'inbox') deleteAllPosts(path,nickname,domain,'inbox')
@ -230,7 +232,7 @@ def createServerBob(path: str,domain: str,port: int,federationList: [], \
noreply,nolike,nopics,noannounce,cw,ocapAlways, \ noreply,nolike,nopics,noannounce,cw,ocapAlways, \
useTor,maxReplies, \ useTor,maxReplies, \
domainMaxPostsPerDay,accountMaxPostsPerDay, \ domainMaxPostsPerDay,accountMaxPostsPerDay, \
True) nodeletion,True)
def createServerEve(path: str,domain: str,port: int,federationList: [], \ def createServerEve(path: str,domain: str,port: int,federationList: [], \
hasFollows: bool,hasPosts :bool,ocapAlways :bool): hasFollows: bool,hasPosts :bool,ocapAlways :bool):
@ -250,6 +252,7 @@ def createServerEve(path: str,domain: str,port: int,federationList: [], \
noannounce=False noannounce=False
cw=False cw=False
maxReplies=64 maxReplies=64
nodeletion=False
privateKeyPem,publicKeyPem,person,wfEndpoint= \ privateKeyPem,publicKeyPem,person,wfEndpoint= \
createPerson(path,nickname,domain,port,httpPrefix,True,password) createPerson(path,nickname,domain,port,httpPrefix,True,password)
deleteAllPosts(path,nickname,domain,'inbox') deleteAllPosts(path,nickname,domain,'inbox')
@ -259,7 +262,7 @@ def createServerEve(path: str,domain: str,port: int,federationList: [], \
print('Server running: Eve') print('Server running: Eve')
runDaemon(False,path,domain,port,httpPrefix,federationList, \ runDaemon(False,path,domain,port,httpPrefix,federationList, \
noreply,nolike,nopics,noannounce,cw,ocapAlways, \ noreply,nolike,nopics,noannounce,cw,ocapAlways, \
useTor,maxReplies,True) useTor,maxReplies,nodeletion,True)
def testPostMessageBetweenServers(): def testPostMessageBetweenServers():
print('Testing sending message from one server to the inbox of another') print('Testing sending message from one server to the inbox of another')