NovuN
Novu4w ago
AndreMaz

@novu/api notification feed - query API

Context
I have multiple workflows, each receives unique payload as input.

In my step.email , step.inApp , step.push and etc. I can format data like so:
await step.push("push-step", async () => {
  return {
    subject,
    body,
    data: {
      orgId,
    },
  };
})


Then orgId can be then used in useNotifications
const { notifications, error, refetch, readAll } = useNotifications({ data: { orgId }, });

to fetch user's notification in context of the specified orgId

Problem
The problem is that @novu/api novu.subscribers.notifications.feed method does not allow to filter by data.orgId.

What's currently possible is to filter by partial input payload. From Docs:
Base64 encoded string of the partial payload JSON object
Source: https://docs.novu.co/api-reference/subscribers/retrieve-subscriber-notifications

And this is where the problem resides. As I've mentioned in the beginning, my worklows have different payload shape. This means that I cannot easily fetch the same notifications that I fetch via the useNotifications hook

Possible solutions
  • Add an endpoint that exposes exactly the same data structure as the useNotifications hook. This will allow to filter by data.orgId
  • Add OR method current endpoint. This way I can specify multiple partial payload inputs and fetch the notifications
Was this page helpful?