Skip to content

Node.js based forum software built for the modern web

fix: #8249, don't send move notifications for deleted posts/topics

Barış Soner Uşaklıd77036dbd155
diff --git a/src/socket.io/posts/move.js b/src/socket.io/posts/move.js
index fe8a293738..bfd614b063 100644
--- a/src/socket.io/posts/move.js
+++ b/src/socket.io/posts/move.js
@@ -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);
- socketHelpers.sendNotificationToPostOwner(pid, socket.uid, 'move', 'notifications:moved_your_post');
+
+ 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');
+ }
}
};
};
diff --git a/src/socket.io/topics/move.js b/src/socket.io/topics/move.js
index 0f309eeac8..47ef260857 100644
--- a/src/socket.io/topics/move.js
+++ b/src/socket.io/topics/move.js
@@ -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);
-
- socketHelpers.sendNotificationToTopicOwner(tid, socket.uid, 'move', 'notifications:moved_your_topic');
+ if (!topicData.deleted) {
+ socketHelpers.sendNotificationToTopicOwner(tid, socket.uid, 'move', 'notifications:moved_your_topic');
+ }
});
};