Repository navigation
fix: New users are not automatically inserted in auto-join rooms inside default teams #31720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f4bb40b
fix: Considering the auto join channels inside teams
Gustrb aaa8151
Create calm-penguins-do.md
97b26c4
refactor: Moving the logic to get default channels to its own file
Gustrb 9eb5a4b
test: Add tests for the new change
Gustrb 5428c0e
chore: Removing unecessary async
Gustrb 25a3931
Improve tests organization and check for correct team room id
matheusbsilva137 1a20226
Use team's _id to insert group in team
matheusbsilva137 affb030
Add test for non auot-join room inside default team
matheusbsilva137 d9f6cc0
Add test for default room inside non default team
matheusbsilva137 853e163
Add test for non default team and room
matheusbsilva137 da38a47
Add missing helper to unset room as workspace default
matheusbsilva137 d0c02dd
Merge branch 'develop' into fix/auto-join-channels-on-auto-join-teams
matheusbsilva137 ad1e9eb
fix: Adjusting the tests
Gustrb 265aacb
chore: Removing unused test helper
Gustrb 92fc248
Merge branch 'develop' into fix/auto-join-channels-on-auto-join-teams
acc8865
fix: Type check failing
Gustrb 4f2361e
fix: Typing
Gustrb 8e89031
Merge branch 'develop' into fix/auto-join-channels-on-auto-join-teams
91980e2
Merge branch 'develop' into fix/auto-join-channels-on-auto-join-teams
scuciatto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.