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 data not in self.hideBlocks:
|
||||
if data in clientAPI._core.getBlockList():
|
||||
block = self.clientAPI.getBlockData(data).encode()
|
||||
block = clientAPI.getBlockData(data, raw=True).encode()
|
||||
resp = base64.b64encode(block).decode()
|
||||
if len(resp) == 0:
|
||||
abort(404)
|
||||
@ -469,17 +469,20 @@ class API:
|
||||
# Don't error on race condition with startup
|
||||
pass
|
||||
|
||||
def getBlockData(self, bHash, decrypt=False):
|
||||
def getBlockData(self, bHash, decrypt=False, raw=False):
|
||||
bl = Block(bHash, core=self._core)
|
||||
if decrypt:
|
||||
bl.decrypt()
|
||||
if bl.isEncrypted and not bl.decrypted:
|
||||
raise ValueError
|
||||
|
||||
retData = {'meta':bl.bheader, 'metadata': bl.bmetadata, 'content': bl.bcontent}
|
||||
for x in list(retData.keys()):
|
||||
try:
|
||||
retData[x] = retData[x].decode()
|
||||
except AttributeError:
|
||||
pass
|
||||
return json.dumps(retData)
|
||||
if not raw:
|
||||
retData = {'meta':bl.bheader, 'metadata': bl.bmetadata, 'content': bl.bcontent}
|
||||
for x in list(retData.keys()):
|
||||
try:
|
||||
retData[x] = retData[x].decode()
|
||||
except AttributeError:
|
||||
pass
|
||||
return json.dumps(retData)
|
||||
else:
|
||||
return bl.raw
|
@ -2,5 +2,6 @@
|
||||
padding-top: 1em;
|
||||
}
|
||||
.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(function(resp) {
|
||||
|
||||
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 subjectLine = document.createElement('span')
|
||||
var dateStr = document.createElement('span')
|
||||
var humanDate = new Date(0)
|
||||
humanDate.setUTCSeconds(resp['meta']['time'])
|
||||
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
|
||||
dateStr.innerText = humanDate.toString()
|
||||
if (resp['metadata']['subject'] === undefined || resp['metadata']['subject'] === null) {
|
||||
@ -33,7 +35,7 @@ function getInbox(){
|
||||
entry.appendChild(subjectLine)
|
||||
entry.appendChild(dateStr)
|
||||
|
||||
})
|
||||
}.bind([pms, i]))
|
||||
}
|
||||
|
||||
}
|
||||
@ -45,6 +47,6 @@ fetch('/getblocksbytype/pm', {
|
||||
.then((resp) => resp.text()) // Transform the data into json
|
||||
.then(function(data) {
|
||||
pms = data.split(',')
|
||||
getInbox()
|
||||
getInbox(pms)
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user