-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
feat(api): Delete subscriber channel preference when updating global channel #6767
feat(api): Delete subscriber channel preference when updating global channel #6767
Conversation
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.
Removing defaults to ensure that only the provided mutation values are persisted, enabling PATCH
operations to work as expected.
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.
👍
✅ Deploy Preview for novu-stg-vite-dashboard-poc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -323,6 +329,10 @@ export class Sync { | |||
return notificationGroupId; | |||
} | |||
|
|||
private getWorkflowPreferences(workflow: DiscoverWorkflowOutput): WorkflowPreferencesPartial { | |||
return workflow.preferences || {}; |
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.
A fallback empty object is now necessary during sync after strengthening validation of the UpsertWorkflow
use-case to disallow undefined
preferences.
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.
Here and in the following files, we'll see renaming from GetPreferences
to GetInboxPreferences
to eliminate the duplicated usage of GetPreferences
use-case naming.
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.
This is a slightly bad diff, as the file is not entirely new. This use-case is however now considerably simpler, owing to better encapsulation of both:
GetSubscriberGlobalPreference
filtering out channels in the response to include only active & non-critical channelsGetSubscriberPreference
filtering out preference sets to include only active & non-critical workflows- Full encapsulation of V1 & V2 preferences in both of the above use-cases
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.
This was a bad diff - it has an extra test spec which caused it to become bad after renaming from get-preferences
-> get-inbox-preferences
commit: |
with: | ||
mongodb-version: 4.2.8 | ||
mongodb-version: 5.0.29 |
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.
Good call out!
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.
👍
return this.callWithSession(async () => | ||
updatePreference({ emitter: this._emitter, apiService: this._inboxService, args }) | ||
); | ||
} |
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.
This update
method on the full Preferences
resource was never used, so I'm deleting it.
What changed? Why was the change needed?
PATCH
operations for preferences don't create preferences for non-relevant channelsGetPreferences
for Inbox toGetInboxPreferences
to eliminate naming duplication with the genericGetPreferences
use-case400 Bad Request
response when attempting to modify global preference channels that don't have active & non-critical workflows that would be affected? Right now, thePATCH
responses for global preferences returnundefined
for channels that are irrelevant and it doesn't make much sense. We have failing tests that need to be addressed with the outcome of this decision.<Inbox />
<Inbox />
when modifying the Subscriber Global preferences, to ensure that the unset Workflow preferences display immediately.Screenshots
Toggling the Subscriber Global Channel Preferences in
<Inbox />
modifies the corresponding Subscriber Workflow Channel Preference fields.Important Note: This PR only has changes to reflect local state changes optimistically, it does not refetch all Preferences from the API after the optimistic update.
global-preference-unset-workflow-pref.mov
<Inbox />
displays only Global Preference channels for active & non-critical workflow channelsExpand for optional sections
Related enterprise PR
Special notes for your reviewer