Skip to content

Commit c102712

Browse files
authored
feat: Search rooms by cyrillic characters in channel names (RocketChat#36861)
1 parent 6876409 commit c102712

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

.changeset/angry-apes-double.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@rocket.chat/models': patch
3+
'@rocket.chat/meteor': patch
4+
---
5+
6+
Enable room search by Cyrillic characters in channel names (e.g. "тест").

apps/meteor/tests/end-to-end/api/rooms.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,6 +2120,18 @@ describe('[Rooms]', () => {
21202120
});
21212121

21222122
describe('[/rooms.autocomplete.channelAndPrivate]', () => {
2123+
let testChannel: IRoom;
2124+
2125+
before(async () => {
2126+
await updateSetting('UI_Allow_room_names_with_special_chars', true);
2127+
testChannel = (await createRoom({ type: 'c', name: 'тест' })).body.channel;
2128+
});
2129+
2130+
after(async () => {
2131+
await updateSetting('UI_Allow_room_names_with_special_chars', true);
2132+
await deleteRoom({ type: 'c', roomId: testChannel._id });
2133+
});
2134+
21232135
it('should return an error when the required parameter "selector" is not provided', (done) => {
21242136
void request
21252137
.get(api('rooms.autocomplete.channelAndPrivate'))
@@ -2146,6 +2158,21 @@ describe('[Rooms]', () => {
21462158
})
21472159
.end(done);
21482160
});
2161+
it('should return the rooms with cyrillic characters in channel name', (done) => {
2162+
void request
2163+
.get(api('rooms.autocomplete.channelAndPrivate'))
2164+
.query({ selector: '{ "name": "тест" }' })
2165+
.set(credentials)
2166+
.expect('Content-Type', 'application/json')
2167+
.expect(200)
2168+
.expect((res) => {
2169+
expect(res.body).to.have.property('success', true);
2170+
expect(res.body).to.have.property('items').and.to.be.an('array');
2171+
expect(res.body.items).to.have.lengthOf(1);
2172+
expect(res.body.items[0].fname).to.be.equal('тест');
2173+
})
2174+
.end(done);
2175+
});
21492176
});
21502177

21512178
describe('[/rooms.autocomplete.channelAndPrivate.withPagination]', () => {

packages/models/src/models/Rooms.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ export class RoomsRaw extends BaseRaw<IRoom> implements IRoomsModel {
301301
t: {
302302
$in: ['c', 'p'],
303303
},
304-
name: nameRegex,
304+
$and: [{ $or: [{ name: nameRegex }, { fname: nameRegex }] }, { federated: { $ne: true } }, { archived: { $ne: true } }],
305305
$or: [
306306
{
307307
teamId: {
@@ -318,7 +318,6 @@ export class RoomsRaw extends BaseRaw<IRoom> implements IRoomsModel {
318318
},
319319
],
320320
prid: { $exists: false },
321-
$and: [{ federated: { $ne: true } }, { archived: { $ne: true } }],
322321
};
323322

324323
return this.find(query, options);

0 commit comments

Comments
 (0)