Node.js based forum software built for the modern web
fix: #9292, messageobj.content already parsed
Barış Soner Uşaklıc953b1b3d123
diff --git a/src/messaging/notifications.js b/src/messaging/notifications.jsindex d76348a29a..748fd2799c 100644--- a/src/messaging/notifications.js+++ b/src/messaging/notifications.js@@ -62,7 +62,7 @@ module.exports = function (Messaging) {type: isGroupChat ? 'new-group-chat' : 'new-chat',subject: `[[email:notif.chat.subject, ${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}`,from: fromuid,path: `/chats/${messageObj.roomId}`,diff --git a/test/messaging.js b/test/messaging.jsindex ecec16026c..fbec60234f 100644--- a/test/messaging.js+++ b/test/messaging.js@@ -4,6 +4,9 @@ const assert = require('assert');const async = require('async');const request = require('request');const nconf = require('nconf');+const util = require('util');++const sleep = util.promisify(setTimeout);const db = require('./mocks/databasemock');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;- db.sortedSetAdd('users:online', Date.now() - ((meta.config.onlineCutoff * 60000) + 50000), herpUid, (err) => {- assert.ifError(err);- socketModules.chats.send({ uid: fooUid }, { roomId: roomId, message: 'second chat message' }, (err) => {- assert.ifError(err);- setTimeout(() => {- User.notifications.get(herpUid, (err, data) => {- assert.ifError(err);- assert(data.unread[0]);- const notification = data.unread[0];- assert.equal(notification.bodyShort, '[[notifications:new_message_from, foo]]');- assert.equal(notification.nid, `chat_${fooUid}_${roomId}`);- assert.equal(notification.path, `${nconf.get('relative_path')}/chats/${roomId}`);- done();- });- }, 1500);- });- });+ const roomId = await socketModules.chats.newRoom({ uid: fooUid }, { touid: bazUid });+ assert(roomId);+ await socketModules.chats.addUserToRoom({ uid: fooUid }, { roomId: roomId, username: 'herp' });+ await db.sortedSetAdd('users:online', Date.now() - ((meta.config.onlineCutoff * 60000) + 50000), herpUid);+ await socketModules.chats.send({ uid: fooUid }, { roomId: roomId, message: 'second chat message **bold** text' });++ await sleep(1500);+ const data = await User.notifications.get(herpUid);+ assert(data.unread[0]);+ const notification = data.unread[0];+ assert.strictEqual(notification.bodyShort, '[[notifications:new_message_from, foo]]');+ assert.strictEqual(notification.nid, `chat_${fooUid}_${roomId}`);+ assert.strictEqual(notification.path, `${nconf.get('relative_path')}/chats/${roomId}`);});it('should fail to get messages from room with invalid data', (done) => {@@ -807,7 +806,7 @@ describe('Messaging Library', () => {assert.ifError(err);assert.equal(response.statusCode, 200);assert(Array.isArray(body.rooms));- assert.equal(body.rooms.length, 1);+ assert.equal(body.rooms.length, 2);assert.equal(body.title, '[[pages:chats]]');done();});