Skip to content

Node.js based forum software built for the modern web

fix: post queue notifications never merged (#14842)

palmoni515ef37195757
diff --git a/src/posts/queue.js b/src/posts/queue.js
index 5d3d41ebbc..1634cd6bd2 100644
--- a/src/posts/queue.js
+++ b/src/posts/queue.js
@@ -270,7 +270,7 @@ module.exports = function (Posts) {
const notifObj = await notifications.create({
type: 'post-queue',
nid: `post-queue-${id}`,
- mergeId: `post-queue-${type}-uid-${data.uid}`,
+ mergeId: `post-queue|${type}-uid-${data.uid}`,
bodyShort: typeToTx[type],
bodyLong: bodyLong,
path: `/post-queue/${id}`,
diff --git a/test/posts.js b/test/posts.js
index eb75d67a77..5655adc712 100644
--- a/test/posts.js
+++ b/test/posts.js
@@ -1194,6 +1194,18 @@ describe('Post\'s', () => {
// should not contain the translated message
assert(body.indexOf('Perhaps you should') === -1);
});
+
+ it('should merge notifications for multiple queued posts from the same user', async () => {
+ const queueUid = await user.create({ username: 'queuemerger' });
+ await apiTopics.reply({ uid: queueUid }, { content: 'first queued reply', tid: topicData.tid });
+ await sleep(5);
+ await apiTopics.reply({ uid: queueUid }, { content: 'second queued reply', tid: topicData.tid });
+ await sleep(2000);
+
+ const { unread } = await user.notifications.get(globalModUid);
+ const queued = unread.filter(n => n && n.type === 'post-queue' && n.mergeId && n.mergeId.endsWith(`-uid-${queueUid}`));
+ assert.strictEqual(queued.length, 1);
+ });
});
describe('post editors', () => {