mail fixes
This commit is contained in:
parent
1d32b3daa1
commit
b09dae276c
@ -27,6 +27,7 @@ from onionrblockapi import Block
|
|||||||
import onionrutils, onionrexceptions, onionrcrypto, blockimporter, onionrevents as events, logger, config, onionr
|
import onionrutils, onionrexceptions, onionrcrypto, blockimporter, onionrevents as events, logger, config, onionr
|
||||||
|
|
||||||
class FDSafeHandler(WSGIHandler):
|
class FDSafeHandler(WSGIHandler):
|
||||||
|
'''Our WSGI handler. Doesn't do much non-default except timeouts'''
|
||||||
def handle(self):
|
def handle(self):
|
||||||
timeout = Timeout(60, exception=Exception)
|
timeout = Timeout(60, exception=Exception)
|
||||||
timeout.start()
|
timeout.start()
|
||||||
@ -37,24 +38,6 @@ class FDSafeHandler(WSGIHandler):
|
|||||||
except Timeout as ex:
|
except Timeout as ex:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def guessMime(path):
|
|
||||||
'''
|
|
||||||
Guesses the mime type of a file from the input filename
|
|
||||||
'''
|
|
||||||
mimetypes = {
|
|
||||||
'html' : 'text/html',
|
|
||||||
'js' : 'application/javascript',
|
|
||||||
'css' : 'text/css',
|
|
||||||
'png' : 'image/png',
|
|
||||||
'jpg' : 'image/jpeg'
|
|
||||||
}
|
|
||||||
|
|
||||||
for mimetype in mimetypes:
|
|
||||||
if path.endswith('.%s' % mimetype):
|
|
||||||
return mimetypes[mimetype]
|
|
||||||
|
|
||||||
return 'text/plain'
|
|
||||||
|
|
||||||
def setBindIP(filePath):
|
def setBindIP(filePath):
|
||||||
'''Set a random localhost IP to a specified file (intended for private or public API localhost IPs)'''
|
'''Set a random localhost IP to a specified file (intended for private or public API localhost IPs)'''
|
||||||
hostOctets = [str(127), str(random.randint(0x02, 0xFF)), str(random.randint(0x02, 0xFF)), str(random.randint(0x02, 0xFF))]
|
hostOctets = [str(127), str(random.randint(0x02, 0xFF)), str(random.randint(0x02, 0xFF)), str(random.randint(0x02, 0xFF))]
|
||||||
@ -65,6 +48,7 @@ def setBindIP(filePath):
|
|||||||
try:
|
try:
|
||||||
s.bind((data, 0))
|
s.bind((data, 0))
|
||||||
except OSError:
|
except OSError:
|
||||||
|
# if mac/non-bindable, show warning and default to 127.0.0.1
|
||||||
logger.warn('Your platform appears to not support random local host addresses 127.x.x.x. Falling back to 127.0.0.1.')
|
logger.warn('Your platform appears to not support random local host addresses 127.x.x.x. Falling back to 127.0.0.1.')
|
||||||
data = '127.0.0.1'
|
data = '127.0.0.1'
|
||||||
s.close()
|
s.close()
|
||||||
@ -486,7 +470,8 @@ class API:
|
|||||||
meta = json.loads(bData['meta'])
|
meta = json.loads(bData['meta'])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
return Response(self._core.insertBlock(message, header=bType, encryptType=encryptType, sign=sign, asymPeer=to, meta=meta))
|
threading.Thread(target=self._core.insertBlock, args=(message,), kwargs={'header': bType, 'encryptType': encryptType, 'sign':sign, 'asymPeer': to, 'meta': meta}).start()
|
||||||
|
return Response('success')
|
||||||
|
|
||||||
@app.route('/apipoints/<path:subpath>', methods=['POST', 'GET'])
|
@app.route('/apipoints/<path:subpath>', methods=['POST', 'GET'])
|
||||||
def pluginEndpoints(subpath=''):
|
def pluginEndpoints(subpath=''):
|
||||||
|
@ -194,9 +194,9 @@ class OnionrMail:
|
|||||||
self.sentMessages = {}
|
self.sentMessages = {}
|
||||||
for i in self.sentboxTools.listSent():
|
for i in self.sentboxTools.listSent():
|
||||||
self.sentboxList.append(i['hash'])
|
self.sentboxList.append(i['hash'])
|
||||||
self.sentMessages[i['hash']] = (self.myCore._utils.bytesToStr(i['message']), i['peer'])
|
self.sentMessages[i['hash']] = (self.myCore._utils.bytesToStr(i['message']), i['peer'], i['subject'])
|
||||||
if display:
|
if display:
|
||||||
logger.info('%s. %s - %s - %s' % (count, i['hash'], i['peer'][:12], i['date']))
|
logger.info('%s. %s - %s - (%s) - %s' % (count, i['hash'], i['peer'][:12], i['subject'], i['date']))
|
||||||
count += 1
|
count += 1
|
||||||
return json.dumps(self.sentMessages)
|
return json.dumps(self.sentMessages)
|
||||||
|
|
||||||
@ -247,7 +247,6 @@ class OnionrMail:
|
|||||||
logger.info('Inserting encrypted message as Onionr block....')
|
logger.info('Inserting encrypted message as Onionr block....')
|
||||||
|
|
||||||
blockID = self.myCore.insertBlock(message, header='pm', encryptType='asym', asymPeer=recip, sign=self.doSigs, meta={'subject': subject})
|
blockID = self.myCore.insertBlock(message, header='pm', encryptType='asym', asymPeer=recip, sign=self.doSigs, meta={'subject': subject})
|
||||||
self.sentboxTools.addToSent(blockID, recip, message)
|
|
||||||
|
|
||||||
def toggle_signing(self):
|
def toggle_signing(self):
|
||||||
self.doSigs = not self.doSigs
|
self.doSigs = not self.doSigs
|
||||||
@ -291,8 +290,8 @@ class OnionrMail:
|
|||||||
|
|
||||||
def on_insertblock(api, data={}):
|
def on_insertblock(api, data={}):
|
||||||
sentboxTools = sentboxdb.SentBox(api.get_core())
|
sentboxTools = sentboxdb.SentBox(api.get_core())
|
||||||
meta = json.dumps(data['meta'])
|
meta = json.loads(data['meta'])
|
||||||
sentboxTools.addToSent(data['hash'], data['peer'], data['content'])
|
sentboxTools.addToSent(data['hash'], data['peer'], data['content'], meta['subject'])
|
||||||
|
|
||||||
def on_pluginrequest(api, data=None):
|
def on_pluginrequest(api, data=None):
|
||||||
resp = ''
|
resp = ''
|
||||||
|
@ -37,6 +37,7 @@ class SentBox:
|
|||||||
hash id not null,
|
hash id not null,
|
||||||
peer text not null,
|
peer text not null,
|
||||||
message text not null,
|
message text not null,
|
||||||
|
subject text not null,
|
||||||
date int not null
|
date int not null
|
||||||
);
|
);
|
||||||
''')
|
''')
|
||||||
@ -46,12 +47,12 @@ class SentBox:
|
|||||||
def listSent(self):
|
def listSent(self):
|
||||||
retData = []
|
retData = []
|
||||||
for entry in self.cursor.execute('SELECT * FROM sent;'):
|
for entry in self.cursor.execute('SELECT * FROM sent;'):
|
||||||
retData.append({'hash': entry[0], 'peer': entry[1], 'message': entry[2], 'date': entry[3]})
|
retData.append({'hash': entry[0], 'peer': entry[1], 'message': entry[2], 'subject': entry[3], 'date': entry[4]})
|
||||||
return retData
|
return retData
|
||||||
|
|
||||||
def addToSent(self, blockID, peer, message):
|
def addToSent(self, blockID, peer, message, subject=''):
|
||||||
args = (blockID, peer, message, self.core._utils.getEpoch())
|
args = (blockID, peer, message, subject, self.core._utils.getEpoch())
|
||||||
self.cursor.execute('INSERT INTO sent VALUES(?, ?, ?, ?)', args)
|
self.cursor.execute('INSERT INTO sent VALUES(?, ?, ?, ?, ?)', args)
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="infoOverlay" class='overlay'>
|
<div id="infoOverlay" class='overlay'>
|
||||||
</div>
|
</div>
|
||||||
<img class='logo' src='/shared/onionr-icon.png' alt='onionr logo'>
|
|
||||||
<span class='logoText'>Onionr Mail ✉️</span>
|
|
||||||
<div class='content'>
|
<div class='content'>
|
||||||
|
<img class='logo' src='/shared/onionr-icon.png' alt='onionr logo'>
|
||||||
|
<span class='logoText'>Onionr Mail ✉️</span>
|
||||||
<div>Current Used Identity: <input class='myPub' type='text' readonly> <button class='refresh'>Refresh Page</button></div>
|
<div>Current Used Identity: <input class='myPub' type='text' readonly> <button class='refresh'>Refresh Page</button></div>
|
||||||
<br><br>
|
<br><br>
|
||||||
<div class="btn-group" id='tabBtns'>
|
<div class="btn-group" id='tabBtns'>
|
||||||
|
@ -154,7 +154,7 @@ function getSentbox(){
|
|||||||
var preview = document.createElement('span')
|
var preview = document.createElement('span')
|
||||||
toEl.readOnly = true
|
toEl.readOnly = true
|
||||||
toEl.value = resp[keys[i]][1]
|
toEl.value = resp[keys[i]][1]
|
||||||
preview.innerText = resp[keys[i]][0].split('\n')[0];
|
preview.innerText = '(' + resp[keys[i]][2] + ')'
|
||||||
entry.appendChild(toLabel)
|
entry.appendChild(toLabel)
|
||||||
entry.appendChild(toEl)
|
entry.appendChild(toEl)
|
||||||
entry.appendChild(preview)
|
entry.appendChild(preview)
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
Onionr - P2P Anonymous Storage Network
|
||||||
|
|
||||||
|
This file handles the mail interface
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
webpass = document.location.hash.replace('#', '')
|
webpass = document.location.hash.replace('#', '')
|
||||||
nowebpass = false
|
nowebpass = false
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user