Skip to content

Commit

Permalink
Add donation received for Qacc flow
Browse files Browse the repository at this point in the history
  • Loading branch information
ae2079 committed Aug 20, 2024
1 parent 050c87c commit 2b18f10
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/entities/notificationType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }[];

Expand Down Expand Up @@ -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 })
Expand Down
9 changes: 9 additions & 0 deletions src/services/notificationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Check failure on line 210 in src/services/notificationService.ts

View workflow job for this annotation

GitHub Actions / test

Expected a 'break' statement before 'default'
logger.debug('activityCreator() invalid event name', orttoEventName);
return;
Expand Down
3 changes: 3 additions & 0 deletions src/types/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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',
};
13 changes: 13 additions & 0 deletions src/utils/validators/segmentAndMetadataValidators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -352,4 +361,8 @@ export const SEGMENT_METADATA_SCHEMA_VALIDATOR: {
metadata: null,
segment: notifyRewardAmountSegmentSchema,
},
donationReceivedForQacc: {
metadata: null,
segment: donationReceivedForQaccSegmentSchema,
},
};
5 changes: 5 additions & 0 deletions src/validators/schemaValidators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}),
}),
});
Expand Down

0 comments on commit 2b18f10

Please sign in to comment.