Return boolean from post

master
Bob Mottram 2019-08-26 13:10:19 +01:00
parent 17d639ba7d
commit 3042b84a16
2 changed files with 4 additions and 4 deletions

View File

@ -920,7 +920,7 @@ def threadSendPost(session,postJsonStr: str,federationList: [],\
if postResult: if postResult:
if debug: if debug:
print('DEBUG: successful json post to '+inboxUrl+' ('+str(postResult)+')') print('DEBUG: successful json post to '+inboxUrl)
# our work here is done # our work here is done
break break
if debug: if debug:

View File

@ -70,7 +70,7 @@ def postJsonString(session,postJsonStr: str, \
inboxUrl: str, \ inboxUrl: str, \
headers: {}, \ headers: {}, \
capability: str, \ capability: str, \
debug: bool) -> str: debug: bool) -> bool:
"""Post a json message string to the inbox of another person """Post a json message string to the inbox of another person
Supplying a capability, such as "inbox:write" Supplying a capability, such as "inbox:write"
NOTE: Here we post a string rather than the original json so that NOTE: Here we post a string rather than the original json so that
@ -88,8 +88,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 postResult.status_code<200 or postResult.status_code>202: if postResult.status_code<200 or postResult.status_code>202:
print('WARN: Failed to post to '+inboxUrl+' status code '+str(postResult.status_code)) print('WARN: Failed to post to '+inboxUrl+' status code '+str(postResult.status_code))
return None return False
return postResult.text return True
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