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

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

Open
2 tasks done
yunluo1024 opened this issue Sep 23, 2024 · 4 comments
Open
2 tasks done

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

yunluo1024 opened this issue Sep 23, 2024 · 4 comments
Labels

Comments

@yunluo1024
Copy link

📜 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: "[email protected]", // 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

Copy link

linear bot commented Sep 23, 2024

@jainpawan21
Copy link
Member

@yunluo1024

I see workflow with id 66ecdd18a17d00ef6f792cab is deleted already. Can you please send us email to [email protected] if you are still facing this issue?

@yunluo1024
Copy link
Author

@jainpawan21 sorry for late response. i still have the the issue as of 29/10/2024; My feeling is that, the function novu.subscribers.updatePreference is not working properly, it seems not updating subscribers' preferences; In my case, even I changed the PUSH channel preferences to disabled, still i can send push notifications;

i have subscriber id and workflow Id below,

const subscriberId = "66e0d1f3cf609b1343ed9e8e";
const workflowId = "671b2ef6b23c71280eff3a64"; // WorkflowId of IN_QC workflow

and i changed subscriber's preference, changed the push channel to false;

novu.subscribers
  .updatePreference(subscriberId, workflowId, {
    channel: { type: "push", enabled: false },
    enabled: false,
  })
  .then((r) => {
    console.log("update preferences AAA");
  });
novu.subscribers.getPreference(subscriberId).then((r) => {
  console.log(" subscriber preferences", JSON.stringify(r.data.data));
});

then i will trigger a workflow to send push notification.

await novu.trigger("IN_QC", {
    to: {
      subscriberId,
      channels: [
        {
          providerId: PushProviderIdEnum.EXPO,
          credentials: {
            deviceTokens: ["ExponentPushToken[*******]"],
          },
        },
      ],
    },
    payload: { subject: "subject", body: "body" },
    bridgeUrl:
      "https://4d52105d-ceda-480a-9280-f614c6893d97.novu.sh/v1/novu-bridge-app",
  });

@yunluo1024
Copy link
Author

@jainpawan21 any thoughts?

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

No branches or pull requests

2 participants