Skip to content

Commit

Permalink
fix(api, application-generic): Filter with supplied tags when fetch…
Browse files Browse the repository at this point in the history
…ing subscriber preferences (#6991)
  • Loading branch information
rifont authored Nov 13, 2024
1 parent 20ff94c commit 01858f5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions apps/api/src/app/inbox/e2e/get-preferences.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe('Get all preferences - /inbox/preferences (GET)', function () {
it('should allow filtering preferences by tags', async function () {
const newsletterTag = 'newsletter';
const securityTag = 'security';
const marketingTag = 'marketing';
await session.createTemplate({
noFeedId: true,
tags: [newsletterTag],
Expand All @@ -68,6 +69,14 @@ describe('Get all preferences - /inbox/preferences (GET)', function () {
noFeedId: true,
tags: [securityTag],
});
await session.createTemplate({
noFeedId: true,
tags: [marketingTag],
});
await session.createTemplate({
noFeedId: true,
tags: [],
});

const response = await session.testAgent
.get(`/v1/inbox/preferences?tags[]=${newsletterTag}&tags[]=${securityTag}`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ describe('GetInboxPreferences', () => {
environmentId: command.environmentId,
subscriberId: command.subscriberId,
organizationId: command.organizationId,
tags: undefined,
})
);

Expand Down Expand Up @@ -216,6 +217,7 @@ describe('GetInboxPreferences', () => {
environmentId: command.environmentId,
subscriberId: command.subscriberId,
organizationId: command.organizationId,
tags: command.tags,
})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class GetInboxPreferences {
environmentId: command.environmentId,
subscriberId: command.subscriberId,
organizationId: command.organizationId,
tags: command.tags,
})
);
const workflowPreferences = subscriberWorkflowPreferences.map((subscriberWorkflowPreference) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { IsArray, IsOptional, IsString } from 'class-validator';
import { EnvironmentWithSubscriber } from '../../commands/project.command';

export class GetSubscriberPreferenceCommand extends EnvironmentWithSubscriber {}
export class GetSubscriberPreferenceCommand extends EnvironmentWithSubscriber {
@IsOptional()
@IsArray()
@IsString({ each: true })
tags?: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class GetSubscriberPreference {
{
organizationId: command.organizationId,
environmentId: command.environmentId,
tags: command.tags,
},
);

Expand Down

0 comments on commit 01858f5

Please sign in to comment.