forked from indymedia/epicyon
Tidying
parent
d8eb8ad375
commit
50bd337e87
4
posts.py
4
posts.py
|
@ -2005,7 +2005,7 @@ def createSharedInboxIndex(baseDir: str,sharedBoxDir: str, \
|
|||
with open(sharedInboxFilename, 'r') as fp:
|
||||
postJsonObject=commentjson.load(fp)
|
||||
except:
|
||||
print('WARN: commentjson exception createBoxBase')
|
||||
print('WARN: commentjson exception createSharedInboxIndex')
|
||||
continue
|
||||
|
||||
actorNickname=getNicknameFromActor(postJsonObject['actor'])
|
||||
|
@ -2041,7 +2041,7 @@ def createSharedInboxIndex(baseDir: str,sharedBoxDir: str, \
|
|||
ocapJson=commentjson.load(fp)
|
||||
loadedOcap=True
|
||||
except:
|
||||
print('WARN: commentjson exception createBoxBase')
|
||||
print('WARN: commentjson exception createSharedInboxIndex')
|
||||
|
||||
if loadedOcap:
|
||||
if ocapJson.get('id'):
|
||||
|
|
14
session.py
14
session.py
|
@ -52,7 +52,8 @@ def getJson(session,url: str,headers: {},params: {}, \
|
|||
print(e)
|
||||
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
|
||||
Supplying a capability, such as "inbox:write"
|
||||
"""
|
||||
|
@ -64,7 +65,10 @@ def postJson(session,postJsonObject: {},federationList: [],inboxUrl: str,headers
|
|||
print('postJson: '+inboxUrl+' not permitted')
|
||||
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:
|
||||
return postResult.text
|
||||
return None
|
||||
|
@ -97,7 +101,8 @@ def postJsonString(session,postJsonStr: str, \
|
|||
# postResult = session.post(url = inboxUrl, data = postJsonStr, headers=headers)
|
||||
# if not (postResult.status_code<200 or postResult.status_code>202):
|
||||
# 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 <<<')
|
||||
return False,True
|
||||
else:
|
||||
|
@ -106,7 +111,8 @@ def postJsonString(session,postJsonStr: str, \
|
|||
return False,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
|
||||
Supplying a capability, such as "inbox:write"
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue