|
1 | 1 | import { Team } from '@rocket.chat/core-services'; |
2 | | -import type { IRoom, IUser } from '@rocket.chat/core-typings'; |
| 2 | +import type { IUser } from '@rocket.chat/core-typings'; |
3 | 3 | import type { ServerMethods } from '@rocket.chat/ddp-client'; |
4 | 4 | import { Rooms, Users, Subscriptions } from '@rocket.chat/models'; |
5 | 5 | import { escapeRegExp } from '@rocket.chat/string-helpers'; |
@@ -45,7 +45,7 @@ const sortUsers = (field: string, direction: 'asc' | 'desc'): Record<string, Sor |
45 | 45 | }; |
46 | 46 |
|
47 | 47 | const getChannelsAndGroups = async ( |
48 | | - user: IUser & { __rooms?: IRoom['_id'][] }, |
| 48 | + user: Pick<IUser, '_id' | '__rooms'>, |
49 | 49 | canViewAnon: boolean, |
50 | 50 | searchTerm: string, |
51 | 51 | sort: Record<string, number>, |
@@ -119,7 +119,7 @@ const getChannelsCountForTeam = mem((teamId) => Rooms.countByTeamId(teamId), { |
119 | 119 | }); |
120 | 120 |
|
121 | 121 | const getTeams = async ( |
122 | | - user: IUser, |
| 122 | + user: Pick<IUser, '_id' | '__rooms'>, |
123 | 123 | searchTerm: string, |
124 | 124 | sort: Record<string, number>, |
125 | 125 | pagination: { |
@@ -247,7 +247,7 @@ const findUsers = async ({ |
247 | 247 | }; |
248 | 248 |
|
249 | 249 | const getUsers = async ( |
250 | | - user: IUser | undefined, |
| 250 | + user: Pick<IUser, '_id' | '__rooms'> | undefined, |
251 | 251 | text: string, |
252 | 252 | workspace: string, |
253 | 253 | sort: Record<string, SortDirection>, |
@@ -299,7 +299,7 @@ export const browseChannelsMethod = async ( |
299 | 299 | offset = 0, |
300 | 300 | limit = 10, |
301 | 301 | }: BrowseChannelsParams, |
302 | | - user: IUser | undefined | null, |
| 302 | + user: Pick<IUser, '_id' | '__rooms'> | undefined | null, |
303 | 303 | ) => { |
304 | 304 | const searchTerm = trim(escapeRegExp(text)); |
305 | 305 |
|
@@ -333,8 +333,6 @@ export const browseChannelsMethod = async ( |
333 | 333 | return; |
334 | 334 | } |
335 | 335 |
|
336 | | - user.__rooms = user.__rooms ?? (await Users.findOneById(user._id, { projection: { __rooms: 1 } }))?.__rooms ?? []; |
337 | | - |
338 | 336 | switch (type) { |
339 | 337 | case 'channels': |
340 | 338 | return getChannelsAndGroups(user, canViewAnonymous, searchTerm, sortChannels(sortBy, sortDirection), pagination); |
|
0 commit comments