File tree Expand file tree Collapse file tree 6 files changed +59
-0
lines changed
Expand file tree Collapse file tree 6 files changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ import { MigrationInterface , QueryRunner } from 'typeorm' ;
2+ import {
3+ SCHEMA_VALIDATORS_NAMES ,
4+ NotificationType ,
5+ } from '../src/entities/notificationType' ;
6+ import { NOTIFICATION_CATEGORY } from '../src/types/general' ;
7+ import { NOTIFICATIONS_EVENT_NAMES } from '../src/types/notifications' ;
8+ import { MICRO_SERVICES } from '../src/utils/utils' ;
9+
10+ const UserEmailConfirmationNotificationCodeFlowType = [
11+ {
12+ name : NOTIFICATIONS_EVENT_NAMES . SEND_USER_EMAIL_CONFIRMATION_CODE_FLOW ,
13+ description :
14+ NOTIFICATIONS_EVENT_NAMES . SEND_USER_EMAIL_CONFIRMATION_CODE_FLOW ,
15+ microService : MICRO_SERVICES . givethio ,
16+ category : NOTIFICATION_CATEGORY . ORTTO ,
17+ schemaValidator :
18+ SCHEMA_VALIDATORS_NAMES . SEND_USER_EMAIL_CONFIRMATION_CODE_FLOW ,
19+ } ,
20+ ] ;
21+
22+ export class AddUserEmailNotification1731590176819
23+ implements MigrationInterface
24+ {
25+ public async up ( queryRunner : QueryRunner ) : Promise < void > {
26+ await queryRunner . manager . save (
27+ NotificationType ,
28+ UserEmailConfirmationNotificationCodeFlowType ,
29+ ) ;
30+ }
31+
32+ public async down ( queryRunner : QueryRunner ) : Promise < void > {
33+ await queryRunner . query (
34+ `DELETE FROM notification_type WHERE "name" = 'Send email confirmation code flow';` ,
35+ ) ;
36+ }
37+ }
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import { NotificationSetting } from './notificationSetting';
1313// Export Object with Schemas to N1 lookup
1414export const SCHEMA_VALIDATORS_NAMES = {
1515 SEND_EMAIL_CONFIRMATION : 'sendEmailConfirmation' ,
16+ SEND_USER_EMAIL_CONFIRMATION_CODE_FLOW : 'sendUserEmailConfirmationCodeFlow' ,
1617 CREATE_ORTTO_PROFILE : 'createOrttoProfile' ,
1718 SUBSCRIBE_ONBOARDING : 'subscribeOnboarding' ,
1819 SUPERFLUID : 'userSuperTokensCritical' ,
Original file line number Diff line number Diff line change @@ -39,6 +39,13 @@ export const activityCreator = (
3939 'str:cm:verificationlink' : payload . verificationLink ,
4040 } ;
4141 break ;
42+ case NOTIFICATIONS_EVENT_NAMES . SEND_USER_EMAIL_CONFIRMATION_CODE_FLOW :
43+ attributes = {
44+ 'str:cm:email' : payload . email ,
45+ 'int:cm:code' : Number ( payload . verificationCode ) ,
46+ 'str:cm:userid' : payload . userId ?. toString ( ) ,
47+ } ;
48+ break ;
4249 case NOTIFICATIONS_EVENT_NAMES . CREATE_ORTTO_PROFILE :
4350 attributes = {
4451 'str:cm:email' : payload . email ,
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ export enum NOTIFICATIONS_EVENT_NAMES {
5050 SUPER_TOKENS_BALANCE_DEPLETED = 'Stream balance depleted' ,
5151 CREATE_ORTTO_PROFILE = 'Create Ortto profile' ,
5252 SEND_EMAIL_CONFIRMATION = 'Send email confirmation' ,
53+ SEND_USER_EMAIL_CONFIRMATION_CODE_FLOW = 'Send email confirmation code flow' ,
5354 SUBSCRIBE_ONBOARDING = 'Subscribe onboarding' ,
5455 NOTIFY_REWARD_AMOUNT = 'Notify reward amount' ,
5556}
@@ -81,4 +82,6 @@ export const ORTTO_EVENT_NAMES = {
8182 'verification-form-email-verification' ,
8283 [ NOTIFICATIONS_EVENT_NAMES . NOTIFY_REWARD_AMOUNT ] : 'notify-reward' ,
8384 [ NOTIFICATIONS_EVENT_NAMES . SUBSCRIBE_ONBOARDING ] : 'onboarding-form' ,
85+ [ NOTIFICATIONS_EVENT_NAMES . SEND_USER_EMAIL_CONFIRMATION_CODE_FLOW ] :
86+ 'email-verification-code' ,
8487} ;
Original file line number Diff line number Diff line change @@ -162,6 +162,12 @@ const sendEmailConfirmationSchema = Joi.object({
162162 verificationLink : Joi . string ( ) . required ( ) ,
163163} ) ;
164164
165+ const sendUserEmailConfirmationCodeFlowSchema = Joi . object ( {
166+ email : Joi . string ( ) . required ( ) ,
167+ verificationCode : Joi . string ( ) . required ( ) ,
168+ userId : Joi . number ( ) . required ( ) ,
169+ } ) ;
170+
165171const notifyRewardAmountSegmentSchema = Joi . object ( {
166172 round : Joi . number ( ) . required ( ) ,
167173 date : Joi . string ( ) . required ( ) ,
@@ -185,6 +191,10 @@ export const SEGMENT_METADATA_SCHEMA_VALIDATOR: {
185191 metadata : null ,
186192 segment : sendEmailConfirmationSchema ,
187193 } ,
194+ sendUserEmailConfirmationCodeFlow : {
195+ metadata : null ,
196+ segment : sendUserEmailConfirmationCodeFlowSchema ,
197+ } ,
188198 createOrttoProfile : {
189199 segment : createOrttoProfileSegmentSchema ,
190200 metadata : null ,
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ export const sendNotificationValidator = Joi.object({
5555 email : Joi . string ( ) . allow ( null ) . allow ( '' ) ,
5656 title : Joi . string ( ) ,
5757 slug : Joi . string ( ) ,
58+ verificationCode : Joi . string ( ) . allow ( null ) . allow ( '' ) ,
5859 firstName : Joi . string ( ) . allow ( null ) . allow ( '' ) ,
5960 userId : Joi . number ( ) ,
6061 projectLink : Joi . string ( ) . allow ( null ) . allow ( '' ) ,
You can’t perform that action at this time.
0 commit comments