fix: missing doTopicAction, fix wrong api params

This commit is contained in:
Barış Soner Uşaklı
2020-10-16 21:36:59 -04:00
parent bc880ee0ca
commit e78c498e84
5 changed files with 69 additions and 63 deletions

View File

@@ -5,7 +5,7 @@ const topics = require('../../topics');
const flags = require('../../flags');
const events = require('../../events');
const websockets = require('../index');
const socketTopics = require('../topics');
const apiHelpers = require('../../api/helpers');
const privileges = require('../../privileges');
const plugins = require('../../plugins');
const social = require('../../social');
@@ -158,16 +158,16 @@ module.exports = function (SocketPosts) {
});
if (isMainAndLast) {
await socketTopics.doTopicAction('purge', 'event:topic_purged', socket, { tids: [postData.tid], cid: topicData.cid });
await apiHelpers.doTopicAction('purge', 'event:topic_purged', socket, { tids: [postData.tid], cid: topicData.cid });
}
};
async function deleteOrRestoreTopicOf(command, pid, socket) {
const topic = await posts.getTopicFields(pid, ['tid', 'cid', 'deleted']);
if (command === 'delete' && !topic.deleted) {
await socketTopics.doTopicAction('delete', 'event:topic_deleted', socket, { tids: [topic.tid], cid: topic.cid });
await apiHelpers.doTopicAction('delete', 'event:topic_deleted', socket, { tids: [topic.tid], cid: topic.cid });
} else if (command === 'restore' && topic.deleted) {
await socketTopics.doTopicAction('restore', 'event:topic_restored', socket, { tids: [topic.tid], cid: topic.cid });
await apiHelpers.doTopicAction('restore', 'event:topic_restored', socket, { tids: [topic.tid], cid: topic.cid });
}
}