From 4ef93d01c5054b315df95f213260da654ea11d45 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 3 Jul 2019 23:44:03 +0100 Subject: [PATCH] Allow for other outbox post types --- daemon.py | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/daemon.py b/daemon.py index dfef899c..d86e1113 100644 --- a/daemon.py +++ b/daemon.py @@ -108,24 +108,32 @@ class PubServer(BaseHTTPRequestHandler): https://www.w3.org/TR/activitypub/#client-to-server-outbox-delivery """ if not messageJson.get('object'): - if messageJson.get('type'): + if messageJson.get('type') and messageJson.get('content'): if messageJson['type']!='Create': # https://www.w3.org/TR/activitypub/#object-without-create + if self.server.debug: + print('DEBUG POST to outbox: Adding Create wrapper') messageJson= \ outboxMessageCreateWrap(self.server.httpPrefix, \ self.postToNickname, \ self.server.domain,messageJson) - if not (messageJson.get('id') and \ - messageJson.get('type') and \ - messageJson.get('actor') and \ - messageJson.get('object') and \ - messageJson.get('atomUri') and \ - messageJson.get('to')): + if messageJson['type']=='Create': + if not (messageJson.get('id') and \ + messageJson.get('type') and \ + messageJson.get('actor') and \ + messageJson.get('object') and \ + messageJson.get('atomUri') and \ + messageJson.get('to')): + if self.server.debug: + print('DEBUG POST to outbox: Create does not have the required parameters') + return False + # https://www.w3.org/TR/activitypub/#create-activity-outbox + messageJson['object']['attributedTo']=messageJson['actor'] + permittedOutboxTypes=['Create','Announce','Like','Follow','Undo','Update','Add','Remove','Block','Delete'] + if messageJson['type'] not in permittedOutboxTypes: + if self.server.debug: + print('DEBUG POST to outbox: '+messageJson['type']+' is not a permitted activity type') return False - if messageJson['type']!='Create': - return False - # https://www.w3.org/TR/activitypub/#create-activity-outbox - messageJson['object']['attributedTo']=messageJson['actor'] savePostToOutbox(self.server.baseDir,messageJson['id'],self.postToNickname,self.server.domain,messageJson) return True