mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
test: fix test, add joinLeaveMessages to newRoom
This commit is contained in:
@@ -88,7 +88,7 @@ module.exports = function (Messaging) {
|
|||||||
timestamp: now,
|
timestamp: now,
|
||||||
notificationSetting: data.notificationSetting,
|
notificationSetting: data.notificationSetting,
|
||||||
messageCount: 0,
|
messageCount: 0,
|
||||||
joinLeaveMessages: 0,
|
joinLeaveMessages: data.joinLeaveMessages || 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (data.hasOwnProperty('roomName') && data.roomName) {
|
if (data.hasOwnProperty('roomName') && data.roomName) {
|
||||||
@@ -127,7 +127,7 @@ module.exports = function (Messaging) {
|
|||||||
'chat:rooms:public:order:all',
|
'chat:rooms:public:order:all',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!isPublic) {
|
if (!isPublic && parseInt(room.joinLeaveMessages, 10) === 1) {
|
||||||
// chat owner should also get the user-join system message
|
// chat owner should also get the user-join system message
|
||||||
await Messaging.addSystemMessage('user-join', uid, roomId);
|
await Messaging.addSystemMessage('user-join', uid, roomId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ describe('Messaging Library', () => {
|
|||||||
await User.setSetting(mocks.users.baz.uid, 'disableIncomingMessages', '0');
|
await User.setSetting(mocks.users.baz.uid, 'disableIncomingMessages', '0');
|
||||||
const { body } = await callv3API('post', `/chats`, {
|
const { body } = await callv3API('post', `/chats`, {
|
||||||
uids: [mocks.users.baz.uid],
|
uids: [mocks.users.baz.uid],
|
||||||
|
joinLeaveMessages: 1,
|
||||||
}, 'foo');
|
}, 'foo');
|
||||||
await User.setSetting(mocks.users.baz.uid, 'disableIncomingMessages', '1');
|
await User.setSetting(mocks.users.baz.uid, 'disableIncomingMessages', '1');
|
||||||
|
|
||||||
@@ -803,7 +804,7 @@ describe('Messaging Library', () => {
|
|||||||
|
|
||||||
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, 3);
|
assert.equal(body.rooms.length, 2);
|
||||||
assert.equal(body.title, '[[pages:chats]]');
|
assert.equal(body.title, '[[pages:chats]]');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user