Skip to content

Node.js based forum software built for the modern web

test: fix test, add joinLeaveMessages to newRoom

Barış Soner Uşaklı7acd63c2a0ab
diff --git a/src/messaging/rooms.js b/src/messaging/rooms.js
index 4bf4deed2c..934bf4e40d 100644
--- a/src/messaging/rooms.js
+++ b/src/messaging/rooms.js
@@ -88,7 +88,7 @@ module.exports = function (Messaging) {
timestamp: now,
notificationSetting: data.notificationSetting,
messageCount: 0,
- joinLeaveMessages: 0,
+ joinLeaveMessages: data.joinLeaveMessages || 0,
};
if (data.hasOwnProperty('roomName') && data.roomName) {
@@ -127,7 +127,7 @@ module.exports = function (Messaging) {
'chat:rooms:public:order:all',
]);
- if (!isPublic) {
+ if (!isPublic && parseInt(room.joinLeaveMessages, 10) === 1) {
// chat owner should also get the user-join system message
await Messaging.addSystemMessage('user-join', uid, roomId);
}
diff --git a/test/messaging.js b/test/messaging.js
index 4429fd6cd7..fbde5d72f6 100644
--- a/test/messaging.js
+++ b/test/messaging.js
@@ -184,6 +184,7 @@ describe('Messaging Library', () => {
await User.setSetting(mocks.users.baz.uid, 'disableIncomingMessages', '0');
const { body } = await callv3API('post', `/chats`, {
uids: [mocks.users.baz.uid],
+ joinLeaveMessages: 1,
}, 'foo');
await User.setSetting(mocks.users.baz.uid, 'disableIncomingMessages', '1');
@@ -803,7 +804,7 @@ describe('Messaging Library', () => {
assert.equal(response.statusCode, 200);
assert(Array.isArray(body.rooms));
- assert.equal(body.rooms.length, 3);
+ assert.equal(body.rooms.length, 2);
assert.equal(body.title, '[[pages:chats]]');
});