mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
fix: #9292, messageobj.content already parsed
This commit is contained in:
@@ -62,7 +62,7 @@ module.exports = function (Messaging) {
|
|||||||
type: isGroupChat ? 'new-group-chat' : 'new-chat',
|
type: isGroupChat ? 'new-group-chat' : 'new-chat',
|
||||||
subject: `[[email:notif.chat.subject, ${messageObj.fromUser.username}]]`,
|
subject: `[[email:notif.chat.subject, ${messageObj.fromUser.username}]]`,
|
||||||
bodyShort: `[[notifications:new_message_from, ${messageObj.fromUser.username}]]`,
|
bodyShort: `[[notifications:new_message_from, ${messageObj.fromUser.username}]]`,
|
||||||
bodyLong: await plugins.hooks.fire('filter:parse.raw', messageObj.content),
|
bodyLong: messageObj.content,
|
||||||
nid: `chat_${fromuid}_${roomId}`,
|
nid: `chat_${fromuid}_${roomId}`,
|
||||||
from: fromuid,
|
from: fromuid,
|
||||||
path: `/chats/${messageObj.roomId}`,
|
path: `/chats/${messageObj.roomId}`,
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ const assert = require('assert');
|
|||||||
const async = require('async');
|
const async = require('async');
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
const nconf = require('nconf');
|
const nconf = require('nconf');
|
||||||
|
const util = require('util');
|
||||||
|
|
||||||
|
const sleep = util.promisify(setTimeout);
|
||||||
|
|
||||||
const db = require('./mocks/databasemock');
|
const db = require('./mocks/databasemock');
|
||||||
const meta = require('../src/meta');
|
const meta = require('../src/meta');
|
||||||
@@ -396,26 +399,22 @@ describe('Messaging Library', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should notify offline users of message', (done) => {
|
it('should notify offline users of message', async () => {
|
||||||
meta.config.notificationSendDelay = 0.1;
|
meta.config.notificationSendDelay = 0.1;
|
||||||
|
|
||||||
db.sortedSetAdd('users:online', Date.now() - ((meta.config.onlineCutoff * 60000) + 50000), herpUid, (err) => {
|
const roomId = await socketModules.chats.newRoom({ uid: fooUid }, { touid: bazUid });
|
||||||
assert.ifError(err);
|
assert(roomId);
|
||||||
socketModules.chats.send({ uid: fooUid }, { roomId: roomId, message: 'second chat message' }, (err) => {
|
await socketModules.chats.addUserToRoom({ uid: fooUid }, { roomId: roomId, username: 'herp' });
|
||||||
assert.ifError(err);
|
await db.sortedSetAdd('users:online', Date.now() - ((meta.config.onlineCutoff * 60000) + 50000), herpUid);
|
||||||
setTimeout(() => {
|
await socketModules.chats.send({ uid: fooUid }, { roomId: roomId, message: 'second chat message **bold** text' });
|
||||||
User.notifications.get(herpUid, (err, data) => {
|
|
||||||
assert.ifError(err);
|
await sleep(1500);
|
||||||
assert(data.unread[0]);
|
const data = await User.notifications.get(herpUid);
|
||||||
const notification = data.unread[0];
|
assert(data.unread[0]);
|
||||||
assert.equal(notification.bodyShort, '[[notifications:new_message_from, foo]]');
|
const notification = data.unread[0];
|
||||||
assert.equal(notification.nid, `chat_${fooUid}_${roomId}`);
|
assert.strictEqual(notification.bodyShort, '[[notifications:new_message_from, foo]]');
|
||||||
assert.equal(notification.path, `${nconf.get('relative_path')}/chats/${roomId}`);
|
assert.strictEqual(notification.nid, `chat_${fooUid}_${roomId}`);
|
||||||
done();
|
assert.strictEqual(notification.path, `${nconf.get('relative_path')}/chats/${roomId}`);
|
||||||
});
|
|
||||||
}, 1500);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail to get messages from room with invalid data', (done) => {
|
it('should fail to get messages from room with invalid data', (done) => {
|
||||||
@@ -807,7 +806,7 @@ describe('Messaging Library', () => {
|
|||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
assert.equal(response.statusCode, 200);
|
assert.equal(response.statusCode, 200);
|
||||||
assert(Array.isArray(body.rooms));
|
assert(Array.isArray(body.rooms));
|
||||||
assert.equal(body.rooms.length, 1);
|
assert.equal(body.rooms.length, 2);
|
||||||
assert.equal(body.title, '[[pages:chats]]');
|
assert.equal(body.title, '[[pages:chats]]');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user