work on mail settings

This commit is contained in:
Kevin Froman 2020-02-24 04:45:29 -06:00
parent 56e86460d1
commit 6f0ef390a7
6 changed files with 36 additions and 28 deletions

View File

@ -42,7 +42,7 @@ def update_block_info(hash, key, data):
conn = sqlite3.connect(dbfiles.block_meta_db, timeout=onionrvalues.DATABASE_LOCK_TIMEOUT) conn = sqlite3.connect(dbfiles.block_meta_db, timeout=onionrvalues.DATABASE_LOCK_TIMEOUT)
c = conn.cursor() c = conn.cursor()
args = (data, hash) args = (data, hash)
# Unfortunately, not really possible # Unfortunately, not really possible to prepare this statement
c.execute("UPDATE hashes SET " + key + " = ? where hash = ?;", args) c.execute("UPDATE hashes SET " + key + " = ? where hash = ?;", args)
conn.commit() conn.commit()
conn.close() conn.close()

View File

@ -10,6 +10,7 @@ import json
from onionrusers import contactmanager from onionrusers import contactmanager
from utils import reconstructhash from utils import reconstructhash
from onionrutils import bytesconverter from onionrutils import bytesconverter
import config
import notifier import notifier
""" """
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
@ -72,4 +73,5 @@ def on_processblocks(api, data=None):
signer = signer[:5] signer = signer[:5]
if data['block'].decrypted: if data['block'].decrypted:
if config.get('mail.notificationSetting', True):
notifier.notification_with_sound(title="Onionr Mail - New Message", message="From: %s\n\nSubject: %s" % (signer, metadata['subject'])) notifier.notification_with_sound(title="Onionr Mail - New Message", message="From: %s\n\nSubject: %s" % (signer, metadata['subject']))

View File

@ -10,15 +10,15 @@
}, },
"general": { "general": {
"announce_node": true, "announce_node": true,
"dev_mode": false, "dev_mode": true,
"display_header": true, "display_header": true,
"hide_created_blocks": true, "hide_created_blocks": true,
"insert_deniable_blocks": true, "insert_deniable_blocks": false,
"max_block_age": 2678400, "max_block_age": 2678400,
"minimum_block_pow": 5, "minimum_block_pow": 4,
"minimum_send_pow": 5, "minimum_send_pow": 4,
"public_key": "", "public_key": "",
"random_bind_ip": true, "random_bind_ip": false,
"security_level": 0, "security_level": 0,
"show_notifications": true, "show_notifications": true,
"socket_servers": false, "socket_servers": false,
@ -33,12 +33,12 @@
}, },
"file": { "file": {
"output": true, "output": true,
"remove_on_exit": true "remove_on_exit": false
}, },
"verbosity": "default" "verbosity": "default"
}, },
"onboarding": { "onboarding": {
"done": false "done": true
}, },
"peers": { "peers": {
"max_connect": 1000, "max_connect": 1000,
@ -58,11 +58,11 @@
"tor": { "tor": {
"bridge_fingerprint": "", "bridge_fingerprint": "",
"bridge_ip": "", "bridge_ip": "",
"existing_control_password": "", "existing_control_password": "testt",
"existing_control_port": 0, "existing_control_port": 1338,
"existing_socks_port": 0, "existing_socks_port": 1337,
"use_bridge": false, "use_bridge": false,
"use_existing_tor": false, "use_existing_tor": true,
"v3onions": true "v3onions": true
}, },
"transports": { "transports": {

View File

@ -166,18 +166,6 @@
</div> </div>
</div> </div>
</div> </div>
<div class="columns">
<div class="column">
Keep messages when blocks are deleted
</div>
<div class="column is-2">
<div class="field">
<input id="maintainMessagesSetting" type="checkbox"
class="switch is-rounded">
<label for="maintainMessagesSetting"></label>
</div>
</div>
</div>
<div class="columns"> <div class="columns">
<div class="column"> <div class="column">
Inbox notifications Inbox notifications

View File

@ -14,4 +14,7 @@ fetch('/config/get/mail', {
if (mailSettings.use_padding === false){ if (mailSettings.use_padding === false){
document.getElementById('messagePaddingSetting').checked = false document.getElementById('messagePaddingSetting').checked = false
} }
if (mailSettings.notificationSetting === false){
document.getElementById('notificationSetting').checked = false
}
}) })

View File

@ -37,7 +37,7 @@ document.getElementById('forwardSecrecySetting').onchange = function(e){
notificationSetting.onchange = function(e){ notificationSetting.onchange = function(e){
let notificationSettings = document.getElementsByClassName('notificationSetting') var notificationSettings = document.getElementsByClassName('notificationSetting')
if (e.target.checked){ if (e.target.checked){
for (i = 0; i < notificationSettings.length; i++){ for (i = 0; i < notificationSettings.length; i++){
notificationSettings[i].style.display = "flex" notificationSettings[i].style.display = "flex"
@ -48,4 +48,19 @@ notificationSetting.onchange = function(e){
notificationSettings[i].style.display = "none" notificationSettings[i].style.display = "none"
} }
} }
var postData = JSON.stringify({"notificationSetting": e.target.checked})
fetch('/config/set/mail', {
method: 'POST',
body: postData,
headers: {
"content-type": "application/json",
"token": webpass
}})
.then((resp) => resp.text())
.then(function(data) {
mailSettings['notificationSetting'] = notificationSetting.checked
PNotify.success({
text: 'Successfully toggled default mail notifications'
})
})
} }