From 2b18f10dd17bd8717738493be37ec273c5f601d4 Mon Sep 17 00:00:00 2001 From: ali ebrahimi Date: Tue, 20 Aug 2024 05:40:23 +0330 Subject: [PATCH] Add donation received for Qacc flow --- src/entities/notificationType.ts | 4 ++-- src/services/notificationService.ts | 9 +++++++++ src/types/notifications.ts | 3 +++ .../validators/segmentAndMetadataValidators.ts | 13 +++++++++++++ src/validators/schemaValidators.ts | 5 +++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/entities/notificationType.ts b/src/entities/notificationType.ts index 8865d01..1777ee8 100644 --- a/src/entities/notificationType.ts +++ b/src/entities/notificationType.ts @@ -68,7 +68,7 @@ export const SCHEMA_VALIDATORS_NAMES = { YOUR_PROJECT_GOT_A_RANK: 'yourProjectGotARank', NOTIFY_REWARD_AMOUNT: 'notifyRewardAmount', - DONATION_RECEIVED_FOR_QACC: 'DonationReceivedForQacc', + DONATION_RECEIVED_FOR_QACC: 'donationReceivedForQacc', }; export type HtmlTemplate = { type: string; content: string; href?: string }[]; @@ -111,7 +111,7 @@ export class NotificationType extends BaseEntity { categoryGroup?: string; @Index() - @Column('text', { nullable: false }) + @Column('text', { nullable: false, unique: true }) name: string; @Column('text', { nullable: false }) diff --git a/src/services/notificationService.ts b/src/services/notificationService.ts index 1ed4a0f..c3879ec 100644 --- a/src/services/notificationService.ts +++ b/src/services/notificationService.ts @@ -198,6 +198,15 @@ export const activityCreator = ( 'str:cm:transactionhash': payload.transactionHash, }; break; + case NOTIFICATIONS_EVENT_NAMES.DONATION_RECEIVED_FOR_QACC: + attributes = { + 'str:cm:donationamount': payload.donationAmount, + 'str:cm:donationtoken': payload.donationToken, + 'str:cm:email': payload.email, + 'str:cm:projectlink': payload.projectLink, + 'str:cm:projecttitle': payload.projectTitle, + 'str:cm:transactionlink': payload.transactionLink, + }; default: logger.debug('activityCreator() invalid event name', orttoEventName); return; diff --git a/src/types/notifications.ts b/src/types/notifications.ts index 68d1d35..776d589 100644 --- a/src/types/notifications.ts +++ b/src/types/notifications.ts @@ -52,6 +52,7 @@ export enum NOTIFICATIONS_EVENT_NAMES { SEND_EMAIL_CONFIRMATION = 'Send email confirmation', SUBSCRIBE_ONBOARDING = 'Subscribe onboarding', NOTIFY_REWARD_AMOUNT = 'Notify reward amount', + DONATION_RECEIVED_FOR_QACC = 'Donation received for qacc', } export const ORTTO_EVENT_NAMES = { @@ -81,4 +82,6 @@ export const ORTTO_EVENT_NAMES = { 'verification-form-email-verification', [NOTIFICATIONS_EVENT_NAMES.NOTIFY_REWARD_AMOUNT]: 'notify-reward', [NOTIFICATIONS_EVENT_NAMES.SUBSCRIBE_ONBOARDING]: 'onboarding-form', + [NOTIFICATIONS_EVENT_NAMES.DONATION_RECEIVED_FOR_QACC]: + 'qacc-donation-received', }; diff --git a/src/utils/validators/segmentAndMetadataValidators.ts b/src/utils/validators/segmentAndMetadataValidators.ts index 915d5bf..09ff529 100644 --- a/src/utils/validators/segmentAndMetadataValidators.ts +++ b/src/utils/validators/segmentAndMetadataValidators.ts @@ -175,6 +175,15 @@ const notifyRewardAmountSegmentSchema = Joi.object({ email: Joi.string().required(), }); +const donationReceivedForQaccSegmentSchema = Joi.object({ + email: Joi.string().required(), + donationAmount: Joi.string().required(), + donationToken: Joi.string().required(), + projectLink: Joi.string().required(), + projectTitle: Joi.string().required(), + transactionLink: Joi.string().required(), +}); + export const SEGMENT_METADATA_SCHEMA_VALIDATOR: { [key: string]: { segment: ObjectSchema | null; @@ -352,4 +361,8 @@ export const SEGMENT_METADATA_SCHEMA_VALIDATOR: { metadata: null, segment: notifyRewardAmountSegmentSchema, }, + donationReceivedForQacc: { + metadata: null, + segment: donationReceivedForQaccSegmentSchema, + }, }; diff --git a/src/validators/schemaValidators.ts b/src/validators/schemaValidators.ts index ccd99ff..1853e7b 100644 --- a/src/validators/schemaValidators.ts +++ b/src/validators/schemaValidators.ts @@ -101,6 +101,11 @@ export const sendNotificationValidator = Joi.object({ network: Joi.string(), script: Joi.string(), transactionHash: Joi.string(), + + // Qacc donation received + donationAmount: Joi.string(), + donationToken: Joi.string(), + projectTitle: Joi.string(), }), }), });