Skip to content

Commit

Permalink
Add service subscription check (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
AleDore authored Jul 8, 2021
1 parent a587b98 commit d8e20c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions GetSubscriptionsFeed/__tests__/handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ describe("GetSubscriptionsFeedHandler", () => {
// service subscriptions
queryEntities.mockImplementationOnce(
queryEntitiesServiceSubscriptionMock(
[anHashedFiscalCode, anotherHashedFiscalCode],
[anHashedFiscalCode],
"S"
)
);
Expand All @@ -283,7 +283,7 @@ describe("GetSubscriptionsFeedHandler", () => {
expect(result.value).toEqual({
dateUTC: yesterdayUTC,
subscriptions: [],
unsubscriptions: [anHashedFiscalCode, anotherHashedFiscalCode]
unsubscriptions: [anotherHashedFiscalCode]
});
}
});
Expand Down
13 changes: 8 additions & 5 deletions GetSubscriptionsFeed/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,14 @@ export function GetSubscriptionsFeedHandler(

const unsubscriptions = new Array<FiscalCodeHash>();

profileUnsubscriptionsSet.forEach(pu =>
// add all users that deleted its own account
// eslint-disable-next-line functional/immutable-data
unsubscriptions.push(pu)
);
profileUnsubscriptionsSet.forEach(pu => {
if (!serviceSubscriptionsSet.has(pu)) {
// add all users that deleted its own account skipping those that
// subscribed to this service
// eslint-disable-next-line functional/immutable-data
unsubscriptions.push(pu);
}
});

serviceUnsubscriptionsSet.forEach(su => {
if (
Expand Down

0 comments on commit d8e20c7

Please sign in to comment.