fixed broken getcontent, more work on mail
This commit is contained in:
parent
158154184a
commit
d21db75edd
@ -139,7 +139,7 @@ class PublicAPI:
|
|||||||
if clientAPI._utils.validateHash(data):
|
if clientAPI._utils.validateHash(data):
|
||||||
if data not in self.hideBlocks:
|
if data not in self.hideBlocks:
|
||||||
if data in clientAPI._core.getBlockList():
|
if data in clientAPI._core.getBlockList():
|
||||||
block = self.clientAPI.getBlockData(data).encode()
|
block = clientAPI.getBlockData(data, raw=True).encode()
|
||||||
resp = base64.b64encode(block).decode()
|
resp = base64.b64encode(block).decode()
|
||||||
if len(resp) == 0:
|
if len(resp) == 0:
|
||||||
abort(404)
|
abort(404)
|
||||||
@ -469,17 +469,20 @@ class API:
|
|||||||
# Don't error on race condition with startup
|
# Don't error on race condition with startup
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def getBlockData(self, bHash, decrypt=False):
|
def getBlockData(self, bHash, decrypt=False, raw=False):
|
||||||
bl = Block(bHash, core=self._core)
|
bl = Block(bHash, core=self._core)
|
||||||
if decrypt:
|
if decrypt:
|
||||||
bl.decrypt()
|
bl.decrypt()
|
||||||
if bl.isEncrypted and not bl.decrypted:
|
if bl.isEncrypted and not bl.decrypted:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
retData = {'meta':bl.bheader, 'metadata': bl.bmetadata, 'content': bl.bcontent}
|
if not raw:
|
||||||
for x in list(retData.keys()):
|
retData = {'meta':bl.bheader, 'metadata': bl.bmetadata, 'content': bl.bcontent}
|
||||||
try:
|
for x in list(retData.keys()):
|
||||||
retData[x] = retData[x].decode()
|
try:
|
||||||
except AttributeError:
|
retData[x] = retData[x].decode()
|
||||||
pass
|
except AttributeError:
|
||||||
return json.dumps(retData)
|
pass
|
||||||
|
return json.dumps(retData)
|
||||||
|
else:
|
||||||
|
return bl.raw
|
@ -2,5 +2,6 @@
|
|||||||
padding-top: 1em;
|
padding-top: 1em;
|
||||||
}
|
}
|
||||||
.threads div span{
|
.threads div span{
|
||||||
padding-left: 1em;
|
padding-left: 0.5em;
|
||||||
|
padding-right: 0.5em;
|
||||||
}
|
}
|
@ -8,16 +8,18 @@ function getInbox(){
|
|||||||
}})
|
}})
|
||||||
.then((resp) => resp.json()) // Transform the data into json
|
.then((resp) => resp.json()) // Transform the data into json
|
||||||
.then(function(resp) {
|
.then(function(resp) {
|
||||||
|
|
||||||
var entry = document.createElement('div')
|
var entry = document.createElement('div')
|
||||||
var bHash = pms[i].substring(0, 10)
|
|
||||||
var bHashDisplay = document.createElement('span')
|
var bHashDisplay = document.createElement('a')
|
||||||
var senderInput = document.createElement('input')
|
var senderInput = document.createElement('input')
|
||||||
var subjectLine = document.createElement('span')
|
var subjectLine = document.createElement('span')
|
||||||
var dateStr = document.createElement('span')
|
var dateStr = document.createElement('span')
|
||||||
var humanDate = new Date(0)
|
var humanDate = new Date(0)
|
||||||
humanDate.setUTCSeconds(resp['meta']['time'])
|
humanDate.setUTCSeconds(resp['meta']['time'])
|
||||||
senderInput.value = resp['meta']['signer']
|
senderInput.value = resp['meta']['signer']
|
||||||
bHashDisplay.innerText = bHash
|
bHashDisplay.innerText = pms[i - 1].substring(0, 10)
|
||||||
|
bHashDisplay.setAttribute('hash', pms[i - 1]);
|
||||||
senderInput.readOnly = true
|
senderInput.readOnly = true
|
||||||
dateStr.innerText = humanDate.toString()
|
dateStr.innerText = humanDate.toString()
|
||||||
if (resp['metadata']['subject'] === undefined || resp['metadata']['subject'] === null) {
|
if (resp['metadata']['subject'] === undefined || resp['metadata']['subject'] === null) {
|
||||||
@ -33,7 +35,7 @@ function getInbox(){
|
|||||||
entry.appendChild(subjectLine)
|
entry.appendChild(subjectLine)
|
||||||
entry.appendChild(dateStr)
|
entry.appendChild(dateStr)
|
||||||
|
|
||||||
})
|
}.bind([pms, i]))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -45,6 +47,6 @@ fetch('/getblocksbytype/pm', {
|
|||||||
.then((resp) => resp.text()) // Transform the data into json
|
.then((resp) => resp.text()) // Transform the data into json
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
pms = data.split(',')
|
pms = data.split(',')
|
||||||
getInbox()
|
getInbox(pms)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user