Headless service `fetchNotifications` should accept 'archived' filter
Really need this to be merged.
https://github.com/novuhq/novu/pull/7136
It's to add the archived filter onto the fetch Notifications. It's already on
getFilterQueryForMessage()
just need to add it in a couple of other places. Mainly apps/api/src/app/subscribers/dtos/get-in-app-notification-feed-for-subscriber.dto.ts
GitHub
fix(api): headless service fetchNotifications should accept archive...
What changed? Why was the change needed?
The fetchNotifications() within headless.service.ts uses the type IStoreQuery for the query. But this property does not have archived: boolean even though ...
6 Replies
@Pawan Jain
@Sigex
I have few questions:
1. Are you using
@novu/headless
npm package?
2. Do you have @novu/framework based workflows or old UI based workflows?
3. Are you using novu cloud or self hosting Novu?Hi Pawan,
1.Yes. We use the same approach as Midday
https://github.com/midday-ai/midday/blob/main/apps/dashboard/src/hooks/use-notifications.ts
2. Yes. We use
@novu/framework
to define workflow's and we use @novu/framework/next
3. Novu cloud.
---
The query object for the fetchNotifications is of type IStoreQuery
Notice the lack of archived
as one of the allowed filters. The fetchNotifications
for the Headless Service is defined in.
packages/headless/src/lib/headless.service.ts
The heavy work is done by this.api.getNotificationsList(page, query)
That hands off too;
The widgets controller has a Get
method which uses CQRS to execute the following command GetNotificationsFeedCommand
.GitHub
midday/apps/dashboard/src/hooks/use-notifications.ts at main · midd...
Invoicing, Time tracking, File reconciliation, Storage, Financial Overview & your own Assistant made for Freelancers - midday-ai/midday
The main execute for this makes a call to;
Heading over to
findBySubscriberChannel
we see;
Now this is where it gets interesting... So far all the way down this Rabit Hole archived
has not been present on the query object.
But... the query object is parsed into getFilterQueryForMessage
which does support archived
.
This getFilterQueryForMessage
is used by getCount
as well which does accept archived
.
So the solution here is to simply pass archived
all the way down.
Note:
The IStoreQuery
we use filters using the payload
. Which is not available on the notifications.list which can be accessed via useNovu
. So that one is not suitable. I am aware it does have archived
as a filter.@Sigex, you just advanced to level 1!