-
Notifications
You must be signed in to change notification settings - Fork 1
PROD : OUT-4000 | Filter out email notifications according to iu notification preference #1396
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 all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d2f1bbf
OUT-4000 | Filter out email notifications according to IU notificatio…
arpandhakal 5bf5996
OUT-4000 | Fail closed on the global IU email gate
arpandhakal f5d34a9
OUT-4000 | Drop the emailSettings global gate; rely on per-category d…
arpandhakal 9f7fe84
Merge pull request #1395 from assemblycom/OUT-4000-filter-iu-email-by…
arpandhakal ec56dd8
Merge branch 'production' into main
arpandhakal 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,46 @@ | ||
| import { InternalUserNotificationSettings } from '@/types/common' | ||
| import { disabledEmailSettingIds } from './iuEmailPreference' | ||
|
|
||
| const settings = (overrides: Partial<InternalUserNotificationSettings> = {}): InternalUserNotificationSettings => ({ | ||
| emailSettings: 'active', | ||
| notifyAbout: {}, | ||
| ...overrides, | ||
| }) | ||
|
|
||
| describe('disabledEmailSettingIds', () => { | ||
| it('collects ids only for categories with email disabled', () => { | ||
| const result = disabledEmailSettingIds( | ||
| settings({ | ||
| notifyAbout: { | ||
| newCommentOnATask: { disableEmail: true, notificationSettingId: 'setting_comment' }, | ||
| newTaskAssigned: { disableEmail: false, notificationSettingId: 'setting_assigned' }, | ||
| taskCompleted: { disableEmail: true, notificationSettingId: 'setting_completed' }, | ||
| }, | ||
| }), | ||
| ) | ||
|
|
||
| expect(result).toEqual(new Set(['setting_comment', 'setting_completed'])) | ||
| }) | ||
|
|
||
| it('ignores platform categories without a notificationSettingId', () => { | ||
| const result = disabledEmailSettingIds( | ||
| settings({ | ||
| notifyAbout: { | ||
| newMessages: { disableEmail: true }, | ||
| newCommentOnATask: { disableEmail: true, notificationSettingId: 'setting_comment' }, | ||
| }, | ||
| }), | ||
| ) | ||
|
|
||
| expect(result).toEqual(new Set(['setting_comment'])) | ||
| }) | ||
|
|
||
| it('returns an empty set when nothing is disabled or notifyAbout is empty', () => { | ||
| expect(disabledEmailSettingIds(settings())).toEqual(new Set()) | ||
| expect( | ||
| disabledEmailSettingIds( | ||
| settings({ notifyAbout: { newCommentOnATask: { disableEmail: false, notificationSettingId: 'setting_comment' } } }), | ||
| ), | ||
| ).toEqual(new Set()) | ||
| }) | ||
| }) |
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,10 @@ | ||
| import { InternalUserNotificationSettings } from '@/types/common' | ||
|
|
||
| // Setting ids for which this IU has turned email off. Matched by notificationSettingId (our app's | ||
| // categories carry it), so this is independent of the platform's internal category key names. | ||
| export const disabledEmailSettingIds = (settings: InternalUserNotificationSettings): Set<string> => { | ||
| const ids = Object.values(settings.notifyAbout) | ||
| .filter((entry) => entry.notificationSettingId && entry.disableEmail) | ||
| .map((entry) => entry.notificationSettingId as string) | ||
| return new Set(ids) | ||
| } |
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
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the Copilot preference request fails for an IU with disabled email categories, this catch returns every event unfiltered, causing opted-out emails to be sent before their buffer rows are marked sent and deleted.
Knowledge Base Used: Notifications flow: from task/comment event to delivered notification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will create another pr for this.