Skip to content
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

refactor(api, application-generic): Encapsulate preference mutations in workflow use-cases #7005

Open
wants to merge 21 commits into
base: next
Choose a base branch
from

Conversation

rifont
Copy link
Contributor

@rifont rifont commented Nov 14, 2024

What changed? Why was the change needed?

  • Encapsulate preference mutations in workflow use-cases
    • Move all preference handling to CreateWorkflow, UpdateWorkflow, and DeleteWorkflow use-cases
    • Remove preference handling from UpsertPreferences use-case

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

linear bot commented Nov 14, 2024

Copy link

netlify bot commented Nov 14, 2024

Deploy Preview for novu-stg-vite-dashboard-poc ready!

Name Link
🔨 Latest commit 712a64a
🔍 Latest deploy log https://app.netlify.com/sites/novu-stg-vite-dashboard-poc/deploys/67368bb665fc900008e70e53
😎 Deploy Preview https://deploy-preview-7005--novu-stg-vite-dashboard-poc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

pkg-pr-new bot commented Nov 14, 2024

Open in Stackblitz

@novu/client

pnpm add https://pkg.pr.new/novuhq/novu/@novu/client@7005

@novu/framework

pnpm add https://pkg.pr.new/novuhq/novu/@novu/framework@7005

@novu/nextjs

pnpm add https://pkg.pr.new/novuhq/novu/@novu/nextjs@7005

@novu/headless

pnpm add https://pkg.pr.new/novuhq/novu/@novu/headless@7005

@novu/node

pnpm add https://pkg.pr.new/novuhq/novu/@novu/node@7005

@novu/js

pnpm add https://pkg.pr.new/novuhq/novu/@novu/js@7005

@novu/notification-center

pnpm add https://pkg.pr.new/novuhq/novu/@novu/notification-center@7005

novu

pnpm add https://pkg.pr.new/novuhq/novu@7005

@novu/providers

pnpm add https://pkg.pr.new/novuhq/novu/@novu/providers@7005

@novu/react

pnpm add https://pkg.pr.new/novuhq/novu/@novu/react@7005

@novu/react-native

pnpm add https://pkg.pr.new/novuhq/novu/@novu/react-native@7005

@novu/shared

pnpm add https://pkg.pr.new/novuhq/novu/@novu/shared@7005

commit: 712a64a

@@ -40,7 +40,7 @@ export class Channels {
export class PreferencesDto {
@ValidateNested({ each: true })
@Type(() => WorkflowPreference)
workflow: WorkflowPreference;
all: WorkflowPreference;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was just completely wrong before.

organizationId: command.organizationId,
identifierOrInternalId: command.id,
}),
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always use the GetWorkflow command at the end. Not the most performant, but the endpoint is infrequently used so it's a suitable compromise to avoid an even bigger refactor.

{
$set: updatePayload,
},
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The database mutation should happen before invalidating.

defaultPreferences: DEFAULT_WORKFLOW_PREFERENCES,
userPreferences:
body.preferenceSettings &&
buildWorkflowPreferencesFromPreferenceChannels(body.critical ?? false, body.preferenceSettings),
Copy link
Contributor Author

@rifont rifont Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internally, all Workflow DTOs now carry a defaultPreferences and userPreferences object now.

preferenceSettings and critical are removed from all internal DTOs in preparation for their full removal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant