From bb3f98eb05a55fad58fa1725c8814a42f5e3bc52 Mon Sep 17 00:00:00 2001 From: "Misty (Bot)" Date: Sat, 21 Apr 2018 09:26:25 +0000 Subject: [PATCH 01/12] Latest translations and fallbacks --- public/language/zh-CN/admin/settings/post.json | 2 +- public/language/zh-CN/global.json | 2 +- public/language/zh-CN/topic.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/language/zh-CN/admin/settings/post.json b/public/language/zh-CN/admin/settings/post.json index c8bdf3692c..b471b57013 100644 --- a/public/language/zh-CN/admin/settings/post.json +++ b/public/language/zh-CN/admin/settings/post.json @@ -3,7 +3,7 @@ "sorting.post-default": "默认帖子排序", "sorting.oldest-to-newest": "从旧到新", "sorting.newest-to-oldest": "从新到旧", - "sorting.most-votes": "最多投票", + "sorting.most-votes": "最多赞同", "sorting.most-posts": "最多回复", "sorting.topic-default": "默认主题排序", "length": "帖子长度", diff --git a/public/language/zh-CN/global.json b/public/language/zh-CN/global.json index bdb63f6748..a0fddbfdf9 100644 --- a/public/language/zh-CN/global.json +++ b/public/language/zh-CN/global.json @@ -53,7 +53,7 @@ "topics": "主题", "posts": "帖子", "best": "最佳", - "votes": "投票", + "votes": "赞同", "upvoters": "顶的人", "upvoted": "顶", "downvoters": "踩的人", diff --git a/public/language/zh-CN/topic.json b/public/language/zh-CN/topic.json index 19971fde40..0fefa3db42 100644 --- a/public/language/zh-CN/topic.json +++ b/public/language/zh-CN/topic.json @@ -118,7 +118,7 @@ "sort_by": "排序", "oldest_to_newest": "从旧到新", "newest_to_oldest": "从新到旧", - "most_votes": "最多投票", + "most_votes": "最多赞同", "most_posts": "最多回复", "stale.title": "接受建议并创建新主题?", "stale.warning": "您回复的主题已经很古老了,是否发布新主题并引用此主题的内容?", From 6659a520e034c1e41b9335afa6dd0ccd97227269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sun, 22 Apr 2018 09:10:02 -0400 Subject: [PATCH 02/12] closes #6465 --- src/controllers/accounts/settings.js | 13 ++-------- src/controllers/admin/settings.js | 28 +++------------------ src/notifications.js | 30 ++++++++++++++++++++++ src/user/settings.js | 37 +++++++++++++--------------- 4 files changed, 53 insertions(+), 55 deletions(-) diff --git a/src/controllers/accounts/settings.js b/src/controllers/accounts/settings.js index 5166222706..5f5bb57aa7 100644 --- a/src/controllers/accounts/settings.js +++ b/src/controllers/accounts/settings.js @@ -9,6 +9,7 @@ var meta = require('../../meta'); var plugins = require('../../plugins'); var privileges = require('../../privileges'); var categories = require('../../categories'); +var notifications = require('../../notifications'); var db = require('../../database'); var helpers = require('../helpers'); var accountHelpers = require('./helpers'); @@ -180,15 +181,6 @@ settingsController.get = function (req, res, callback) { }; function getNotificationSettings(userData, callback) { - var types = [ - 'notificationType_upvote', - 'notificationType_new-topic', - 'notificationType_new-reply', - 'notificationType_follow', - 'notificationType_new-chat', - 'notificationType_group-invite', - ]; - var privilegedTypes = []; async.waterfall([ @@ -206,8 +198,7 @@ function getNotificationSettings(userData, callback) { privilegedTypes.push('notificationType_new-user-flag'); } plugins.fireHook('filter:user.notificationTypes', { - userData: userData, - types: types, + types: notifications.baseTypes.slice(), privilegedTypes: privilegedTypes, }, next); }, diff --git a/src/controllers/admin/settings.js b/src/controllers/admin/settings.js index 678a9e4e8c..d711e7cdcc 100644 --- a/src/controllers/admin/settings.js +++ b/src/controllers/admin/settings.js @@ -4,7 +4,7 @@ var async = require('async'); var meta = require('../../meta'); var emailer = require('../../emailer'); -var plugins = require('../../plugins'); +var notifications = require('../../notifications'); var settingsController = module.exports; @@ -45,32 +45,12 @@ function renderEmail(req, res, next) { } function renderUser(req, res, next) { - var types = [ - 'notificationType_upvote', - 'notificationType_new-topic', - 'notificationType_new-reply', - 'notificationType_follow', - 'notificationType_new-chat', - 'notificationType_group-invite', - ]; - - var privilegedTypes = [ - 'notificationType_new-register', - 'notificationType_post-queue', - 'notificationType_new-post-flag', - 'notificationType_new-user-flag', - ]; - async.waterfall([ function (next) { - plugins.fireHook('filter:user.notificationTypes', { - userData: {}, - types: types, - privilegedTypes: privilegedTypes, - }, next); + notifications.getAllNotificationTypes(next); }, - function (results) { - var notificationSettings = results.types.concat(results.privilegedTypes).map(function (type) { + function (notificationTypes) { + var notificationSettings = notificationTypes.map(function (type) { return { name: type, label: '[[notifications:' + type + ']]', diff --git a/src/notifications.js b/src/notifications.js index 8a91c44509..a9ef31f734 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -17,6 +17,36 @@ var emailer = require('./emailer'); var Notifications = module.exports; +Notifications.baseTypes = [ + 'notificationType_upvote', + 'notificationType_new-topic', + 'notificationType_new-reply', + 'notificationType_follow', + 'notificationType_new-chat', + 'notificationType_group-invite', +]; + +Notifications.privilegedTypes = [ + 'notificationType_new-register', + 'notificationType_post-queue', + 'notificationType_new-post-flag', + 'notificationType_new-user-flag', +]; + +Notifications.getAllNotificationTypes = function (callback) { + async.waterfall([ + function (next) { + plugins.fireHook('filter:user.notificationTypes', { + types: Notifications.baseTypes.slice(), + privilegedTypes: Notifications.privilegedTypes.slice(), + }, next); + }, + function (results, next) { + next(null, results.types.concat(results.privilegedTypes)); + }, + ], callback); +}; + Notifications.startJobs = function () { winston.verbose('[notifications.init] Registering jobs.'); new cron('*/30 * * * *', Notifications.prune, null, true); diff --git a/src/user/settings.js b/src/user/settings.js index c654d2dd99..202c440d14 100644 --- a/src/user/settings.js +++ b/src/user/settings.js @@ -6,6 +6,7 @@ var async = require('async'); var meta = require('../meta'); var db = require('../database'); var plugins = require('../plugins'); +var notifications = require('../notifications'); module.exports = function (User) { User.getSettings = function (uid, callback) { @@ -81,12 +82,14 @@ 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'); + + notifications.getAllNotificationTypes(next); + }, + function (notificationTypes, next) { + notificationTypes.forEach(function (notificationType) { + settings[notificationType] = getSetting(settings, notificationType, 'notification'); + }); + next(null, settings); }, ], callback); @@ -139,26 +142,20 @@ module.exports = function (User) { upvoteNotifFreq: data.upvoteNotifFreq, }; - var notificationTypes = [ - 'notificationType_upvote', 'notificationType_new-topic', 'notificationType_new-reply', - 'notificationType_follow', 'notificationType_new-chat', 'notificationType_group-invite', - 'notificationType_new-register', 'notificationType_post-queue', 'notificationType_new-post-flag', - 'notificationType_new-user-flag', - ]; - - notificationTypes.forEach(function (notificationType) { - if (data[notificationType]) { - settings[notificationType] = data[notificationType]; - } - }); - - if (data.bootswatchSkin) { settings.bootswatchSkin = data.bootswatchSkin; } async.waterfall([ function (next) { + notifications.getAllNotificationTypes(next); + }, + function (notificationTypes, next) { + notificationTypes.forEach(function (notificationType) { + if (data[notificationType]) { + settings[notificationType] = data[notificationType]; + } + }); plugins.fireHook('filter:user.saveSettings', { settings: settings, data: data }, next); }, function (result, next) { From 9eac794e8e1d96cfb7b86e81ba6b9c50ee7d4a68 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 23 Apr 2018 16:05:33 -0400 Subject: [PATCH 03/12] normalising behaviour for subfolder installs, #6410 --- src/views/500-embed.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/500-embed.tpl b/src/views/500-embed.tpl index d9d9f30d5d..3bd6857048 100644 --- a/src/views/500-embed.tpl +++ b/src/views/500-embed.tpl @@ -1,6 +1,6 @@