mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 06:25:50 +01:00
Fix followed topic notifications going to the last unread post
Regression introduced in 1b34ebe230.
Bug originally reported in #4469.
This commit is contained in:
@@ -631,12 +631,12 @@ app.cacheBuster = null;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.parse('partials/cookie-consent', config.cookies, function(html) {
|
templates.parse('partials/cookie-consent', config.cookies, function (html) {
|
||||||
$(document.body).append(html);
|
$(document.body).append(html);
|
||||||
|
|
||||||
var warningEl = $('.cookie-consent');
|
var warningEl = $('.cookie-consent');
|
||||||
var dismissEl = warningEl.find('button');
|
var dismissEl = warningEl.find('button');
|
||||||
dismissEl.on('click', function() {
|
dismissEl.on('click', function () {
|
||||||
// Save consent cookie and remove warning element
|
// Save consent cookie and remove warning element
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
window.localStorage.setItem('cookieconsent', '1');
|
window.localStorage.setItem('cookieconsent', '1');
|
||||||
|
|||||||
@@ -464,7 +464,7 @@ var utils = require('../public/src/utils');
|
|||||||
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_multiple, ' + usernames[0] + ', ' + (numUsers - 1) + titleEscaped + ']]';
|
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_multiple, ' + usernames[0] + ', ' + (numUsers - 1) + titleEscaped + ']]';
|
||||||
}
|
}
|
||||||
|
|
||||||
notifications[modifyIndex].path = set[0].path;
|
notifications[modifyIndex].path = set[set.length - 1].path;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'new_register':
|
case 'new_register':
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
var async = require('async');
|
||||||
|
|
||||||
var db = require('./mocks/databasemock');
|
var db = require('./mocks/databasemock');
|
||||||
var user = require('../src/user');
|
var user = require('../src/user');
|
||||||
@@ -96,6 +97,76 @@ describe('Notifications', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should link to the first unread post in a watched topic', function (done) {
|
||||||
|
var categories = require('../src/categories');
|
||||||
|
var topics = require('../src/topics');
|
||||||
|
|
||||||
|
var watcherUid;
|
||||||
|
var cid;
|
||||||
|
var tid;
|
||||||
|
var pid;
|
||||||
|
|
||||||
|
async.waterfall([
|
||||||
|
function (next) {
|
||||||
|
user.create({username: 'watcher'}, next);
|
||||||
|
},
|
||||||
|
function (_watcherUid, next) {
|
||||||
|
watcherUid = _watcherUid;
|
||||||
|
|
||||||
|
categories.create({
|
||||||
|
name: 'Test Category',
|
||||||
|
description: 'Test category created by testing script'
|
||||||
|
}, next);
|
||||||
|
},
|
||||||
|
function (category, next) {
|
||||||
|
cid = category.cid;
|
||||||
|
|
||||||
|
topics.post({
|
||||||
|
uid: watcherUid,
|
||||||
|
cid: cid,
|
||||||
|
title: 'Test Topic Title',
|
||||||
|
content: 'The content of test topic'
|
||||||
|
}, next);
|
||||||
|
},
|
||||||
|
function (topic, next) {
|
||||||
|
tid = topic.topicData.tid;
|
||||||
|
|
||||||
|
topics.follow(tid, watcherUid, next);
|
||||||
|
},
|
||||||
|
function (next) {
|
||||||
|
topics.reply({
|
||||||
|
uid: uid,
|
||||||
|
content: 'This is the first reply.',
|
||||||
|
tid: tid
|
||||||
|
}, next);
|
||||||
|
},
|
||||||
|
function (post, next) {
|
||||||
|
pid = post.pid;
|
||||||
|
|
||||||
|
topics.reply({
|
||||||
|
uid: uid,
|
||||||
|
content: 'This is the second reply.',
|
||||||
|
tid: tid
|
||||||
|
}, next);
|
||||||
|
},
|
||||||
|
function (post, next) {
|
||||||
|
// notifications are sent asynchronously with a 1 second delay.
|
||||||
|
setTimeout(next, 3000);
|
||||||
|
},
|
||||||
|
function (next) {
|
||||||
|
user.notifications.get(watcherUid, next);
|
||||||
|
},
|
||||||
|
function (notifications, next) {
|
||||||
|
assert.equal(notifications.unread.length, 1, 'there should be 1 unread notification');
|
||||||
|
assert.equal('/post/' + pid, notifications.unread[0].path, 'the notification should link to the first unread post');
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
], function (err) {
|
||||||
|
assert.ifError(err);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
after(function (done) {
|
after(function (done) {
|
||||||
db.emptydb(done);
|
db.emptydb(done);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user