mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: #8249, don't send move notifications for deleted posts/topics
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
const privileges = require('../../privileges');
|
||||
const topics = require('../../topics');
|
||||
const posts = require('../../posts');
|
||||
const socketHelpers = require('../helpers');
|
||||
|
||||
module.exports = function (SocketPosts) {
|
||||
@@ -25,7 +26,15 @@ module.exports = function (SocketPosts) {
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
}
|
||||
await topics.movePostToTopic(socket.uid, pid, data.tid);
|
||||
|
||||
const [postDeleted, topicDeleted] = await Promise.all([
|
||||
posts.getPostField(pid, 'deleted'),
|
||||
topics.getTopicField(data.tid, 'deleted'),
|
||||
]);
|
||||
|
||||
if (!postDeleted && !topicDeleted) {
|
||||
socketHelpers.sendNotificationToPostOwner(pid, socket.uid, 'move', 'notifications:moved_your_post');
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -17,13 +17,14 @@ module.exports = function (SocketTopics) {
|
||||
if (!canMove) {
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
}
|
||||
const topicData = await topics.getTopicFields(tid, ['tid', 'cid', 'slug']);
|
||||
const topicData = await topics.getTopicFields(tid, ['tid', 'cid', 'slug', 'deleted']);
|
||||
data.uid = socket.uid;
|
||||
await topics.tools.move(tid, data);
|
||||
|
||||
socketHelpers.emitToTopicAndCategory('event:topic_moved', topicData);
|
||||
|
||||
if (!topicData.deleted) {
|
||||
socketHelpers.sendNotificationToTopicOwner(tid, socket.uid, 'move', 'notifications:moved_your_topic');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user