diff --git a/apps/api/src/notifications/dto/massmail.dto.ts b/apps/api/src/notifications/dto/massmail.dto.ts index 543cd1c2..ead2c539 100644 --- a/apps/api/src/notifications/dto/massmail.dto.ts +++ b/apps/api/src/notifications/dto/massmail.dto.ts @@ -1,6 +1,6 @@ import { ApiProperty } from '@nestjs/swagger' import { Expose } from 'class-transformer' -import { IsDate, IsDateString, IsNumber, IsOptional, IsString } from 'class-validator' +import { IsDateString, IsNumber, IsOptional, IsString } from 'class-validator' export class MassMailDto { @ApiProperty() diff --git a/apps/api/src/notifications/notifications.service.ts b/apps/api/src/notifications/notifications.service.ts index c030d8d1..0972fed1 100644 --- a/apps/api/src/notifications/notifications.service.ts +++ b/apps/api/src/notifications/notifications.service.ts @@ -34,8 +34,6 @@ import { CampaignService } from '../campaign/campaign.service' import { KeycloakTokenParsed } from '../auth/keycloak' import { MassMailDto } from './dto/massmail.dto' import { randomUUID } from 'crypto' -import { MailDataRequired } from '@sendgrid/mail' -import { PersonalizationData } from '@sendgrid/helpers/classes/personalization' import { mapChunk } from '../common/mapChunk' type UnregisteredInsert = { @@ -570,7 +568,7 @@ export class MarketingNotificationsService { }) } async sendConsentMail(data: MassMailDto) { - const contacts = await this.marketingNotificationsProvider.getContactsFromList(data.listId) + const contacts = await this.marketingNotificationsProvider.getContactsFromList(data) const sendList: ContactsMap = new Map() const emailList = contacts.map((contact: ContactsResponse) => contact.email) diff --git a/apps/api/src/notifications/providers/notifications.sendgrid.provider.ts b/apps/api/src/notifications/providers/notifications.sendgrid.provider.ts index 7d575b9e..710829ee 100644 --- a/apps/api/src/notifications/providers/notifications.sendgrid.provider.ts +++ b/apps/api/src/notifications/providers/notifications.sendgrid.provider.ts @@ -10,6 +10,7 @@ import sgClient from '@sendgrid/client' import sgMail from '@sendgrid/mail' import { NotificationsProviderInterface } from './notifications.interface.providers' import { + ContactsFromListParams, ContactsResponse, SendGridExportStatusResponse, SendGridParams, @@ -81,7 +82,7 @@ export class SendGridNotificationsProvider return response.body as SendGridExportStatusResponse } - async getContactsFromList(listId: string) { + async getContactsFromList({ listId }: ContactsFromListParams) { const SENDGRID_EXPORT_TIMEOUT = 10000 const RETRY_LIMIT = 5 let numOfRetries = 0 diff --git a/apps/api/src/notifications/providers/notifications.sendgrid.types.ts b/apps/api/src/notifications/providers/notifications.sendgrid.types.ts index 39a36a9d..c0eebe42 100644 --- a/apps/api/src/notifications/providers/notifications.sendgrid.types.ts +++ b/apps/api/src/notifications/providers/notifications.sendgrid.types.ts @@ -11,7 +11,7 @@ export type SendGridParams = { RemoveFromUnsubscribedParams: RemoveFromUnsubscribedParams AddToUnsubscribedParams: AddToUnsubscribedParams SendNotificationParams: SendNotificationParams - GetContactsFromListParam: any + GetContactsFromListParam: ContactsFromListParams // Responses CreateListRes: string @@ -23,12 +23,15 @@ export type SendGridParams = { RemoveFromUnsubscribedRes: unknown AddToUnsubscribedRes: unknown SendNotificationRes: unknown - GetContactsFromListRes: any + GetContactsFromListRes: ContactsResponse[] // Implementation specific ContactData: ContactData } +export type ContactsFromListParams = { + listId: string +} type ContactData = { email: string first_name?: string