epicyon/inbox.py

43 lines
1.1 KiB
Python
Raw Normal View History

2019-06-28 21:59:54 +00:00
__filename__ = "inbox.py"
__author__ = "Bob Mottram"
__license__ = "AGPL3+"
__version__ = "0.0.1"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
import json
import os
def inboxPermittedMessage(self,messageJson,federationList) -> bool:
""" check that we are receiving from a permitted domain
"""
testParam='actor'
if not messageJson.get(testParam):
return False
actor=messageJson[testParam]
# always allow the local domain
if thisDomain in actor:
return True
permittedDomain=False
for domain in federationList:
if domain in actor:
permittedDomain=True
break
if not permittedDomain:
return False
if messageJson.get('object'):
if messageJson['object'].get('inReplyTo'):
inReplyTo=messageJson['object']['inReplyTo']
permittedReplyDomain=False
for domain in federationList:
if domain in inReplyTo:
permittedReplyDomain=True
break
if not permittedReplyDomain:
return False
return True