-
Notifications
You must be signed in to change notification settings - Fork 13k
feat: support mapping users to exchange servers by domain #36153
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
kodiakhq
merged 27 commits into
develop
from
support-multiple-exchange-servers-CONN-674
Jun 18, 2025
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
dccd547
feat: map users to exchange servers by domain
cardoso 6928825
wip: open outlook
cardoso 57aa970
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
cardoso 935067e
chore: remove dead code
cardoso 18e537b
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
cardoso 04ccc98
wip: map all outlook settings to domain
cardoso 3bd6351
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
cardoso 772b51f
fix: typechecking
cardoso 3eee286
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
cardoso 94d0cde
Merge branch 'develop' into support-multiple-exchange-servers-CONN-674
cardoso 00df1c8
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
cardoso e168a27
wip: send only necessary calendar user info
cardoso 39878af
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
cardoso 3d4adb7
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
cardoso 4f3fef1
wip: simplify & revert some type definitions
cardoso 57eaafa
fix: user calendar mapping
cardoso a98cc5d
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
cardoso ba9e63b
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
cardoso 5a97f24
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
cardoso 32dcfce
test: getUserInfo
cardoso b388a32
Merge branch 'develop' into support-multiple-exchange-servers-CONN-674
cardoso 2fda15e
Merge branch 'develop' into support-multiple-exchange-servers-CONN-674
cardoso f25d0eb
chore: add changeset
cardoso a3d8154
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
cardoso 0650d91
Merge branch 'develop' into support-multiple-exchange-servers-CONN-674
kodiakhq[bot] 5356317
Merge branch 'develop' into support-multiple-exchange-servers-CONN-674
cardoso 7328c24
Merge branch 'develop' into support-multiple-exchange-servers-CONN-674
cardoso 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,7 @@ | ||
| --- | ||
| '@rocket.chat/core-typings': minor | ||
| '@rocket.chat/i18n': minor | ||
| '@rocket.chat/meteor': minor | ||
| --- | ||
|
|
||
| Adds a new setting to override outlook calendar settings per user email domain |
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,196 @@ | ||
| import { getUserInfo } from './getUserInfo'; | ||
| import type { CachedSettings } from '../../../settings/server/CachedSettings'; | ||
|
|
||
| jest.mock('@rocket.chat/models', () => ({ | ||
| Users: { | ||
| findOneById: jest.fn().mockResolvedValue({ | ||
| id: '123', | ||
| name: 'Test User', | ||
| emails: [{ address: '[email protected]' }], | ||
| }), | ||
| }, | ||
| })); | ||
|
|
||
| const settings = new Map<string, unknown>(); | ||
|
|
||
| jest.mock('../../../settings/server', () => ({ | ||
| settings: { | ||
| getByRegexp(_id) { | ||
| return [...settings].filter(([key]) => key.match(_id)) as any; | ||
| }, | ||
| get(_id) { | ||
| return settings.get(_id) as any; | ||
| }, | ||
| set(record) { | ||
| settings.set(record._id, record.value); | ||
| }, | ||
| } satisfies Partial<CachedSettings>, | ||
| })); | ||
|
|
||
| // @ts-expect-error __meteor_runtime_config__ is not defined in the type definitions | ||
| global.__meteor_runtime_config__ = { | ||
| ROOT_URL: 'http://localhost:3000', | ||
| ROOT_URL_PATH_PREFIX: '', | ||
| }; | ||
|
|
||
| describe('getUserInfo', () => { | ||
| let user: Parameters<typeof getUserInfo>[0]; | ||
|
|
||
| beforeEach(() => { | ||
| settings.clear(); | ||
| settings.set('Site_Url', 'http://localhost:3000'); | ||
| user = { | ||
| _id: '123', | ||
| createdAt: new Date(), | ||
| roles: [], | ||
| type: 'user', | ||
| active: true, | ||
| _updatedAt: new Date(), | ||
| }; | ||
| }); | ||
|
|
||
| it('should return user info', async () => { | ||
| const userInfo = await getUserInfo(user); | ||
|
|
||
| expect(userInfo).toEqual( | ||
| expect.objectContaining({ | ||
| _id: '123', | ||
| type: 'user', | ||
| roles: [], | ||
| active: true, | ||
| _updatedAt: expect.any(Date), | ||
| createdAt: expect.any(Date), | ||
| email: undefined, | ||
| avatarUrl: 'http://localhost:3000/avatar/undefined', | ||
| settings: { | ||
| calendar: {}, | ||
| profile: {}, | ||
| preferences: {}, | ||
| }, | ||
| }), | ||
| ); | ||
| }); | ||
|
|
||
| describe('email handling', () => { | ||
| it('should not include email if no emails are present', async () => { | ||
| user.emails = []; | ||
| const userInfo = await getUserInfo(user); | ||
| expect(userInfo.email).toBe(undefined); | ||
| }); | ||
|
|
||
| it('should include email if one email is present and verified', async () => { | ||
| user.emails = [{ address: '[email protected]', verified: true }]; | ||
| const userInfo = await getUserInfo(user); | ||
| expect(userInfo.email).toEqual('[email protected]'); | ||
| }); | ||
|
|
||
| it('should not include email if one email is present and not verified', async () => { | ||
| user.emails = [{ address: '[email protected]', verified: false }]; | ||
| const userInfo = await getUserInfo(user); | ||
| expect(userInfo.email).toBe(undefined); | ||
| }); | ||
|
|
||
| it('should include email if multiple emails are present and one is verified', async () => { | ||
| user.emails = [ | ||
| { address: '[email protected]', verified: false }, | ||
| { address: '[email protected]', verified: true }, | ||
| ]; | ||
| const userInfo = await getUserInfo(user); | ||
| expect(userInfo.email).toEqual('[email protected]'); | ||
| }); | ||
|
|
||
| it('should not include email if multiple emails are present and none are verified', async () => { | ||
| user.emails = [ | ||
| { address: '[email protected]', verified: false }, | ||
| { address: '[email protected]', verified: false }, | ||
| ]; | ||
| const userInfo = await getUserInfo(user); | ||
| expect(userInfo.email).toBe(undefined); | ||
| }); | ||
| }); | ||
|
|
||
| describe('outlook calendar settings', () => { | ||
| beforeEach(() => { | ||
| settings.set('Outlook_Calendar_Enabled', true); | ||
| settings.set('Outlook_Calendar_Exchange_Url', 'https://outlook.office365.com/'); | ||
| settings.set('Outlook_Calendar_Outlook_Url', 'https://outlook.office365.com/owa/#calendar/view/month'); | ||
| settings.set('Outlook_Calendar_Url_Mapping', JSON.stringify({})); | ||
| user.emails = [{ address: '[email protected]', verified: true }]; | ||
| }); | ||
|
|
||
| it('should return empty calendar settings if Outlook is disabled', async () => { | ||
| settings.set('Outlook_Calendar_Enabled', false); | ||
| const userInfo = await getUserInfo(user); | ||
| expect(userInfo.settings?.calendar).toEqual({}); | ||
| }); | ||
|
|
||
| it('should return calendar settings with Outlook enabled and default URLs', async () => { | ||
| const userInfo = await getUserInfo(user); | ||
| expect(userInfo.settings?.calendar?.outlook).toEqual({ | ||
| Enabled: true, | ||
| Exchange_Url: 'https://outlook.office365.com/', | ||
| Outlook_Url: 'https://outlook.office365.com/owa/#calendar/view/month', | ||
| }); | ||
| }); | ||
|
|
||
| it('should return calendar settings with Outlook enabled and domain mapping', async () => { | ||
| settings.set( | ||
| 'Outlook_Calendar_Url_Mapping', | ||
| JSON.stringify({ | ||
| 'example.com': { Exchange_Url: 'https://custom.exchange.com/', Outlook_Url: 'https://custom.outlook.com/' }, | ||
| }), | ||
| ); | ||
| const userInfo = await getUserInfo(user); | ||
| expect(userInfo.settings?.calendar).toEqual({ | ||
| outlook: { | ||
| Enabled: true, | ||
| Exchange_Url: 'https://custom.exchange.com/', | ||
| Outlook_Url: 'https://custom.outlook.com/', | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| it('should return calendar settings with outlook disabled but enabled for specific domain', async () => { | ||
| settings.set('Outlook_Calendar_Enabled', false); | ||
| settings.set( | ||
| 'Outlook_Calendar_Url_Mapping', | ||
| JSON.stringify({ | ||
| 'specific.com': { Enabled: true, Exchange_Url: 'https://specific.exchange.com/', Outlook_Url: 'https://specific.outlook.com/' }, | ||
| }), | ||
| ); | ||
| user.emails = [{ address: '[email protected]', verified: true }]; | ||
| const userInfo = await getUserInfo(user); | ||
| expect(userInfo.settings?.calendar).toEqual({ | ||
| outlook: { | ||
| Enabled: true, | ||
| Exchange_Url: 'https://specific.exchange.com/', | ||
| Outlook_Url: 'https://specific.outlook.com/', | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| it('should return calendar settings with Outlook enabled and default mapping for unknown domain', async () => { | ||
| user.emails = [{ address: '[email protected]', verified: true }]; | ||
| const userInfo = await getUserInfo(user); | ||
| expect(userInfo.settings?.calendar).toEqual({ | ||
| outlook: { | ||
| Enabled: true, | ||
| Exchange_Url: 'https://outlook.office365.com/', | ||
| Outlook_Url: 'https://outlook.office365.com/owa/#calendar/view/month', | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| it('should handle invalid JSON in Outlook_Calendar_Url_Mapping', async () => { | ||
| settings.set('Outlook_Calendar_Url_Mapping', 'invalid json'); | ||
| const userInfo = await getUserInfo(user); | ||
| expect(userInfo.settings?.calendar).toEqual({ | ||
| outlook: { | ||
| Enabled: true, | ||
| Exchange_Url: 'https://outlook.office365.com/', | ||
| Outlook_Url: 'https://outlook.office365.com/owa/#calendar/view/month', | ||
| }, | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.