-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: New users are not automatically inserted in auto-join rooms insi…
…de default teams (#31720) Co-authored-by: Matheus Barbosa Silva <[email protected]>
- Loading branch information
1 parent
b0aace7
commit 0f0d631
Showing
7 changed files
with
210 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@rocket.chat/meteor": patch | ||
--- | ||
|
||
Now we are considering channels with auto-join inside teams on user creation |
8 changes: 4 additions & 4 deletions
8
apps/meteor/app/lib/server/functions/addUserToDefaultChannels.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
apps/meteor/app/lib/server/functions/getDefaultChannels.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { IRoom } from '@rocket.chat/core-typings'; | ||
import { Rooms } from '@rocket.chat/models'; | ||
|
||
export async function getDefaultChannels(): Promise<IRoom[]> { | ||
const defaultRooms = await Rooms.findByDefaultAndTypes(true, ['c', 'p'], { | ||
projection: { usernames: 0 }, | ||
}).toArray(); | ||
const roomsThatAreGoingToBeJoined = new Set(defaultRooms.map((room) => room._id)); | ||
|
||
// If any of those are teams, we need to get all the channels that have the auto-join flag as well | ||
const teamRooms = defaultRooms.filter((room) => room.teamMain && room.teamId); | ||
if (teamRooms.length > 0) { | ||
for await (const teamRoom of teamRooms) { | ||
const defaultTeamRooms = await Rooms.findDefaultRoomsForTeam(teamRoom.teamId).toArray(); | ||
|
||
const defaultTeamRoomsThatWereNotAlreadyAdded = defaultTeamRooms.filter((channel) => !roomsThatAreGoingToBeJoined.has(channel._id)); | ||
|
||
defaultTeamRoomsThatWereNotAlreadyAdded.forEach((channel) => roomsThatAreGoingToBeJoined.add(channel._id)); | ||
// Add the channels to the defaultRooms list | ||
defaultRooms.push(...defaultTeamRoomsThatWereNotAlreadyAdded); | ||
} | ||
} | ||
|
||
return defaultRooms; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters