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

@@ -13,8 +13,8 @@ const utils = require('../../utils');
const helpers = require('../helpers');
const sockets = require('../../socket.io');
const apiHelpers = require('../../api/helpers');
const socketPostHelpers = require('../../socket.io/posts/helpers'); // eehhh...
const socketTopics = require('../../socket.io/topics'); // eehhh...
const Posts = module.exports;
@@ -111,7 +111,7 @@ Posts.purge = async (req, res) => {
});
if (isMainAndLast) {
await socketTopics.doTopicAction('purge', 'event:topic_purged', {
await apiHelpers.doTopicAction('purge', 'event:topic_purged', {
ip: req.ip,
uid: req.user.uid,
}, { tids: [postData.tid], cid: topicData.cid });
@@ -199,12 +199,12 @@ async function isMainAndLastPost(pid) {
async function deleteOrRestoreTopicOf(command, pid, req) {
const topic = await posts.getTopicFields(pid, ['tid', 'cid', 'deleted']);
if (command === 'delete' && !topic.deleted) {
await socketTopics.doTopicAction('delete', 'event:topic_deleted', {
await apiHelpers.doTopicAction('delete', 'event:topic_deleted', {
uid: req.user.uid,
ip: req.ip,
}, { tids: [topic.tid], cid: topic.cid });
} else if (command === 'restore' && topic.deleted) {
await socketTopics.doTopicAction('restore', 'event:topic_restored', {
await apiHelpers.doTopicAction('restore', 'event:topic_restored', {
uid: req.user.uid,
ip: req.ip,
}, { tids: [topic.tid], cid: topic.cid });