Allow for other outbox post types

master
Bob Mottram 2019-07-03 23:44:03 +01:00
parent d3128fe91d
commit 4ef93d01c5
1 changed files with 19 additions and 11 deletions

View File

@ -108,24 +108,32 @@ class PubServer(BaseHTTPRequestHandler):
https://www.w3.org/TR/activitypub/#client-to-server-outbox-delivery https://www.w3.org/TR/activitypub/#client-to-server-outbox-delivery
""" """
if not messageJson.get('object'): if not messageJson.get('object'):
if messageJson.get('type'): if messageJson.get('type') and messageJson.get('content'):
if messageJson['type']!='Create': if messageJson['type']!='Create':
# https://www.w3.org/TR/activitypub/#object-without-create # https://www.w3.org/TR/activitypub/#object-without-create
if self.server.debug:
print('DEBUG POST to outbox: Adding Create wrapper')
messageJson= \ messageJson= \
outboxMessageCreateWrap(self.server.httpPrefix, \ outboxMessageCreateWrap(self.server.httpPrefix, \
self.postToNickname, \ self.postToNickname, \
self.server.domain,messageJson) self.server.domain,messageJson)
if messageJson['type']=='Create':
if not (messageJson.get('id') and \ if not (messageJson.get('id') and \
messageJson.get('type') and \ messageJson.get('type') and \
messageJson.get('actor') and \ messageJson.get('actor') and \
messageJson.get('object') and \ messageJson.get('object') and \
messageJson.get('atomUri') and \ messageJson.get('atomUri') and \
messageJson.get('to')): messageJson.get('to')):
return False if self.server.debug:
if messageJson['type']!='Create': print('DEBUG POST to outbox: Create does not have the required parameters')
return False return False
# https://www.w3.org/TR/activitypub/#create-activity-outbox # https://www.w3.org/TR/activitypub/#create-activity-outbox
messageJson['object']['attributedTo']=messageJson['actor'] 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
savePostToOutbox(self.server.baseDir,messageJson['id'],self.postToNickname,self.server.domain,messageJson) savePostToOutbox(self.server.baseDir,messageJson['id'],self.postToNickname,self.server.domain,messageJson)
return True return True