Skip to content

🐛 Bug Report: Subscriber level preference does not work #6548

@yunluo1024

Description

@yunluo1024

📜 Description

I have a subscriber (ID: 66e0d1f3cf609b1343ed9e8e) and a workflow (ID: 66ecdd18a17d00ef6f792cab) configured to send email and push notifications. I've explicitly set the subscriber's email and push channel preferences to false using the code below.

However, when I trigger workflow 66ecdd18a17d00ef6f792cab for this subscriber, I still receive both email and push notifications, contrary to my expectation.

const novu = new Novu("MY_KEY");

novu.notificationTemplates.getOne("66ecdd18a17d00ef6f792cab").then((p) => {
  console.log(p.data);
});
novu.subscribers
  .updatePreference("66e0d1f3cf609b1343ed9e8e", "66ecdd18a17d00ef6f792cab", {
    channel: { type: "email", enabled: false },
    enabled: true,
  })
  .then((r) => {
    // console.log(r.data);
  });
novu.subscribers
  .updatePreference("66e0d1f3cf609b1343ed9e8e", "66ecdd18a17d00ef6f792cab", {
    channel: { type: "push", enabled: false },
    enabled: true,
  })
  .then((r) => {
    // console.log(r.data);
  });
code to trigger the workflow
async function sendEmail() {
  await novu.trigger("WORKFLOW_NAME", { //  WORKFLOW_NAME is the name for template id 66ecdd18a17d00ef6f792cab
    to: {
      subscriberId: "66e0d1f3cf609b1343ed9e8e",
      email: "dummy-email@email.com", // fake email for reporting issue purpose
    },
    payload: {
      // Any custom payload data goes here
      data: {
        emailData: {subject: 'subject', body: 'body'},
        pushData: {
          subject: "Push notification subject",
          body: "Push notification body",
        },
      },
    },
    bridgeUrl: "https://xxxxxx-c8dd-465c-b066-1184b307c8bd.novu.sh/api/novu",
  });

👟 Reproduction steps

  1. invoke subscriber updatePreferences api to set email and push channel to false for subscriber for a workflow.
  2. invoke novu.trigger function to trigger the above workflow and subscriber;

👍 Expected behavior

Since the subscriber's preferences indicate they should not receive email and push notifications, triggering the workflow should not result in any notifications being sent to them.

👎 Actual Behavior with Screenshots

When I trigger workflow 66ecdd18a17d00ef6f792cab for this subscriber, I still receive both email and push notifications, contrary to my expectation.

Novu version

local installation @novu/node version 2.0.1

npm version

10.7.0

node version

v18.20.4

📃 Provide any additional context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

None

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions