From d21db75edd711f1bb6e7d03977be35501a861461 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Fri, 1 Feb 2019 21:15:28 -0600 Subject: [PATCH] fixed broken getcontent, more work on mail --- onionr/api.py | 21 ++++++++++++--------- onionr/static-data/www/mail/mail.css | 3 ++- onionr/static-data/www/mail/mail.js | 12 +++++++----- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/onionr/api.py b/onionr/api.py index dbd79321..352dc329 100755 --- a/onionr/api.py +++ b/onionr/api.py @@ -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) \ No newline at end of file + 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 \ No newline at end of file diff --git a/onionr/static-data/www/mail/mail.css b/onionr/static-data/www/mail/mail.css index 17ea217f..7a807d3e 100644 --- a/onionr/static-data/www/mail/mail.css +++ b/onionr/static-data/www/mail/mail.css @@ -2,5 +2,6 @@ padding-top: 1em; } .threads div span{ - padding-left: 1em; + padding-left: 0.5em; + padding-right: 0.5em; } \ No newline at end of file diff --git a/onionr/static-data/www/mail/mail.js b/onionr/static-data/www/mail/mail.js index c07d9534..f392f569 100644 --- a/onionr/static-data/www/mail/mail.js +++ b/onionr/static-data/www/mail/mail.js @@ -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) })