diff --git a/daemon.py b/daemon.py index 18f4c7112..89c0ad7b1 100644 --- a/daemon.py +++ b/daemon.py @@ -206,9 +206,10 @@ class PubServer(BaseHTTPRequestHandler): if self.server.debug: print('DEBUG: handle any unfollow requests') outboxUndoFollow(self.server.baseDir,messageJson,self.server.debug) - if self.server.debug: - print('DEBUG: handle delete requests') - outboxDelete(self.server.baseDir,self.server.httpPrefix,messageJson,self.server.debug) + if not self.server.nodeletion: + if self.server.debug: + print('DEBUG: handle delete requests') + outboxDelete(self.server.baseDir,self.server.httpPrefix,messageJson,self.server.debug) if self.server.debug: print('DEBUG: sending c2s post to named addresses') print('c2s sender: '+self.postToNickname+'@'+self.server.domain+':'+str(self.server.port)) @@ -812,7 +813,7 @@ def runDaemon(clientToServer: bool,baseDir: str,domain: str, \ noannounce=False,cw=False,ocapAlways=False, \ useTor=False,maxReplies=64, \ domainMaxPostsPerDay=8640,accountMaxPostsPerDay=8640, \ - debug=False) -> None: + nodeletion=False,debug=False) -> None: if len(domain)==0: domain='localhost' if '.' not in domain: @@ -845,6 +846,7 @@ def runDaemon(clientToServer: bool,baseDir: str,domain: str, \ httpd.ocapAlways=ocapAlways httpd.maxMessageLength=5000 httpd.maxImageSize=10*1024*1024 + httpd.nodeletion=nodeletion httpd.acceptedCaps=["inbox:write","objects:read"] if noreply: httpd.acceptedCaps.append('inbox:noreply') @@ -869,7 +871,7 @@ def runDaemon(clientToServer: bool,baseDir: str,domain: str, \ domain,port,useTor,httpd.federationList, \ httpd.ocapAlways,maxReplies, \ domainMaxPostsPerDay,accountMaxPostsPerDay, \ - debug,httpd.acceptedCaps),daemon=True) + nodeletion,debug,httpd.acceptedCaps),daemon=True) httpd.thrInboxQueue.start() if clientToServer: print('Running ActivityPub client on ' + domain + ' port ' + str(port)) diff --git a/epicyon.py b/epicyon.py index d2db37dbc..1459d82eb 100644 --- a/epicyon.py +++ b/epicyon.py @@ -164,6 +164,9 @@ parser.add_argument('--message', dest='message', type=str,default=None, \ help='Message content') parser.add_argument('--delete', dest='delete', type=str,default=None, \ 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, \ help='Announce/repeat a url') parser.add_argument('--sendto', nargs='+',dest='sendto', \ @@ -776,4 +779,4 @@ runDaemon(args.client,baseDir,domain,port,httpPrefix, \ args.noannounce,args.cw,ocapAlways, \ useTor,args.maxReplies, \ args.domainMaxPostsPerDay,args.accountMaxPostsPerDay, \ - debug) + args.nodeletion,debug) diff --git a/inbox.py b/inbox.py index ec1803c39..f39f36623 100644 --- a/inbox.py +++ b/inbox.py @@ -823,7 +823,7 @@ def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \ federationList: [],ocapAlways: bool,debug: bool, \ acceptedCaps: [], queueFilename :str,destinationFilename :str, - maxReplies: int) -> bool: + maxReplies: int,nodeletion: bool) -> bool: """ Anything which needs to be done after capabilities checks have passed """ if receiveLike(session,handle, \ @@ -877,18 +877,19 @@ def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \ print('DEBUG: Undo announce accepted from '+keyId) return False - if receiveDelete(session,handle, \ - baseDir,httpPrefix, \ - domain,port, \ - sendThreads,postLog, \ - cachedWebfingers, \ - personCache, \ - messageJson, \ - federationList, \ - debug): - if debug: - print('DEBUG: Delete accepted from '+keyId) - return False + if not nodeletion: + if receiveDelete(session,handle, \ + baseDir,httpPrefix, \ + domain,port, \ + sendThreads,postLog, \ + cachedWebfingers, \ + personCache, \ + messageJson, \ + federationList, \ + debug): + if debug: + print('DEBUG: Delete accepted from '+keyId) + return False populateReplies(baseDir,httpPrefix,domain,messageJson,maxReplies,debug) @@ -915,7 +916,7 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \ domain: str,port: int,useTor: bool,federationList: [], \ ocapAlways: bool,maxReplies: int, \ domainMaxPostsPerDay: int,accountMaxPostsPerDay: int, \ - debug: bool, \ + nodeletion: bool,debug: bool, \ acceptedCaps=["inbox:write","objects:read"]) -> None: """Processes received items and moves them to the appropriate directories @@ -1178,7 +1179,7 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \ federationList,ocapAlways, \ debug,acceptedCaps, \ queueFilename,destination, \ - maxReplies) + maxReplies,nodeletion) else: if debug: print('DEBUG: object capabilities check failed') @@ -1195,7 +1196,7 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \ federationList,ocapAlways, \ debug,acceptedCaps, \ queueFilename,destination, \ - maxReplies) + maxReplies,nodeletion) if debug: print('DEBUG: object capabilities check failed') diff --git a/tests.py b/tests.py index 69ceac28b..cec8bbeda 100644 --- a/tests.py +++ b/tests.py @@ -151,6 +151,7 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [], \ maxReplies=64 domainMaxPostsPerDay=1000 accountMaxPostsPerDay=1000 + nodeletion=False privateKeyPem,publicKeyPem,person,wfEndpoint= \ createPerson(path,nickname,domain,port,httpPrefix,True,password) deleteAllPosts(path,nickname,domain,'inbox') @@ -179,7 +180,7 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [], \ noreply,nolike,nopics,noannounce,cw,ocapAlways, \ useTor,maxReplies, \ domainMaxPostsPerDay,accountMaxPostsPerDay, \ - True) + nodeletion,True) def createServerBob(path: str,domain: str,port: int,federationList: [], \ hasFollows: bool,hasPosts :bool,ocapAlways :bool): @@ -202,6 +203,7 @@ def createServerBob(path: str,domain: str,port: int,federationList: [], \ maxReplies=64 domainMaxPostsPerDay=1000 accountMaxPostsPerDay=1000 + nodeletion=False privateKeyPem,publicKeyPem,person,wfEndpoint= \ createPerson(path,nickname,domain,port,httpPrefix,True,password) deleteAllPosts(path,nickname,domain,'inbox') @@ -230,7 +232,7 @@ def createServerBob(path: str,domain: str,port: int,federationList: [], \ noreply,nolike,nopics,noannounce,cw,ocapAlways, \ useTor,maxReplies, \ domainMaxPostsPerDay,accountMaxPostsPerDay, \ - True) + nodeletion,True) def createServerEve(path: str,domain: str,port: int,federationList: [], \ hasFollows: bool,hasPosts :bool,ocapAlways :bool): @@ -250,6 +252,7 @@ def createServerEve(path: str,domain: str,port: int,federationList: [], \ noannounce=False cw=False maxReplies=64 + nodeletion=False privateKeyPem,publicKeyPem,person,wfEndpoint= \ createPerson(path,nickname,domain,port,httpPrefix,True,password) deleteAllPosts(path,nickname,domain,'inbox') @@ -259,7 +262,7 @@ def createServerEve(path: str,domain: str,port: int,federationList: [], \ print('Server running: Eve') runDaemon(False,path,domain,port,httpPrefix,federationList, \ noreply,nolike,nopics,noannounce,cw,ocapAlways, \ - useTor,maxReplies,True) + useTor,maxReplies,nodeletion,True) def testPostMessageBetweenServers(): print('Testing sending message from one server to the inbox of another')