diff --git a/static-data/default-plugins/pms/main.py b/static-data/default-plugins/pms/main.py
index 4a7753ce..0b0a1c5b 100755
--- a/static-data/default-plugins/pms/main.py
+++ b/static-data/default-plugins/pms/main.py
@@ -62,6 +62,7 @@ def on_insertblock(api, data={}):
def on_processblocks(api, data=None):
if data['type'] != 'pm':
return
+ notification_func = notifier.notify
data['block'].decrypt()
metadata = data['block'].bmetadata
@@ -73,10 +74,14 @@ def on_processblocks(api, data=None):
else:
signer = signer[:5]
+
if data['block'].decrypted:
config.reload()
+
+ if config.get('mail.notificationSound', True):
+ notification_func = notifier.notification_with_sound
if config.get('mail.notificationSetting', True):
if not config.get('mail.strangersNotification', True):
if not user.isFriend():
return
- notifier.notification_with_sound(title="Onionr Mail - New Message", message="From: %s\n\nSubject: %s" % (signer, metadata['subject']))
+ notification_func(title="Onionr Mail - New Message", message="From: %s\n\nSubject: %s" % (signer, metadata['subject']))
diff --git a/static-data/www/mail/index.html b/static-data/www/mail/index.html
index a320f552..a67be33f 100755
--- a/static-data/www/mail/index.html
+++ b/static-data/www/mail/index.html
@@ -161,13 +161,13 @@
- Only show notifications for friends
+ Notifications for stranger's messages
@@ -177,9 +177,9 @@
diff --git a/static-data/www/mail/loadsettings.js b/static-data/www/mail/loadsettings.js
index c6608c29..3ec81891 100644
--- a/static-data/www/mail/loadsettings.js
+++ b/static-data/www/mail/loadsettings.js
@@ -17,7 +17,13 @@ fetch('/config/get/mail', {
if (mailSettings.notificationSetting === false){
document.getElementById('notificationSetting').checked = false
}
+ if (mailSettings.notificationSound === false){
+ document.getElementById('notificationSound').checked = false
+ }
if (typeof mailSettings.signature != undefined && mailSettings.signature != null && mailSettings.signature != ""){
document.getElementById('mailSignatureSetting').value = mailSettings.signature
}
+ if (mailSettings.strangersNotification == false){
+ document.getElementById('strangersNotification').checked = false
+ }
})
\ No newline at end of file
diff --git a/static-data/www/mail/settings.js b/static-data/www/mail/settings.js
index 0667a31b..f410660d 100644
--- a/static-data/www/mail/settings.js
+++ b/static-data/www/mail/settings.js
@@ -17,6 +17,8 @@
along with this program. If not, see .
*/
var notificationSetting = document.getElementById('notificationSetting')
+var friendOnlyNotification = document.getElementById('strangersNotification')
+var notificationSound = document.getElementById('notificationSound')
var sigSetting = document.getElementById('mailSignatureSetting')
document.getElementById('forwardSecrecySetting').onchange = function(e){
@@ -37,6 +39,40 @@ document.getElementById('forwardSecrecySetting').onchange = function(e){
})
}
+notificationSound.onchange = function(e){
+ var postData = JSON.stringify({"notificationSound": e.target.checked})
+ fetch('/config/set/mail', {
+ method: 'POST',
+ body: postData,
+ headers: {
+ "content-type": "application/json",
+ "token": webpass
+ }})
+ .then(function(data) {
+ mailSettings['notificationSound'] = notificationSound.checked
+ PNotify.success({
+ text: 'Successfully notification sound'
+ })
+ })
+}
+
+friendOnlyNotification.onchange = function(e){
+ var postData = JSON.stringify({"strangersNotification": e.target.checked})
+ fetch('/config/set/mail', {
+ method: 'POST',
+ body: postData,
+ headers: {
+ "content-type": "application/json",
+ "token": webpass
+ }})
+ .then(function(data) {
+ mailSettings['strangersNotification'] = friendOnlyNotification.checked
+ PNotify.success({
+ text: 'Successfully toggled notifications from strangers'
+ })
+ })
+}
+
notificationSetting.onchange = function(e){
var notificationSettings = document.getElementsByClassName('notificationSetting')