diff --git a/install/data/defaults.json b/install/data/defaults.json index 3d45ff6565..547adb1334 100644 --- a/install/data/defaults.json +++ b/install/data/defaults.json @@ -38,5 +38,11 @@ "bookmarkThreshold": 5, "topicsPerList": 20, "autoDetectLang": 1, - "min:rep:flag": 0 + "min:rep:flag": 0, + "notificationType_upvote": "notification", + "notificationType_new-topic": "notification", + "notificationType_new-reply": "notification", + "notificationType_follow": "notification", + "notificationType_new-chat": "notification", + "notificationType_group-invite": "notification" } diff --git a/public/language/en-GB/admin/settings/user.json b/public/language/en-GB/admin/settings/user.json index cbdd4ee91c..664bff67f7 100644 --- a/public/language/en-GB/admin/settings/user.json +++ b/public/language/en-GB/admin/settings/user.json @@ -62,5 +62,6 @@ "email-chat-notifs": "Send an email if a new chat message arrives and I am not online", "email-post-notif": "Send an email when replies are made to topics I am subscribed to", "follow-created-topics": "Follow topics you create", - "follow-replied-topics": "Follow topics that you reply to" + "follow-replied-topics": "Follow topics that you reply to", + "default-notification-settings": "Default notification settings" } \ No newline at end of file diff --git a/src/controllers/accounts/settings.js b/src/controllers/accounts/settings.js index 39828c5350..5166222706 100644 --- a/src/controllers/accounts/settings.js +++ b/src/controllers/accounts/settings.js @@ -213,7 +213,7 @@ function getNotificationSettings(userData, callback) { }, function (results, next) { function modifyType(type) { - var setting = userData.settings[type] || 'notification'; + var setting = userData.settings[type]; return { name: type, diff --git a/src/upgrades/1.7.6/notification_types.js b/src/upgrades/1.7.6/notification_types.js new file mode 100644 index 0000000000..156acc3769 --- /dev/null +++ b/src/upgrades/1.7.6/notification_types.js @@ -0,0 +1,26 @@ +'use strict'; + +var async = require('async'); +var db = require('../../database'); + +module.exports = { + name: 'Add default settings for notification delivery types', + timestamp: Date.UTC(2018, 1, 14), + method: function (callback) { + async.waterfall([ + function (next) { + db.getObject('config', next); + }, + function (config, next) { + db.setObject('config', { + notificationType_upvote: config.notificationType_upvote || 'notification', + 'notificationType_new-topic': config.notificationType_upvote || 'notification', + 'notificationType_new-reply': config.notificationType_upvote || 'notification', + notificationType_follow: config.notificationType_upvote || 'notification', + 'notificationType_new-chat': config.notificationType_upvote || 'notification', + 'notificationType_group-invite': config.notificationType_upvote || 'notification', + }, next); + }, + ], callback); + }, +}; diff --git a/src/user/settings.js b/src/user/settings.js index cac4430fbc..4268db7515 100644 --- a/src/user/settings.js +++ b/src/user/settings.js @@ -81,6 +81,12 @@ module.exports = function (User) { settings.delayImageLoading = parseInt(getSetting(settings, 'delayImageLoading', 1), 10) === 1; settings.bootswatchSkin = settings.bootswatchSkin || meta.config.bootswatchSkin || 'default'; settings.scrollToMyPost = parseInt(getSetting(settings, 'scrollToMyPost', 1), 10) === 1; + settings.notificationType_upvote = getSetting(settings, 'notificationType_upvote', 'notification'); + settings['notificationType_new-topic'] = getSetting(settings, 'notificationType_new-topic', 'notification'); + settings['notificationType_new-reply'] = getSetting(settings, 'notificationType_new-reply', 'notification'); + settings.notificationType_follow = getSetting(settings, 'notificationType_follow', 'notification'); + settings['notificationType_new-chat'] = getSetting(settings, 'notificationType_new-chat', 'notification'); + settings['notificationType_group-invite'] = getSetting(settings, 'notificationType_group-invite', 'notification'); next(null, settings); }, ], callback); diff --git a/src/views/admin/settings/user.tpl b/src/views/admin/settings/user.tpl index 8b2528624e..02286cc636 100644 --- a/src/views/admin/settings/user.tpl +++ b/src/views/admin/settings/user.tpl @@ -232,7 +232,6 @@