Always allow capabilities requests

master
Bob Mottram 2019-07-06 12:03:51 +01:00
parent 02bcea9ce1
commit 31ccb80830
2 changed files with 10 additions and 6 deletions

View File

@ -460,7 +460,8 @@ def threadSendPost(session,postJsonObject: {},federationList: [],capsList: [],\
backoffTime=60
for attempt in range(20):
postResult = postJson(session,postJsonObject,federationList, \
capsList,inboxUrl,signatureHeaderJson)
capsList,inboxUrl,signatureHeaderJson, \
"inbox:write")
if postResult:
postLog.append(postJsonObject['published']+' '+postResult+'\n')
# keep the length of the log finite

View File

@ -39,12 +39,15 @@ def getJson(session,url: str,headers: {},params: {}) -> {}:
pass
return None
def postJson(session,postJsonObject: {},federationList: [],capsList: [],inboxUrl: str,headers: {}) -> str:
def postJson(session,postJsonObject: {},federationList: [],capsList: [],inboxUrl: str,headers: {},capability: str) -> str:
"""Post a json message to the inbox of another person
Supplying a capability, such as "inbox:write"
"""
# always allow capability requests
if not capability.startswith('cap'):
# check that we are posting to a permitted domain
if not urlPermitted(inboxUrl,federationList,capsList,"inbox:write"):
if not urlPermitted(inboxUrl,federationList,capsList,capability):
return None
postResult = session.post(url = inboxUrl, data = json.dumps(postJsonObject), headers=headers)