main
Bob Mottram 2019-11-18 16:55:04 +00:00
parent d8eb8ad375
commit 50bd337e87
2 changed files with 12 additions and 6 deletions

View File

@ -2005,7 +2005,7 @@ def createSharedInboxIndex(baseDir: str,sharedBoxDir: str, \
with open(sharedInboxFilename, 'r') as fp: with open(sharedInboxFilename, 'r') as fp:
postJsonObject=commentjson.load(fp) postJsonObject=commentjson.load(fp)
except: except:
print('WARN: commentjson exception createBoxBase') print('WARN: commentjson exception createSharedInboxIndex')
continue continue
actorNickname=getNicknameFromActor(postJsonObject['actor']) actorNickname=getNicknameFromActor(postJsonObject['actor'])
@ -2041,7 +2041,7 @@ def createSharedInboxIndex(baseDir: str,sharedBoxDir: str, \
ocapJson=commentjson.load(fp) ocapJson=commentjson.load(fp)
loadedOcap=True loadedOcap=True
except: except:
print('WARN: commentjson exception createBoxBase') print('WARN: commentjson exception createSharedInboxIndex')
if loadedOcap: if loadedOcap:
if ocapJson.get('id'): if ocapJson.get('id'):

View File

@ -52,7 +52,8 @@ def getJson(session,url: str,headers: {},params: {}, \
print(e) print(e)
return None return None
def postJson(session,postJsonObject: {},federationList: [],inboxUrl: str,headers: {},capability: str) -> str: def postJson(session,postJsonObject: {},federationList: [], \
inboxUrl: str,headers: {},capability: str) -> str:
"""Post a json message to the inbox of another person """Post a json message to the inbox of another person
Supplying a capability, such as "inbox:write" Supplying a capability, such as "inbox:write"
""" """
@ -64,7 +65,10 @@ def postJson(session,postJsonObject: {},federationList: [],inboxUrl: str,headers
print('postJson: '+inboxUrl+' not permitted') print('postJson: '+inboxUrl+' not permitted')
return None return None
postResult = session.post(url = inboxUrl, data = json.dumps(postJsonObject), headers=headers) postResult= \
session.post(url=inboxUrl, \
data=json.dumps(postJsonObject), \
headers=headers)
if postResult: if postResult:
return postResult.text return postResult.text
return None return None
@ -97,7 +101,8 @@ def postJsonString(session,postJsonStr: str, \
# postResult = session.post(url = inboxUrl, data = postJsonStr, headers=headers) # postResult = session.post(url = inboxUrl, data = postJsonStr, headers=headers)
# if not (postResult.status_code<200 or postResult.status_code>202): # if not (postResult.status_code<200 or postResult.status_code>202):
# return True # return True
if postResult.status_code>=400 and postResult.status_code<=405 and postResult.status_code!=404: if postResult.status_code>=400 and postResult.status_code<=405 and \
postResult.status_code!=404:
print('WARN: >>> Post to '+inboxUrl+' is unauthorized <<<') print('WARN: >>> Post to '+inboxUrl+' is unauthorized <<<')
return False,True return False,True
else: else:
@ -106,7 +111,8 @@ def postJsonString(session,postJsonStr: str, \
return False,False return False,False
return True,False return True,False
def postImage(session,attachImageFilename: str,federationList: [],inboxUrl: str,headers: {},capability: str) -> str: def postImage(session,attachImageFilename: str,federationList: [], \
inboxUrl: str,headers: {},capability: str) -> str:
"""Post an image to the inbox of another person or outbox via c2s """Post an image to the inbox of another person or outbox via c2s
Supplying a capability, such as "inbox:write" Supplying a capability, such as "inbox:write"
""" """