mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-05 15:20:39 +01:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
830c59eb4f | ||
|
|
60ba66c0a3 | ||
|
|
6349fa03e1 | ||
|
|
4b38533b15 | ||
|
|
066b442e18 | ||
|
|
bb3aa54006 | ||
|
|
a024cc1344 | ||
|
|
0595e71078 | ||
|
|
89b010249d | ||
|
|
8591f5d2cc | ||
|
|
5fd05dc942 | ||
|
|
c4bdeae06e | ||
|
|
87ce31d1f5 | ||
|
|
cd1375cbd5 | ||
|
|
dde830db9a | ||
|
|
a255c8f6fd |
@@ -45,6 +45,9 @@ module.exports = function (grunt) {
|
||||
if (!plugins.includes('nodebb-plugin-composer-default')) {
|
||||
plugins.push('nodebb-plugin-composer-default');
|
||||
}
|
||||
if (!plugins.includes('nodebb-theme-persona')) {
|
||||
plugins.push('nodebb-theme-persona');
|
||||
}
|
||||
}
|
||||
|
||||
const styleUpdated_Client = plugins.map(p => 'node_modules/' + p + '/*.less')
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "nodebb",
|
||||
"license": "GPL-3.0",
|
||||
"description": "NodeBB Forum",
|
||||
"version": "1.14.0-4",
|
||||
"version": "1.14.0-5",
|
||||
"homepage": "http://www.nodebb.org",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -79,7 +79,7 @@
|
||||
"mousetrap": "^1.6.5",
|
||||
"@nodebb/mubsub": "^1.6.0",
|
||||
"nconf": "^0.10.0",
|
||||
"nodebb-plugin-composer-default": "6.3.40",
|
||||
"nodebb-plugin-composer-default": "6.3.41",
|
||||
"nodebb-plugin-dbsearch": "4.0.7",
|
||||
"nodebb-plugin-emoji": "^3.3.0",
|
||||
"nodebb-plugin-emoji-android": "2.0.0",
|
||||
@@ -98,7 +98,7 @@
|
||||
"passport-local": "1.0.0",
|
||||
"pg": "^8.0.2",
|
||||
"pg-cursor": "^2.1.9",
|
||||
"postcss": "7.0.30",
|
||||
"postcss": "7.0.32",
|
||||
"postcss-clean": "1.1.0",
|
||||
"promise-polyfill": "^8.1.3",
|
||||
"prompt": "^1.0.0",
|
||||
@@ -136,7 +136,7 @@
|
||||
"@commitlint/cli": "8.3.5",
|
||||
"@commitlint/config-angular": "8.3.4",
|
||||
"coveralls": "3.1.0",
|
||||
"eslint": "7.1.0",
|
||||
"eslint": "7.2.0",
|
||||
"eslint-config-airbnb-base": "14.1.0",
|
||||
"eslint-plugin-import": "2.21.1",
|
||||
"grunt": "1.1.0",
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"hsts.preload": "Allow preloading of HSTS header",
|
||||
"hsts.help": "If enabled, an HSTS header will be set for this site. You can elect to include subdomains and preloading flags in your header. If in doubt, you can leave these unchecked. <a href=\"%1\">More information <i class=\"fa fa-external-link\"></i></a>",
|
||||
"traffic-management": "Traffic Management",
|
||||
"traffic.help": "NodeBB deploys equipped with a module that automatically denies requests in high-traffic situations. You can tune these settings here, although the defaults are a good starting point.",
|
||||
"traffic.help": "NodeBB uses a module that automatically denies requests in high-traffic situations. You can tune these settings here, although the defaults are a good starting point.",
|
||||
"traffic.enable": "Enable Traffic Management",
|
||||
"traffic.event-lag": "Event Loop Lag Threshold (in milliseconds)",
|
||||
"traffic.event-lag-help": "Lowering this value decreases wait times for page loads, but will also show the \"excessive load\" message to more users. (Restart required)",
|
||||
|
||||
@@ -115,7 +115,11 @@
|
||||
"fork_pid_count": "%1 post(s) selected",
|
||||
"fork_success": "Successfully forked topic! Click here to go to the forked topic.",
|
||||
"delete_posts_instruction": "Click the posts you want to delete/purge",
|
||||
"merge_topics_instruction": "Click the topics you want to merge",
|
||||
"merge_topics_instruction": "Click the topics you want to merge or search for them",
|
||||
"merge-topic-list-title": "List of topics to be merged",
|
||||
"merge-options": "Merge options",
|
||||
"merge-select-main-topic": "Select the main topic",
|
||||
"merge-new-title-for-topic": "New title for topic",
|
||||
"move_posts_instruction": "Click the posts you want to move",
|
||||
"change_owner_instruction": "Click the posts you want to assign to another user",
|
||||
|
||||
|
||||
@@ -99,7 +99,11 @@
|
||||
"fork_pid_count": "%1 post(s) selected",
|
||||
"fork_success": "Successfully forked topic! Click here to go to the forked topic.",
|
||||
"delete_posts_instruction": "Click the posts you want to delete/purge",
|
||||
"merge_topics_instruction": "Click the topics you want to merge",
|
||||
"merge_topics_instruction": "Click the topics you want to merge or search for them",
|
||||
"merge-topic-list-title": "List of topics to be merged",
|
||||
"merge-options": "Merge options",
|
||||
"merge-select-main-topic": "Select the main topic",
|
||||
"merge-new-title-for-topic": "New title for topic",
|
||||
"move_posts_instruction": "Click the posts you want to move",
|
||||
"change_owner_instruction": "Click the posts you want to assign to another user",
|
||||
"composer.title_placeholder": "Enter your topic title here...",
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
$('[component="logout"]').on('click', function () {
|
||||
app.logout();
|
||||
return false;
|
||||
});
|
||||
|
||||
configureSlidemenu();
|
||||
|
||||
@@ -478,34 +478,87 @@ app.cacheBuster = null;
|
||||
}
|
||||
|
||||
app.enableTopicSearch = function (options) {
|
||||
var quickSearchResults = options.resultEl;
|
||||
var inputEl = options.inputEl;
|
||||
/* eslint-disable-next-line */
|
||||
var searchOptions = Object.assign({ in: 'titles' }, options.searchOptions);
|
||||
var quickSearchResults = options.searchElements.resultEl;
|
||||
var inputEl = options.searchElements.inputEl;
|
||||
var searchTimeoutId = 0;
|
||||
var currentVal = inputEl.val();
|
||||
var oldValue = inputEl.val();
|
||||
|
||||
function doSearch() {
|
||||
require(['search'], function (search) {
|
||||
/* eslint-disable-next-line */
|
||||
options.searchOptions = Object.assign({}, searchOptions);
|
||||
options.searchOptions.term = inputEl.val();
|
||||
$(window).trigger('action:search.quick.start', options);
|
||||
options.searchOptions.searchOnly = 1;
|
||||
search.api(options.searchOptions, function (data) {
|
||||
var resultEl = options.searchElements.resultEl;
|
||||
if (options.hideOnNoMatches && !data.posts.length) {
|
||||
return resultEl.addClass('hidden').find('.quick-search-results-container').html('');
|
||||
}
|
||||
data.posts.forEach(function (p) {
|
||||
p.snippet = utils.escapeHTML($('<div>' + p.content + '</div>').text().slice(0, 80) + '...');
|
||||
});
|
||||
app.parseAndTranslate('partials/quick-search-results', data, function (html) {
|
||||
if (html.length) {
|
||||
html.find('.timeago').timeago();
|
||||
}
|
||||
resultEl.toggleClass('hidden', !html.length)
|
||||
.find('.quick-search-results-container')
|
||||
.html(html.length ? html : '');
|
||||
$(window).trigger('action:search.quick.complete', {
|
||||
data: data,
|
||||
options: options,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
inputEl.off('keyup').on('keyup', function () {
|
||||
if (searchTimeoutId) {
|
||||
clearTimeout(searchTimeoutId);
|
||||
searchTimeoutId = 0;
|
||||
}
|
||||
searchTimeoutId = setTimeout(function () {
|
||||
if (inputEl.val().length < 3 || inputEl.val() === currentVal) {
|
||||
if (inputEl.val().length < 3) {
|
||||
quickSearchResults.addClass('hidden');
|
||||
oldValue = inputEl.val();
|
||||
return;
|
||||
}
|
||||
currentVal = inputEl.val();
|
||||
if (inputEl.val() === oldValue) {
|
||||
return;
|
||||
}
|
||||
oldValue = inputEl.val();
|
||||
if (!inputEl.is(':focus')) {
|
||||
return quickSearchResults.addClass('hidden');
|
||||
}
|
||||
require(['search'], function (search) {
|
||||
search.quick({
|
||||
term: inputEl.val(),
|
||||
in: 'titles',
|
||||
}, options);
|
||||
});
|
||||
doSearch();
|
||||
}, 250);
|
||||
});
|
||||
|
||||
inputEl.on('blur', function () {
|
||||
setTimeout(function () {
|
||||
if (!inputEl.is(':focus')) {
|
||||
quickSearchResults.addClass('hidden');
|
||||
}
|
||||
}, 200);
|
||||
});
|
||||
|
||||
inputEl.on('focus', function () {
|
||||
if (inputEl.val() && quickSearchResults.find('#quick-search-results').children().length) {
|
||||
quickSearchResults.removeClass('hidden');
|
||||
}
|
||||
});
|
||||
|
||||
inputEl.off('refresh').on('refresh', function () {
|
||||
doSearch();
|
||||
});
|
||||
};
|
||||
|
||||
app.handleSearch = function () {
|
||||
app.handleSearch = function (searchOptions) {
|
||||
searchOptions = searchOptions || { in: 'titles' };
|
||||
var searchButton = $('#search-button');
|
||||
var searchFields = $('#search-fields');
|
||||
var searchInput = $('#search-fields input');
|
||||
@@ -519,23 +572,21 @@ app.cacheBuster = null;
|
||||
searchInput.blur();
|
||||
});
|
||||
searchInput.off('blur').on('blur', dismissSearch);
|
||||
searchInput.off('focus').on('focus', function () {
|
||||
if (searchInput.val() && quickSearchContainer.find('#quick-search-results').children().length) {
|
||||
quickSearchContainer.removeClass('hidden');
|
||||
}
|
||||
});
|
||||
searchInput.off('focus');
|
||||
|
||||
app.enableTopicSearch({
|
||||
var searchElements = {
|
||||
inputEl: searchInput,
|
||||
resultEl: quickSearchContainer,
|
||||
};
|
||||
|
||||
app.enableTopicSearch({
|
||||
searchOptions: searchOptions,
|
||||
searchElements: searchElements,
|
||||
});
|
||||
|
||||
function dismissSearch() {
|
||||
searchFields.addClass('hidden');
|
||||
searchButton.removeClass('hidden');
|
||||
setTimeout(function () {
|
||||
quickSearchContainer.addClass('hidden');
|
||||
}, 200);
|
||||
}
|
||||
|
||||
searchButton.off('click').on('click', function (e) {
|
||||
@@ -558,7 +609,10 @@ app.cacheBuster = null;
|
||||
require(['search'], function (search) {
|
||||
var data = search.getSearchPreferences();
|
||||
data.term = input.val();
|
||||
$(window).trigger('action:search.submit', { data: data });
|
||||
$(window).trigger('action:search.submit', {
|
||||
searchOptions: data,
|
||||
searchElements: searchElements,
|
||||
});
|
||||
search.query(data, function () {
|
||||
input.val('');
|
||||
});
|
||||
|
||||
@@ -8,7 +8,8 @@ define('forum/topic/merge', function () {
|
||||
|
||||
var selectedTids = {};
|
||||
|
||||
Merge.init = function () {
|
||||
Merge.init = function (callback) {
|
||||
callback = callback || function () {};
|
||||
if (modal) {
|
||||
return;
|
||||
}
|
||||
@@ -28,11 +29,29 @@ define('forum/topic/merge', function () {
|
||||
mergeBtn.on('click', function () {
|
||||
mergeTopics(mergeBtn);
|
||||
});
|
||||
|
||||
app.enableTopicSearch({
|
||||
searchElements: {
|
||||
inputEl: modal.find('.topic-search-input'),
|
||||
resultEl: modal.find('.quick-search-container'),
|
||||
},
|
||||
searchOptions: {
|
||||
in: 'titles',
|
||||
},
|
||||
});
|
||||
modal.on('click', '[data-tid]', function () {
|
||||
if ($(this).attr('data-tid')) {
|
||||
Merge.addTopic($(this).attr('data-tid'));
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
function onTopicClicked(ev) {
|
||||
var tid = $(this).parents('[component="category/topic"]').attr('data-tid');
|
||||
Merge.addTopic = function (tid, callback) {
|
||||
callback = callback || function () {};
|
||||
socket.emit('topics.getTopic', tid, function (err, topicData) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
@@ -45,7 +64,14 @@ define('forum/topic/merge', function () {
|
||||
}
|
||||
checkButtonEnable();
|
||||
showTopicsSelected();
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
function onTopicClicked(ev) {
|
||||
var tid = $(this).parents('[component="category/topic"]').attr('data-tid');
|
||||
Merge.addTopic(tid);
|
||||
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
return false;
|
||||
@@ -54,12 +80,19 @@ define('forum/topic/merge', function () {
|
||||
function mergeTopics(btn) {
|
||||
btn.attr('disabled', true);
|
||||
var tids = Object.keys(selectedTids);
|
||||
socket.emit('topics.merge', tids, function (err) {
|
||||
var options = {};
|
||||
if (modal.find('.merge-main-topic-radio').is(':checked')) {
|
||||
options.mainTid = modal.find('.merge-main-topic-select').val();
|
||||
} else if (modal.find('.merge-new-title-radio').is(':checked')) {
|
||||
options.newTopicTitle = modal.find('.merge-new-title-input').val();
|
||||
}
|
||||
|
||||
socket.emit('topics.merge', { tids: tids, options: options }, function (err, tid) {
|
||||
btn.removeAttr('disabled');
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
ajaxify.go('/topic/' + tids[0]);
|
||||
ajaxify.go('/topic/' + tid);
|
||||
closeModal();
|
||||
});
|
||||
}
|
||||
@@ -75,8 +108,12 @@ define('forum/topic/merge', function () {
|
||||
});
|
||||
|
||||
if (tids.length) {
|
||||
app.parseAndTranslate('partials/merge_topics_modal', 'topics', { topics: topics }, function (html) {
|
||||
modal.find('.topics-section').html(html);
|
||||
app.parseAndTranslate('partials/merge_topics_modal', {
|
||||
config: config,
|
||||
topics: topics,
|
||||
}, function (html) {
|
||||
modal.find('.topics-section').html(html.find('.topics-section').html());
|
||||
modal.find('.merge-main-topic-select').html(html.find('.merge-main-topic-select').html());
|
||||
});
|
||||
} else {
|
||||
modal.find('.topics-section').translateHtml('[[error:no-topics-selected]]');
|
||||
|
||||
@@ -33,31 +33,6 @@ define('search', ['navigator', 'translator', 'storage'], function (nav, translat
|
||||
});
|
||||
};
|
||||
|
||||
Search.quick = function (query, options, callback) {
|
||||
callback = callback || function () {};
|
||||
var template = options.template || 'partials/quick-search-results';
|
||||
$(window).trigger('action:search.quick.start', { data: query });
|
||||
query.searchOnly = 1;
|
||||
Search.api(query, function (data) {
|
||||
if (options.hideOnNoMatches && !data.posts.length) {
|
||||
return options.resultEl.addClass('hidden').find('#quick-search-results-container').html('');
|
||||
}
|
||||
data.posts.forEach(function (p) {
|
||||
p.snippet = utils.escapeHTML($('<div>' + p.content + '</div>').text().slice(0, 80) + '...');
|
||||
});
|
||||
app.parseAndTranslate(template, data, function (html) {
|
||||
if (html.length) {
|
||||
html.find('.timeago').timeago();
|
||||
options.resultEl.removeClass('hidden').find('#quick-search-results-container').html(html);
|
||||
} else {
|
||||
options.resultEl.addClass('hidden').find('#quick-search-results-container').html('');
|
||||
}
|
||||
$(window).trigger('action:search.quick.complete', { data: data });
|
||||
callback();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function createQueryString(data) {
|
||||
var searchIn = data.in || 'titlesposts';
|
||||
var postedBy = data.by || '';
|
||||
|
||||
@@ -8,6 +8,7 @@ const db = require('../database');
|
||||
const user = require('../user');
|
||||
const batch = require('../batch');
|
||||
const meta = require('../meta');
|
||||
const cache = require('../cache');
|
||||
|
||||
|
||||
module.exports = function (Groups) {
|
||||
@@ -180,6 +181,7 @@ module.exports = function (Groups) {
|
||||
const allGroups = await db.getSortedSetRange('groups:createtime', 0, -1);
|
||||
const keys = allGroups.map(group => 'group:' + group + ':members');
|
||||
await renameGroupsMember(keys, oldName, newName);
|
||||
cache.del(keys);
|
||||
|
||||
await db.rename('group:' + oldName, 'group:' + newName);
|
||||
await db.rename('group:' + oldName + ':members', 'group:' + newName + ':members');
|
||||
|
||||
@@ -4,14 +4,18 @@ const topics = require('../../topics');
|
||||
const privileges = require('../../privileges');
|
||||
|
||||
module.exports = function (SocketTopics) {
|
||||
SocketTopics.merge = async function (socket, tids) {
|
||||
if (!Array.isArray(tids)) {
|
||||
SocketTopics.merge = async function (socket, data) {
|
||||
if (!data || !Array.isArray(data.tids)) {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
}
|
||||
const allowed = await Promise.all(tids.map(tid => privileges.topics.isAdminOrMod(tid, socket.uid)));
|
||||
const allowed = await Promise.all(data.tids.map(tid => privileges.topics.isAdminOrMod(tid, socket.uid)));
|
||||
if (allowed.includes(false)) {
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
}
|
||||
await topics.merge(tids, socket.uid);
|
||||
if (data.options && data.options.mainTid && !data.tids.includes(data.options.mainTid)) {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
}
|
||||
const mergeIntoTid = await topics.merge(data.tids, socket.uid, data.options);
|
||||
return mergeIntoTid;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -4,10 +4,18 @@ const async = require('async');
|
||||
const plugins = require('../plugins');
|
||||
|
||||
module.exports = function (Topics) {
|
||||
Topics.merge = async function (tids, uid) {
|
||||
const mergeIntoTid = findOldestTopic(tids);
|
||||
Topics.merge = async function (tids, uid, options) {
|
||||
options = options || {};
|
||||
const oldestTid = findOldestTopic(tids);
|
||||
let mergeIntoTid = oldestTid;
|
||||
if (options.mainTid) {
|
||||
mergeIntoTid = options.mainTid;
|
||||
} else if (options.newTopicTitle) {
|
||||
mergeIntoTid = await createNewTopic(options.newTopicTitle, oldestTid);
|
||||
}
|
||||
|
||||
const otherTids = tids.filter(tid => tid && parseInt(tid, 10) !== parseInt(mergeIntoTid, 10));
|
||||
const otherTids = tids.sort((a, b) => a - b)
|
||||
.filter(tid => tid && parseInt(tid, 10) !== parseInt(mergeIntoTid, 10));
|
||||
|
||||
await async.eachSeries(otherTids, async function (tid) {
|
||||
const pids = await Topics.getPids(tid);
|
||||
@@ -25,8 +33,19 @@ module.exports = function (Topics) {
|
||||
});
|
||||
|
||||
plugins.fireHook('action:topic.merge', { uid: uid, tids: tids, mergeIntoTid: mergeIntoTid, otherTids: otherTids });
|
||||
return mergeIntoTid;
|
||||
};
|
||||
|
||||
async function createNewTopic(title, oldestTid) {
|
||||
const topicData = await Topics.getTopicFields(oldestTid, ['uid', 'cid']);
|
||||
const tid = await Topics.create({
|
||||
uid: topicData.uid,
|
||||
cid: topicData.cid,
|
||||
title: title,
|
||||
});
|
||||
return tid;
|
||||
}
|
||||
|
||||
function findOldestTopic(tids) {
|
||||
return Math.min.apply(null, tids);
|
||||
}
|
||||
|
||||
@@ -2080,6 +2080,11 @@ describe('Topic\'s', function () {
|
||||
var topic1Data;
|
||||
var topic2Data;
|
||||
|
||||
async function getTopic(tid) {
|
||||
const topicData = await topics.getTopicData(tid);
|
||||
return await topics.getTopicWithPosts(topicData, 'tid:' + topicData.tid + ':posts', adminUid, 0, 19, false);
|
||||
}
|
||||
|
||||
before(function (done) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
@@ -2111,18 +2116,17 @@ describe('Topic\'s', function () {
|
||||
});
|
||||
|
||||
it('should error if user does not have privileges', function (done) {
|
||||
socketTopics.merge({ uid: 0 }, [topic2Data.tid, topic1Data.tid], function (err) {
|
||||
socketTopics.merge({ uid: 0 }, { tids: [topic2Data.tid, topic1Data.tid] }, function (err) {
|
||||
assert.equal(err.message, '[[error:no-privileges]]');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should merge 2 topics', async function () {
|
||||
await socketTopics.merge({ uid: adminUid }, [topic2Data.tid, topic1Data.tid]);
|
||||
async function getTopic(tid) {
|
||||
const topicData = await topics.getTopicData(tid);
|
||||
return await topics.getTopicWithPosts(topicData, 'tid:' + topicData.tid + ':posts', adminUid, 0, 19, false);
|
||||
}
|
||||
await socketTopics.merge({ uid: adminUid }, {
|
||||
tids: [topic2Data.tid, topic1Data.tid],
|
||||
});
|
||||
|
||||
const [topic1, topic2] = await Promise.all([
|
||||
getTopic(topic1Data.tid),
|
||||
getTopic(topic2Data.tid),
|
||||
@@ -2136,6 +2140,7 @@ describe('Topic\'s', function () {
|
||||
assert.equal(topic1.posts[1].content, 'topic 2 OP');
|
||||
assert.equal(topic1.posts[2].content, 'topic 1 reply');
|
||||
assert.equal(topic1.posts[3].content, 'topic 2 reply');
|
||||
assert.equal(topic1.title, 'topic 1');
|
||||
});
|
||||
|
||||
it('should return properly for merged topic', function (done) {
|
||||
@@ -2147,6 +2152,65 @@ describe('Topic\'s', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should merge 2 topics with options mainTid', async function () {
|
||||
const topic1Result = await topics.post({ uid: uid, cid: categoryObj.cid, title: 'topic 1', content: 'topic 1 OP' });
|
||||
const topic2Result = await topics.post({ uid: uid, cid: categoryObj.cid, title: 'topic 2', content: 'topic 2 OP' });
|
||||
await topics.reply({ uid: uid, content: 'topic 1 reply', tid: topic1Result.topicData.tid });
|
||||
await topics.reply({ uid: uid, content: 'topic 2 reply', tid: topic2Result.topicData.tid });
|
||||
await socketTopics.merge({ uid: adminUid }, {
|
||||
tids: [topic2Result.topicData.tid, topic1Result.topicData.tid],
|
||||
options: {
|
||||
mainTid: topic2Result.topicData.tid,
|
||||
},
|
||||
});
|
||||
|
||||
const [topic1, topic2] = await Promise.all([
|
||||
getTopic(topic1Result.topicData.tid),
|
||||
getTopic(topic2Result.topicData.tid),
|
||||
]);
|
||||
|
||||
assert.equal(topic1.posts.length, 0);
|
||||
assert.equal(topic2.posts.length, 4);
|
||||
assert.equal(topic1.deleted, true);
|
||||
|
||||
assert.equal(topic2.posts[0].content, 'topic 2 OP');
|
||||
assert.equal(topic2.posts[1].content, 'topic 1 OP');
|
||||
assert.equal(topic2.posts[2].content, 'topic 1 reply');
|
||||
assert.equal(topic2.posts[3].content, 'topic 2 reply');
|
||||
assert.equal(topic2.title, 'topic 2');
|
||||
});
|
||||
|
||||
it('should merge 2 topics with options newTopicTitle', async function () {
|
||||
const topic1Result = await topics.post({ uid: uid, cid: categoryObj.cid, title: 'topic 1', content: 'topic 1 OP' });
|
||||
const topic2Result = await topics.post({ uid: uid, cid: categoryObj.cid, title: 'topic 2', content: 'topic 2 OP' });
|
||||
await topics.reply({ uid: uid, content: 'topic 1 reply', tid: topic1Result.topicData.tid });
|
||||
await topics.reply({ uid: uid, content: 'topic 2 reply', tid: topic2Result.topicData.tid });
|
||||
const mergeTid = await socketTopics.merge({ uid: adminUid }, {
|
||||
tids: [topic2Result.topicData.tid, topic1Result.topicData.tid],
|
||||
options: {
|
||||
newTopicTitle: 'new merge topic',
|
||||
},
|
||||
});
|
||||
|
||||
const [topic1, topic2, topic3] = await Promise.all([
|
||||
getTopic(topic1Result.topicData.tid),
|
||||
getTopic(topic2Result.topicData.tid),
|
||||
getTopic(mergeTid),
|
||||
]);
|
||||
|
||||
assert.equal(topic1.posts.length, 0);
|
||||
assert.equal(topic2.posts.length, 0);
|
||||
assert.equal(topic3.posts.length, 4);
|
||||
assert.equal(topic1.deleted, true);
|
||||
assert.equal(topic2.deleted, true);
|
||||
|
||||
assert.equal(topic3.posts[0].content, 'topic 1 OP');
|
||||
assert.equal(topic3.posts[1].content, 'topic 2 OP');
|
||||
assert.equal(topic3.posts[2].content, 'topic 1 reply');
|
||||
assert.equal(topic3.posts[3].content, 'topic 2 reply');
|
||||
assert.equal(topic3.title, 'new merge topic');
|
||||
});
|
||||
});
|
||||
|
||||
describe('sorted topics', function () {
|
||||
|
||||
Reference in New Issue
Block a user