test: fix test, add joinLeaveMessages to newRoom

This commit is contained in:
Barış Soner Uşaklı
2025-06-27 15:03:23 -04:00
parent f5aca1144d
commit 7acd63c2a0
2 changed files with 4 additions and 3 deletions

View File

@@ -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);
}

View File

@@ -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]]');
});