diff --git a/migrations/1660716115917-seedNotificationType.ts b/migrations/1660716115917-seedNotificationType.ts index 5ea6109..8d1d29c 100644 --- a/migrations/1660716115917-seedNotificationType.ts +++ b/migrations/1660716115917-seedNotificationType.ts @@ -892,7 +892,7 @@ export const GivethNotificationTypes = { }, { type: 'a', - content: '$poolName', + content: '$contractName', href: '/givfarm', }, { @@ -900,7 +900,7 @@ export const GivethNotificationTypes = { content: ' was successful.', }, ], - content: 'Staking {amount} of {poolName} was successful.', + content: 'Staking {amount} of {contractName} was successful.', }, UN_STAKE: { name: 'UnStake', @@ -933,7 +933,7 @@ export const GivethNotificationTypes = { }, { type: 'a', - content: '$poolName', + content: '$contractName', href: '/givfarm', }, { @@ -941,32 +941,32 @@ export const GivethNotificationTypes = { content: ' was successful.', }, ], - content: 'Unstaking {amount} of {poolname} was successful.', + content: 'Unstaking {amount} of {contractName} was successful.', }, - GIV_BACKS_ARE_READY_TO_CLAIM: { - name: 'GIVbacks are ready to claim', - title: 'GIVbacks', - description: 'When GIVbacks are ready to be claimed after each round', + GIV_BACK_IS_READY_TO_CLAIM: { + name: 'GIVback is ready to claim', + title: 'GIVback', + description: 'When GIVback is ready to be claimed after each round', showOnSettingPage: true, microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.GIV_ECONOMY, - icon: 'IconUnstake', - schemaValidator: SCHEMA_VALIDATORS_NAMES.GIV_FARM_READY_TO_CLAIM, - emailNotifierService: THIRD_PARTY_EMAIL_SERVICES.SEGMENT, - emailNotificationId: SegmentEvents.PROJECT_REJECTED, + icon: 'IconGIVBack', + schemaValidator: SCHEMA_VALIDATORS_NAMES.GIV_BACK_IS_READY_TO_CLAIM, + emailNotifierService: null, + emailNotificationId: null, pushNotifierService: null, htmlTemplate: [ { type: 'p', - content: 'Your GIVbacks for round ', + content: 'Your GIVback ', }, { type: 'b', - content: '$round', + content: '$amount', }, { type: 'p', - content: ' are ready to claim! ', + content: ' GIV is ready to claim! ', }, { type: 'br' }, { @@ -980,7 +980,7 @@ export const GivethNotificationTypes = { }, ], content: - 'Your GIVbacks for round {round number} are ready to claim! \n{Click here} to take a shortcut.', + 'Your GIVback {amount} GIV is ready to claim! \n{Click here} to take a shortcut.', }, PROJECT_EDITED: { name: 'Project edited', diff --git a/src/entities/notificationType.ts b/src/entities/notificationType.ts index fce53ab..7116d69 100644 --- a/src/entities/notificationType.ts +++ b/src/entities/notificationType.ts @@ -59,6 +59,7 @@ export const SCHEMA_VALIDATORS_NAMES = { USER_UNLOCKED_GIVPOWER: 'givPowerUserUnlockedGivPower', USER_GIVPOWER_RELOCKED_AUTOMATICALLY: 'givPowerUserGivPowerRelockedAutoMatically', + GIV_BACK_IS_READY_TO_CLAIM: 'givBackReadyToClaim', }; export type HtmlTemplate = { type: string; content: string; href?: string }[]; diff --git a/src/routes/v1/notificationRouter.test.ts b/src/routes/v1/notificationRouter.test.ts index 54bb295..70411db 100644 --- a/src/routes/v1/notificationRouter.test.ts +++ b/src/routes/v1/notificationRouter.test.ts @@ -1274,7 +1274,7 @@ function sendNotificationTestCases() { sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), metadata: { - poolName: 'GIV farm', + contractName: 'GIV farm', amount: '10', network: 100, transactionHash: generateRandomTxHash(), @@ -1298,7 +1298,7 @@ function sendNotificationTestCases() { sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), metadata: { - poolName: 'GIV farm', + contractName: 'GIV farm', network: 100, transactionHash: generateRandomTxHash(), }, @@ -1327,7 +1327,7 @@ function sendNotificationTestCases() { sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), metadata: { - poolName: 'GIVpower', + contractName: 'GIVpower', amount: '10', round: 13, transactionHash: generateRandomTxHash(), @@ -1353,7 +1353,7 @@ function sendNotificationTestCases() { userWalletAddress: generateRandomEthereumAddress(), metadata: { round: 11, - poolName: 'GIVpower', + contractName: 'GIVpower', transactionHash: generateRandomTxHash(), network: 100, }, @@ -1383,7 +1383,7 @@ function sendNotificationTestCases() { sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), metadata: { - poolName: 'GIV farm', + contractName: 'GIV farm', amount: '10', network: 100, transactionHash: generateRandomTxHash(), @@ -1407,7 +1407,7 @@ function sendNotificationTestCases() { sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), metadata: { - poolName: 'GIV farm', + contractName: 'GIV farm', network: 100, transactionHash: generateRandomTxHash(), }, @@ -1431,12 +1431,15 @@ function sendNotificationTestCases() { it('should create *GIVbacks are ready to claim* notification, success, segment is off', async () => { const data = { - eventName: 'GIVbacks are ready to claim', + eventName: 'GIVback is ready to claim', sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), metadata: { - round: 5, + contractName: 'Gnosis Chain Token Distro', + amount: '10', + network: 100, + transactionHash: generateRandomTxHash(), }, }; @@ -1452,11 +1455,15 @@ function sendNotificationTestCases() { it('should create *GIVbacks are ready to claim* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'GIVbacks are ready to claim', + eventName: 'GIVback is ready to claim', sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), - metadata: {}, + metadata: { + contractName: 'Gnosis Chain Token Distro', + network: 100, + transactionHash: generateRandomTxHash(), + }, }; await axios.post(sendNotificationUrl, data, { @@ -1471,7 +1478,7 @@ function sendNotificationTestCases() { e.response.data.message, errorMessagesEnum.IMPACT_GRAPH_VALIDATION_ERROR.message, ); - assert.equal(e.response.data.description, '"round" is required'); + assert.equal(e.response.data.description, '"amount" is required'); } }); diff --git a/src/services/segment/segmentAnalyticsSingleton.ts b/src/services/segment/segmentAnalyticsSingleton.ts index 00cdcaf..71f34f5 100644 --- a/src/services/segment/segmentAnalyticsSingleton.ts +++ b/src/services/segment/segmentAnalyticsSingleton.ts @@ -23,7 +23,8 @@ export enum SegmentEvents { PROJECT_BADGE_UP_FOR_REVOKING = 'Project badge up for revoking', PROJECT_VERIFIED = 'Project verified', PROJECT_REJECTED = 'Project rejected', - GIVBACK_ARE_READY_TO_CLAIM = 'We dont have event yet', + GIVBACKS_ARE_READY_TO_CLAIM = 'We dont have event yet', + GIVBACK_IS_READY_TO_CLAIM = 'We dont have event yet', PROJECT_UNVERIFIED = 'Project unverified', PROJECT_UNVERIFIED_USERS_WHO_BOOSTED = 'Project unverified - Users Who Boosted', PROJECT_ACTIVATED = 'Project activated', diff --git a/src/utils/validators/segmentAndMetadataValidators.ts b/src/utils/validators/segmentAndMetadataValidators.ts index debb45d..25f7630 100644 --- a/src/utils/validators/segmentAndMetadataValidators.ts +++ b/src/utils/validators/segmentAndMetadataValidators.ts @@ -43,14 +43,14 @@ const projectBoostedSchema = Joi.object({ }); const givPowerLockedSchema = Joi.object({ - poolName: Joi.string().required(), + contractName: Joi.string().required(), amount: Joi.string().required(), round: Joi.number()?.greater(0).required(), transactionHash: Joi.string().required(), network: Joi.number().required(), }); const givPowerUnLockedSchema = Joi.object({ - poolName: Joi.string().required(), + contractName: Joi.string().required(), amount: Joi.string().required(), round: Joi.number()?.greater(0).required(), transactionHash: Joi.string().required(), @@ -100,7 +100,7 @@ const getDonationPriceFailedMetadataSchema = Joi.object({ txLink: Joi.string().required(), }); const stakeUnStakeSchema = Joi.object({ - poolName: Joi.string().required(), + contractName: Joi.string().required(), transactionHash: Joi.string().required(), network: Joi.number().required(), amount: Joi.string().required(), @@ -115,6 +115,12 @@ const adminMessageSchema = Joi.object({ instruction: Joi.string().required(), href: Joi.string().required(), }); +const givBackReadyClaimSchema = Joi.object({ + contractName: Joi.string().required(), + transactionHash: Joi.string().required(), + network: Joi.number().required(), + amount: Joi.string().required(), +}); export const SEGMENT_METADATA_SCHEMA_VALIDATOR: { [key: string]: { @@ -259,6 +265,10 @@ export const SEGMENT_METADATA_SCHEMA_VALIDATOR: { metadata: givPowerLockedSchema, segment: null, }, + givBackReadyToClaim: { + metadata: givBackReadyClaimSchema, + segment: null, + } }; function throwHttpErrorIfJoiValidatorFails(