Node.js based forum software built for the modern web
closes #6248 , closes #6282
Barış Soner Uşaklı2e2b97033e63
diff --git a/install/package.json b/install/package.jsonindex e57eefeb4e..58a22e7821 100644--- a/install/package.json+++ b/install/package.json@@ -69,7 +69,7 @@"nodebb-plugin-spam-be-gone": "0.5.1","nodebb-rewards-essentials": "0.0.11","nodebb-theme-lavender": "5.0.1",- "nodebb-theme-persona": "7.2.16",+ "nodebb-theme-persona": "7.2.19","nodebb-theme-slick": "1.1.4","nodebb-theme-vanilla": "8.1.7","nodebb-widget-essentials": "4.0.1",diff --git a/public/language/en-GB/topic.json b/public/language/en-GB/topic.jsonindex 657880296c..a4892868b3 100644--- a/public/language/en-GB/topic.json+++ b/public/language/en-GB/topic.json@@ -38,6 +38,7 @@"flag_title": "Flag this post for moderation",+ "merged_message": "This topic has been merged into <a href=\"/topic/%1\">%2</a>","deleted_message": "This topic has been deleted. Only users with topic management privileges can see it.","following_topic.message": "You will now be receiving notifications when somebody posts to this topic.",diff --git a/src/topics.js b/src/topics.jsindex 2ac14e4264..c3475995bd 100644--- a/src/topics.js+++ b/src/topics.js@@ -198,6 +198,7 @@ Topics.getTopicWithPosts = function (topicData, set, uid, start, stop, reverse,bookmark: async.apply(Topics.getUserBookmark, topicData.tid, uid),postSharing: async.apply(social.getActivePostSharing),deleter: async.apply(getDeleter, topicData),+ merger: async.apply(getMerger, topicData),related: function (next) {async.waterfall([function (next) {@@ -223,6 +224,8 @@ Topics.getTopicWithPosts = function (topicData, set, uid, start, stop, reverse,topicData.postSharing = results.postSharing;topicData.deleter = results.deleter;topicData.deletedTimestampISO = utils.toISOString(topicData.deletedTimestamp);+ topicData.merger = results.merger;+ topicData.mergedTimestampISO = utils.toISOString(topicData.mergedTimestamp);topicData.related = results.related || [];topicData.unreplied = parseInt(topicData.postcount, 10) === 1;@@ -290,6 +293,28 @@ function getDeleter(topicData, callback) {user.getUserFields(topicData.deleterUid, ['username', 'userslug', 'picture'], callback);}+function getMerger(topicData, callback) {+ if (!topicData.mergerUid) {+ return setImmediate(callback, null, null);+ }+ async.waterfall([+ function (next) {+ async.parallel({+ merger: function (next) {+ user.getUserFields(topicData.mergerUid, ['username', 'userslug', 'picture'], next);+ },+ mergedIntoTitle: function (next) {+ Topics.getTopicField(topicData.mergeIntoTid, 'title', next);+ },+ }, next);+ },+ function (results, next) {+ results.merger.mergedIntoTitle = results.mergedIntoTitle;+ next(null, results.merger);+ },+ ], callback);+}+Topics.getMainPost = function (tid, uid, callback) {Topics.getMainPosts([tid], uid, function (err, mainPosts) {callback(err, Array.isArray(mainPosts) && mainPosts.length ? mainPosts[0] : null);diff --git a/src/topics/merge.js b/src/topics/merge.jsindex 9fd97f60eb..0477de3b41 100644--- a/src/topics/merge.js+++ b/src/topics/merge.js@@ -26,6 +26,13 @@ module.exports = function (Topics) {function (next) {Topics.delete(tid, uid, next);},+ function (next) {+ Topics.setTopicFields(tid, {+ mergeIntoTid: mergeIntoTid,+ mergerUid: uid,+ mergedTimestamp: Date.now(),+ }, next);+ },], next);}, callback);};