work on making mail more efficient, added --private-ke argument imp to run script

This commit is contained in:
Kevin Froman 2020-09-19 08:25:10 +00:00
parent 646a7c0b80
commit 3199f93d4b
4 changed files with 43 additions and 4 deletions

View file

@ -10,9 +10,11 @@ from flask import Response, request, redirect, Blueprint, abort
from flask import send_from_directory
import deadsimplekv as simplekv
from httpapi.sse.wrapper import SSEWrapper
from onionrusers import contactmanager
from onionrutils import stringvalidators
from utils import reconstructhash, identifyhome
from utils.bettersleep import better_sleep as sleep
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
import loadinbox
@ -35,6 +37,7 @@ flask_blueprint = Blueprint('mail', __name__)
kv = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/mailcache.dat')
root = os.path.dirname(os.path.realpath(__file__))
sse_wrapper = SSEWrapper()
@flask_blueprint.route('/mail/<path:path>', endpoint='mailstatic')
def load_mail(path):
@ -68,6 +71,16 @@ def mail_delete(block):
def list_inbox():
return ','.join(loadinbox.load_inbox())
@flask_blueprint.route('/mail/streaminbox')
def stream_inbox():
def _stream():
while True:
yield "data: " + ','.join(loadinbox.load_inbox()) + "\n\n"
sleep(1)
return sse_wrapper.handle_sse_request(_stream)
@flask_blueprint.route('/mail/getsentbox')
def list_sentbox():
kv.refresh()

View file

@ -15,6 +15,7 @@
<link rel="stylesheet" href="/mail/mail.css">
<script defer src="/shared/node_modules/pnotify/dist/iife/PNotify.js"></script>
<script defer src="/shared/node_modules/pnotify/dist/iife/PNotifyButtons.js"></script>
<script defer src="/shared/eventsource.js"></script>
<script defer src="/shared/main/apicheck.js"></script>
<script defer src="/shared/misc.js"></script>
<script defer src="/mail/sethumanreadable.js"></script>

View file

@ -382,6 +382,9 @@ function refreshPms(callNext){
if (! window.inboxActive){
return
}
if (document.hidden){
return
}
fetch('/mail/getinbox', {
headers: {
"token": webpass
@ -448,3 +451,17 @@ document.addEventListener("visibilitychange", function() {
refreshPms()
}
})
/*
let mailStream = function(){
var streamSource = new EventSourcePolyfill('/mail/streaminbox', {
headers: {
"token": webpass
}
})
streamSource.onmessage = function(e){
console.debug(e.data)
}
}
mailStream()
*/