loopback4-microservice-catalog
loopback4-microservice-catalog copied to clipboard
/notification-users get api is not working for userTenantId (issue of @sourceloop/notification-service)
Is your feature request related to a problem? Please describe. /notification-users get api is not working for userTenantId because we are using user tenant id for our socket connection which is "to" parameter in request and currently it is comparing userId column value with token userId
Describe the solution you'd like We can check userTenantId for userId column or we should introduce a provider for checking column value
Describe alternatives you've considered currently using a new controller for handling /notification-users get api
@sandeep-sourcefuse I dont like the solution of adding a new provider for this. Any other solution ? @sourcefuse/sourceloop
@sandeep-sourcefuse can you please elaborate the issue? Do you want the userTeanantId in the response body?
@harshitmitSF there are two issue which i am facing in @sourceloop/notification-service but this is about first
We are using create-notification
{
"template": {
"method": "POST",
"url": "/notifications",
"headers": {
"content-type": "application/json",
"Authorization": "{token}"
},
"body": "{body}"
},
"functions": {
"createNotification": ["body", "token"]
}
},
and the body passed as
this.notificationService.createNotification(bearerToken, {
----
receiver: {
to: [{id: userTenantId}],
},
type: NotificationType.Push,
----
});
as you can see here we are passing userTenantId to send socket notification
but if we request for all notifications list for particular user then the condition check will incorrect as it is defined in
@sourceloop/notification-service/src/controllers/notification-user.controller.ts
private _createFilterBuilder(
currentUser: IAuthUserWithPermissions,
filter: Filter<NotificationUser> = {},
) {
const filterBuilder = new FilterBuilder(filter);
if (filter) {
const whereBuilder = new WhereBuilder(filter.where);
whereBuilder.and([
{
userId: currentUser.id,
},
]);
filterBuilder.where(whereBuilder.build());
}
return filterBuilder;
}
In above check we are using userId: currentUser.id, not userId: currentUser.userTenantId,
so can we get something to define our condition
@sandeep-sourcefuse I think if we use currentUser.userTenantId instead of currentUser.id the issue will be resolved. Right?
@harshitmitSF for my case it will work fine, but again other user may want to use currentUser.id