From 6a6abd8cde75d2371ab99f5526463a2955ca7ca4 Mon Sep 17 00:00:00 2001 From: Mohammad Ranjbar Z Date: Thu, 19 Jan 2023 12:03:08 +0330 Subject: [PATCH 1/4] Modify project update added - Users who supported notificationType related to https://github.com/Giveth/impact-graph/issues/809 --- .../1660716115917-seedNotificationType.ts | 111 ++---------- src/entities/notificationSetting.ts | 2 +- src/entities/notificationType.ts | 3 +- src/routes/v1/notificationRouter.test.ts | 163 +----------------- .../segment/segmentAnalyticsSingleton.ts | 8 +- .../segmentAndMetadataValidators.ts | 10 +- 6 files changed, 35 insertions(+), 262 deletions(-) diff --git a/migrations/1660716115917-seedNotificationType.ts b/migrations/1660716115917-seedNotificationType.ts index fd80bf3..76ceb5a 100644 --- a/migrations/1660716115917-seedNotificationType.ts +++ b/migrations/1660716115917-seedNotificationType.ts @@ -290,7 +290,7 @@ export const GivethNotificationTypes = { category: NOTIFICATION_CATEGORY.PROJECT_RELATED, icon: 'IconUnlisted', schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UNLISTED, - categoryGroup: NOTIFICATION_CATEGORY_GROUPS.LIKED_BY_YOU_PROJECT_GROUP, + categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPPORTED_BY_YOU_PROJECT_GROUP, emailNotifierService: null, emailNotificationId: null, pushNotifierService: null, @@ -423,7 +423,7 @@ export const GivethNotificationTypes = { category: NOTIFICATION_CATEGORY.PROJECT_RELATED, icon: 'IconDeactivated', schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_CANCELLED, - categoryGroup: NOTIFICATION_CATEGORY_GROUPS.LIKED_BY_YOU_PROJECT_GROUP, + categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPPORTED_BY_YOU_PROJECT_GROUP, emailNotifierService: null, emailNotificationId: null, pushNotifierService: null, @@ -520,7 +520,7 @@ export const GivethNotificationTypes = { category: NOTIFICATION_CATEGORY.PROJECT_RELATED, icon: 'IconActivated', schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_ACTIVATED, - categoryGroup: NOTIFICATION_CATEGORY_GROUPS.LIKED_BY_YOU_PROJECT_GROUP, + categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPPORTED_BY_YOU_PROJECT_GROUP, emailNotifierService: null, emailNotificationId: null, pushNotifierService: null, @@ -615,7 +615,7 @@ export const GivethNotificationTypes = { category: NOTIFICATION_CATEGORY.PROJECT_RELATED, icon: 'IconDeactivated', schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_DEACTIVATED, - categoryGroup: NOTIFICATION_CATEGORY_GROUPS.LIKED_BY_YOU_PROJECT_GROUP, + categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPPORTED_BY_YOU_PROJECT_GROUP, emailNotifierService: null, emailNotificationId: null, pushNotifierService: null, @@ -709,7 +709,7 @@ export const GivethNotificationTypes = { category: NOTIFICATION_CATEGORY.PROJECT_RELATED, icon: 'IconVerifiedBadge', schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_VERIFIED, - categoryGroup: NOTIFICATION_CATEGORY_GROUPS.LIKED_BY_YOU_PROJECT_GROUP, + categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPPORTED_BY_YOU_PROJECT_GROUP, emailNotifierService: null, emailNotificationId: null, pushNotifierService: null, @@ -1358,58 +1358,8 @@ export const GivethNotificationTypes = { ], content: 'Your project update was successful.', }, - NEW_PROJECT_UPDATE_DONORS: { - name: 'Project update - Donors', - description: 'Project update - Donors', - microService: MICRO_SERVICES.givethio, - category: NOTIFICATION_CATEGORY.DISCUSSION, - icon: 'IconFile', - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UPDATED_DONOR, - emailNotifierService: null, - emailNotificationId: null, - pushNotifierService: null, - title: 'Project update - Donors', - htmlTemplate: [ - { - type: 'a', - content: '$projectTitle', - href: '$projectLink', - }, - { - type: 'p', - content: ' that you donated before posted an update.', - }, - ], - content: '{Project name} that you donated before posted an update.', - }, - NEW_PROJECT_UPDATE_USERS_WHO_LIKED: { - name: 'Project update - Users Who Liked', - description: 'Project update - Users Who Liked', - microService: MICRO_SERVICES.givethio, - category: NOTIFICATION_CATEGORY.DISCUSSION, - icon: 'IconFile', - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UPDATED_WHO_LIKED, - categoryGroup: NOTIFICATION_CATEGORY_GROUPS.LIKED_BY_YOU_PROJECT_GROUP, - emailNotifierService: null, - emailNotificationId: null, - pushNotifierService: null, - title: 'Project update - Users Who Liked', - htmlTemplate: [ - { - type: 'a', - content: '$projectTitle', - href: '$projectLink', - }, - { - type: 'p', - content: 'that you liked before posted an update.', - }, - ], - content: '{Project name} that you liked before posted an update.', - }, - - PROJECT_UPDATED_OWNER: { - name: 'Project updated - owner', + PROJECT_UPDATE_ADDED_OWNER: { + name: 'Project update added - owner', title: 'Your project update', description: 'You Posted an update on your project', showOnSettingPage: true, @@ -1418,7 +1368,7 @@ export const GivethNotificationTypes = { icon: '', schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_EDITED, emailNotifierService: THIRD_PARTY_EMAIL_SERVICES.SEGMENT, - emailNotificationId: SegmentEvents.PROJECT_UPDATED_OWNER, + emailNotificationId: SegmentEvents.PROJECT_UPDATE_ADDED_OWNER, pushNotifierService: null, htmlTemplate: [ { @@ -1428,31 +1378,6 @@ export const GivethNotificationTypes = { ], content: 'Your project update was successful.', // Missing copy }, - PROJECT_UPDATED_DONOR: { - name: 'Project updated - donor', - description: - 'Send notification to donors that the project has added an updated', - microService: MICRO_SERVICES.givethio, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - icon: '', - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_EDITED, - emailNotifierService: THIRD_PARTY_EMAIL_SERVICES.SEGMENT, - emailNotificationId: SegmentEvents.PROJECT_UPDATED_DONOR, - pushNotifierService: null, - title: 'Project posted an update', - htmlTemplate: [ - { - type: 'a', - content: '$projectTitle', - href: '$projectLink', - }, - { - type: 'p', - content: ' that you donated before posted an update.', - }, - ], - content: '{Project name} that you donated before posted an update.', - }, VERIFICATION_FORM_GOT_DRAFT_BY_ADMIN: { name: 'Verification form got draft by admin', @@ -1512,18 +1437,18 @@ export const GivethNotificationTypes = { ], content: 'Nice! Your project {project name} received a like', }, - NEW_PROJECT_UPDATE_FOR_USERS_WHO_LIKED: { - name: 'Project updates', - title: 'Your liked project update', - description: 'When your liked project has an update', + NEW_PROJECT_UPDATE_FOR_USERS_WHO_SUPPORTED: { + name: 'Project update added - Users who supported', + title: 'Supported project updated', + description: 'When your supported project has an update', showOnSettingPage: true, microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.PROJECT_RELATED, icon: '', - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UPDATED_WHO_LIKED, - categoryGroup: NOTIFICATION_CATEGORY_GROUPS.LIKED_BY_YOU_PROJECT_GROUP, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UPDATED_ADDED_WHO_SUPPORTS, + categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPPORTED_BY_YOU_PROJECT_GROUP, emailNotifierService: THIRD_PARTY_EMAIL_SERVICES.SEGMENT, - emailNotificationId: 'Project updated - Users who liked', + emailNotificationId: 'Project update added - Users who supported', pushNotifierService: null, htmlTemplate: [ { @@ -1533,10 +1458,10 @@ export const GivethNotificationTypes = { }, { type: 'p', - content: 'that you liked before posted an update.', + content: 'that you are supporting posted an update.', }, ], - content: '{Project name} that you liked before posted an update.', + content: '{Project name} that you are supporting posted an update.', }, YOU_BOOSTED: { name: 'You boosted', @@ -1904,7 +1829,7 @@ export const GivethNotificationTypes = { ], category: NOTIFICATION_CATEGORY.PROJECT_RELATED, icon: '', - categoryGroup: NOTIFICATION_CATEGORY_GROUPS.LIKED_BY_YOU_PROJECT_GROUP, + categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPPORTED_BY_YOU_PROJECT_GROUP, }, RAW_HTML: { diff --git a/src/entities/notificationSetting.ts b/src/entities/notificationSetting.ts index db92441..8fcec24 100644 --- a/src/entities/notificationSetting.ts +++ b/src/entities/notificationSetting.ts @@ -16,7 +16,7 @@ export const NOTIFICATION_CATEGORY_GROUPS = { GIVPOWER_ALLOCATIONS: 'givPowerAllocations', PROJECT_BOOSTING_STATUS: 'projectBoostStatus', SELF_BOOSTING_STATUS: 'yourBoostStatus', - LIKED_BY_YOU_PROJECT_GROUP: 'likedByYouProjects', + SUPPORTED_BY_YOU_PROJECT_GROUP: 'supportedByYouProjects', PROJECT_STATUS: 'projectStatus', DONATIONS: 'donations', STAKING: 'stakes', diff --git a/src/entities/notificationType.ts b/src/entities/notificationType.ts index 4faa0d0..425ec90 100644 --- a/src/entities/notificationType.ts +++ b/src/entities/notificationType.ts @@ -23,6 +23,7 @@ export const SCHEMA_VALIDATORS_NAMES = { PROJECT_LISTED: 'projectListed', PROJECT_UNLISTED: 'projectUnlisted', PROJECT_EDITED: 'projectEdited', + PROJECT_UPDATE_ADDED_OWNER: 'projectUpdateAddedOwner', PROJECT_BADGE_REVOKED: 'projectBadgeRevoked', PROJECT_BADGE_REVOKE_REMINDER: 'projectBadgeRevokeReminder', PROJECT_BADGE_REVOKE_WARNING: 'projectBadgeRevokeWarning', @@ -49,7 +50,7 @@ export const SCHEMA_VALIDATORS_NAMES = { DONATION_RECEIVED: 'donationReceived', PROJECT_UPDATED_DONOR: 'projectUpdatedDonor', PROJECT_UPDATED_OWNER: 'projectUpdatedOwner', - PROJECT_UPDATED_WHO_LIKED: 'projectUpdatedWhoLiked', + PROJECT_UPDATED_ADDED_WHO_SUPPORTS: 'projectUpdateAddedWhoSupported', PROJECT_CREATED: 'projectCreated', GET_DONATION_PRICE_FAILED: 'getDonationPriceFailed', VERIFICATION_FORM_GOT_DRAFT_BY_ADMIN: 'verificationFormDrafted', diff --git a/src/routes/v1/notificationRouter.test.ts b/src/routes/v1/notificationRouter.test.ts index fb8bfe5..3d6668a 100644 --- a/src/routes/v1/notificationRouter.test.ts +++ b/src/routes/v1/notificationRouter.test.ts @@ -1871,55 +1871,6 @@ function sendNotificationTestCases() { } }); - it('should create *Project update - Donors* notification, success, segment is off', async () => { - const data = { - eventName: 'Project update - Donors', - sendEmail: false, - sendSegment: false, - userWalletAddress: generateRandomEthereumAddress(), - metadata: { - projectTitle, - projectLink, - }, - }; - - const result = await axios.post(sendNotificationUrl, data, { - headers: { - authorization: getGivethIoBasicAuth(), - }, - }); - assert.equal(result.status, 200); - assert.isOk(result.data); - assert.isTrue(result.data.success); - }); - it('should create *Project update - Donors* notification, failed invalid metadata, segment is off', async () => { - try { - const data = { - eventName: 'Project update - Donors', - sendEmail: false, - sendSegment: false, - userWalletAddress: generateRandomEthereumAddress(), - metadata: { - projectLink, - }, - }; - - await axios.post(sendNotificationUrl, data, { - headers: { - authorization: getGivethIoBasicAuth(), - }, - }); - // If request doesn't fail, it means this test failed - assert.isTrue(false); - } catch (e: any) { - assert.equal( - e.response.data.message, - errorMessagesEnum.IMPACT_GRAPH_VALIDATION_ERROR.message, - ); - assert.equal(e.response.data.description, '"projectTitle" is required'); - } - }); - it('should create *Project update* notification, success, segment is off', async () => { const data = { eventName: 'Project update', @@ -1969,107 +1920,9 @@ function sendNotificationTestCases() { } }); - it('should create *Project update - Donors* notification, success, segment is off', async () => { - const data = { - eventName: 'Project update - Donors', - sendEmail: false, - sendSegment: false, - userWalletAddress: generateRandomEthereumAddress(), - metadata: { - projectTitle, - projectLink, - }, - }; - - const result = await axios.post(sendNotificationUrl, data, { - headers: { - authorization: getGivethIoBasicAuth(), - }, - }); - assert.equal(result.status, 200); - assert.isOk(result.data); - assert.isTrue(result.data.success); - }); - it('should create *Project update - Donors* notification, failed invalid metadata, segment is off', async () => { - try { - const data = { - eventName: 'Project update - Donors', - sendEmail: false, - sendSegment: false, - userWalletAddress: generateRandomEthereumAddress(), - metadata: { - projectLink, - }, - }; - - await axios.post(sendNotificationUrl, data, { - headers: { - authorization: getGivethIoBasicAuth(), - }, - }); - // If request doesn't fail, it means this test failed - assert.isTrue(false); - } catch (e: any) { - assert.equal( - e.response.data.message, - errorMessagesEnum.IMPACT_GRAPH_VALIDATION_ERROR.message, - ); - assert.equal(e.response.data.description, '"projectTitle" is required'); - } - }); - - it('should create *Project update - Users Who Liked* notification, success, segment is off', async () => { - const data = { - eventName: 'Project update - Users Who Liked', - sendEmail: false, - sendSegment: false, - userWalletAddress: generateRandomEthereumAddress(), - metadata: { - projectTitle, - projectLink, - }, - }; - - const result = await axios.post(sendNotificationUrl, data, { - headers: { - authorization: getGivethIoBasicAuth(), - }, - }); - assert.equal(result.status, 200); - assert.isOk(result.data); - assert.isTrue(result.data.success); - }); - it('should create *Project update - Users Who Liked* notification, failed invalid metadata, segment is off', async () => { - try { - const data = { - eventName: 'Project update - Users Who Liked', - sendEmail: false, - sendSegment: false, - userWalletAddress: generateRandomEthereumAddress(), - metadata: { - projectLink, - }, - }; - - await axios.post(sendNotificationUrl, data, { - headers: { - authorization: getGivethIoBasicAuth(), - }, - }); - // If request doesn't fail, it means this test failed - assert.isTrue(false); - } catch (e: any) { - assert.equal( - e.response.data.message, - errorMessagesEnum.IMPACT_GRAPH_VALIDATION_ERROR.message, - ); - assert.equal(e.response.data.description, '"projectTitle" is required'); - } - }); - - it('should create *Project updated - owner* notification, success, segment is off', async () => { + it('should create *Project update added - Users who supported* notification, success, segment is off', async () => { const data = { - eventName: 'Project updated - owner', + eventName: 'Project update added - Users who supported', sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -2088,10 +1941,10 @@ function sendNotificationTestCases() { assert.isOk(result.data); assert.isTrue(result.data.success); }); - it('should create *Project updated - owner* notification, failed invalid metadata, segment is off', async () => { + it('should create *Project update added - Users who supported* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project updated - owner', + eventName: 'Project update added - Users who supported', sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -2116,9 +1969,9 @@ function sendNotificationTestCases() { } }); - it('should create *Project updated - donor* notification, success, segment is off', async () => { + it('should create *Project update added - owner* notification, success, segment is off', async () => { const data = { - eventName: 'Project updated - donor', + eventName: 'Project update added - owner', sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -2137,10 +1990,10 @@ function sendNotificationTestCases() { assert.isOk(result.data); assert.isTrue(result.data.success); }); - it('should create *Project updated - donor* notification, failed invalid metadata, segment is off', async () => { + it('should create *Project update added - owner* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project updated - donor', + eventName: 'Project update added - owner', sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), diff --git a/src/services/segment/segmentAnalyticsSingleton.ts b/src/services/segment/segmentAnalyticsSingleton.ts index 71f34f5..d0ab2c8 100644 --- a/src/services/segment/segmentAnalyticsSingleton.ts +++ b/src/services/segment/segmentAnalyticsSingleton.ts @@ -23,8 +23,6 @@ export enum SegmentEvents { PROJECT_BADGE_UP_FOR_REVOKING = 'Project badge up for revoking', PROJECT_VERIFIED = 'Project verified', PROJECT_REJECTED = 'Project rejected', - 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', @@ -32,11 +30,7 @@ export enum SegmentEvents { PROJECT_CANCELLED = 'Project cancelled', MADE_DONATION = 'Made donation', DONATION_RECEIVED = 'Donation received', - PROJECT_UPDATED_DONOR = 'Project updated - donor', - PROJECT_UPDATED_OWNER = 'Project updated - owner', - PROJECT_CREATED = 'Project created', - UPDATED_PROFILE = 'Updated profile', - GET_DONATION_PRICE_FAILED = 'Get Donation Price Failed', + PROJECT_UPDATE_ADDED_OWNER = 'Project update added - owner', VERIFICATION_FORM_GOT_DRAFT_BY_ADMIN = 'Verification form got draft by admin', } diff --git a/src/utils/validators/segmentAndMetadataValidators.ts b/src/utils/validators/segmentAndMetadataValidators.ts index 496bfd2..343767e 100644 --- a/src/utils/validators/segmentAndMetadataValidators.ts +++ b/src/utils/validators/segmentAndMetadataValidators.ts @@ -212,10 +212,6 @@ export const SEGMENT_METADATA_SCHEMA_VALIDATOR: { metadata: projectTitleProjectLinkSchema, segment: donationTrackerSchema, }, - projectUpdatedDonor: { - metadata: projectTitleProjectLinkSchema, - segment: projectRelatedTrackerSchema, - }, projectUpdatedOwner: { metadata: projectTitleProjectLinkSchema, segment: projectRelatedTrackerSchema, @@ -240,7 +236,11 @@ export const SEGMENT_METADATA_SCHEMA_VALIDATOR: { metadata: projectTitleProjectLinkSchema, segment: null, }, - projectUpdatedWhoLiked: { + projectUpdateAddedWhoSupported: { + metadata: projectTitleProjectLinkSchema, + segment: null, + }, + projectUpdateAddedOwner: { metadata: projectTitleProjectLinkSchema, segment: null, }, From 14722011cbdb150ad3a1198de2aa779acf0f5d8c Mon Sep 17 00:00:00 2001 From: Mohammad Ranjbar Z Date: Sun, 22 Jan 2023 13:06:59 +0330 Subject: [PATCH 2/4] Fix unlisted notification for who supported project --- .../1660716115917-seedNotificationType.ts | 67 +++++-------------- src/routes/v1/notificationRouter.test.ts | 63 ++--------------- src/types/general.ts | 16 +++++ 3 files changed, 38 insertions(+), 108 deletions(-) diff --git a/migrations/1660716115917-seedNotificationType.ts b/migrations/1660716115917-seedNotificationType.ts index 76ceb5a..a1889da 100644 --- a/migrations/1660716115917-seedNotificationType.ts +++ b/migrations/1660716115917-seedNotificationType.ts @@ -4,7 +4,7 @@ import { SCHEMA_VALIDATORS_NAMES, } from '../src/entities/notificationType'; import { MICRO_SERVICES, THIRD_PARTY_EMAIL_SERVICES } from '../src/utils/utils'; -import { NOTIFICATION_CATEGORY } from '../src/types/general'; +import {NOTIFICATION_CATEGORY, NOTIFICATION_TYPE_NAMES} from '../src/types/general'; import { NOTIFICATION_CATEGORY_GROUPS } from '../src/entities/notificationSetting'; import { SegmentEvents } from '../src/services/segment/segmentAnalyticsSingleton'; @@ -12,7 +12,7 @@ import { SegmentEvents } from '../src/services/segment/segmentAnalyticsSingleton // icons https://gist.github.com/MohammadPCh/31e2b750dd9aa54edb21dcc6e7332efb export const GivethNotificationTypes = { EMAIL_NOTIFICATIONS: { - name: 'Email notifications', + name: NOTIFICATION_TYPE_NAMES.EMAIL_NOTIFICATION, description: 'Turn on/off all email notifications', microService: MICRO_SERVICES.givethio, category: 'general', @@ -26,7 +26,7 @@ export const GivethNotificationTypes = { isGlobal: true, }, DAPP_NOTIFICATIONS: { - name: 'Dapp notifications', + name: NOTIFICATION_TYPE_NAMES.DAPP_NOTIFICATIONS, description: 'Turn on/off all Dapp notifications', microService: MICRO_SERVICES.givethio, category: 'general', @@ -41,7 +41,7 @@ export const GivethNotificationTypes = { }, // SEGMENT INCOMPLETE_PROFILE: { - name: 'Incomplete profile', + name: NOTIFICATION_TYPE_NAMES.INCOMPLETE_PROFILE, description: 'Please complete your profile', microService: MICRO_SERVICES.givethio, category: 'general', @@ -60,7 +60,7 @@ export const GivethNotificationTypes = { ], }, WELCOME: { - name: 'Welcome', + name: NOTIFICATION_TYPE_NAMES.WELCOME, description: "Welcome to Giveth! ❤️ So happy you're here.", microService: MICRO_SERVICES.givethio, category: 'general', @@ -79,7 +79,7 @@ export const GivethNotificationTypes = { content: "Welcome to Giveth! ❤️ So happy you're here.", }, COMPLETE_PROFILE: { - name: 'The profile has been completed', + name: NOTIFICATION_TYPE_NAMES.PROFILE_HAS_BEEN_COMPLETED, description: 'Thanks for completing your profile', microService: MICRO_SERVICES.givethio, category: 'general', @@ -98,7 +98,7 @@ export const GivethNotificationTypes = { content: 'Done! Your profile is complete 🙂', }, ADMIN_MESSAGE: { - name: 'Admin message', + name: NOTIFICATION_TYPE_NAMES.ADMIN_MESSAGE, description: 'Admin message', microService: MICRO_SERVICES.givethio, category: 'general', @@ -131,7 +131,7 @@ export const GivethNotificationTypes = { }, }, DRAFTED_PROJECT_SAVED: { - name: 'The project saved as draft', + name: NOTIFICATION_TYPE_NAMES.DRAFT_PROJECT_HAS_BEEN_SAVED_OWNER, description: 'The project saved as draft', category: NOTIFICATION_CATEGORY.PROJECT_RELATED, icon: 'IconFile', @@ -160,7 +160,7 @@ export const GivethNotificationTypes = { ], }, DRAFTED_PROJECT_ACTIVATED: { - name: 'Draft published', + name: NOTIFICATION_TYPE_NAMES.DRAFT_PUBLISHED_OWNER, title: 'Project published', description: 'When Project has been published', showOnSettingPage: true, @@ -190,7 +190,7 @@ export const GivethNotificationTypes = { ], }, PROJECT_LISTED: { - name: 'Project listed', + name: NOTIFICATION_TYPE_NAMES.PROJECT_LISTED_OWNER, description: 'Project has been listed!', category: NOTIFICATION_CATEGORY.PROJECT_RELATED, icon: 'IconListed', @@ -219,7 +219,7 @@ export const GivethNotificationTypes = { content: 'Nice! Your {project name} project is listed.', }, PROJECT_UNLISTED: { - name: 'Project unlisted', + name: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_OWNER, description: 'Project has been unlisted!', microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.PROJECT_RELATED, @@ -248,7 +248,7 @@ export const GivethNotificationTypes = { content: 'Your {project name} project is no longer visible.', }, PROJECT_UNLISTED_FOR_DONORS: { - name: 'Project unlisted - Donors', + name: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_SUPPORTED, description: 'Project has been unlisted!', microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.PROJECT_RELATED, @@ -270,7 +270,7 @@ export const GivethNotificationTypes = { }, { type: 'p', - content: ' that you donated before is no longer visible.', + content: ' that you are supporting is no longer visible.', }, { type: 'br', @@ -281,47 +281,10 @@ export const GivethNotificationTypes = { }, ], content: - 'The {project name} that you donated before is no longer visible.\n{reason}', - }, - PROJECT_UNLISTED_FOR_USERS_WHO_LIKED: { - name: 'Project unlisted - Users Who Liked', - description: 'Project has been unlisted!', - microService: MICRO_SERVICES.givethio, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - icon: 'IconUnlisted', - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UNLISTED, - categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPPORTED_BY_YOU_PROJECT_GROUP, - emailNotifierService: null, - emailNotificationId: null, - pushNotifierService: null, - title: 'Project is unlisted', - htmlTemplate: [ - { - type: 'p', - content: 'The ', - }, - { - type: 'a', - content: '$projectTitle', - href: '$projectLink', - }, - { - type: 'p', - content: ' that you liked is no longer visible.', - }, - { - type: 'br', - }, - { - type: 'p', - content: '$reason', - }, - ], - content: - 'The {project name} that you donated before is no longer visible.\n{reason}', + 'The {project name} that you are supporting is no longer visible.\n{reason}', }, PROJECT_BOOSTED: { - name: 'Project boosted', + name: NOTIFICATION_TYPE_NAMES.PROJECT_BOOSTED_OWNER, description: 'Project has been boosted', microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.PROJECT_RELATED, diff --git a/src/routes/v1/notificationRouter.test.ts b/src/routes/v1/notificationRouter.test.ts index 3d6668a..c40065b 100644 --- a/src/routes/v1/notificationRouter.test.ts +++ b/src/routes/v1/notificationRouter.test.ts @@ -12,6 +12,7 @@ import { assert } from 'chai'; import { errorMessages, errorMessagesEnum } from '../../utils/errorMessages'; import { findNotificationByTrackId } from '../../repositories/notificationRepository'; import { generateRandomString } from '../../utils/utils'; +import {NOTIFICATION_TYPE_NAMES} from "../../types/general"; describe('/notifications POST test cases', sendNotificationTestCases); describe('/notificationsBulk POST test cases', sendBulkNotificationsTestCases); @@ -392,7 +393,7 @@ function sendNotificationTestCases() { it('should create *Project unlisted* notification, success, segment is off', async () => { const data = { - eventName: 'Project unlisted', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_OWNER, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -414,7 +415,7 @@ function sendNotificationTestCases() { it('should create *Project unlisted* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project unlisted', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_OWNER, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -438,59 +439,9 @@ function sendNotificationTestCases() { assert.equal(e.response.data.description, '"projectTitle" is required'); } }); - - it('should create *Project unlisted - Donors* notification, success, segment is off', async () => { - const data = { - eventName: 'Project unlisted - Donors', - sendEmail: false, - sendSegment: false, - userWalletAddress: generateRandomEthereumAddress(), - metadata: { - projectTitle, - projectLink, - }, - }; - - const result = await axios.post(sendNotificationUrl, data, { - headers: { - authorization: getGivethIoBasicAuth(), - }, - }); - assert.equal(result.status, 200); - assert.isOk(result.data); - assert.isTrue(result.data.success); - }); - it('should create *Project unlisted - Donors* notification, failed invalid metadata, segment is off', async () => { - try { - const data = { - eventName: 'Project unlisted - Donors', - sendEmail: false, - sendSegment: false, - userWalletAddress: generateRandomEthereumAddress(), - metadata: { - projectLink, - }, - }; - - await axios.post(sendNotificationUrl, data, { - headers: { - authorization: getGivethIoBasicAuth(), - }, - }); - // If request doesn't fail, it means this test failed - assert.isTrue(false); - } catch (e: any) { - assert.equal( - e.response.data.message, - errorMessagesEnum.IMPACT_GRAPH_VALIDATION_ERROR.message, - ); - assert.equal(e.response.data.description, '"projectTitle" is required'); - } - }); - - it('should create *Project unlisted - Users Who Liked* notification, success, segment is off', async () => { + it('should create *Project unlisted - Users who supported* notification, success, segment is off', async () => { const data = { - eventName: 'Project unlisted - Users Who Liked', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -509,10 +460,10 @@ function sendNotificationTestCases() { assert.isOk(result.data); assert.isTrue(result.data.success); }); - it('should create *Project unlisted - Users Who Liked* notification, failed invalid metadata, segment is off', async () => { + it('should create *Project unlisted - Users who supported* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project unlisted - Users Who Liked', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), diff --git a/src/types/general.ts b/src/types/general.ts index dcc47ae..fd7b97f 100644 --- a/src/types/general.ts +++ b/src/types/general.ts @@ -11,3 +11,19 @@ export enum NOTIFICATION_CATEGORY { GIV_ECONOMY = 'givEconomy', GIV_POWER = 'givPower', } + +export enum NOTIFICATION_TYPE_NAMES { + PROJECT_UNLISTED_SUPPORTED='Project unlisted - Users who supported', + PROJECT_UNLISTED_OWNER='Project unlisted', + PROJECT_LISTED_OWNER='Project listed', + DRAFT_PUBLISHED_OWNER='Draft published', + DRAFT_PROJECT_HAS_BEEN_SAVED_OWNER='The project saved as draft', + EMAIL_NOTIFICATION='Email notifications', + DAPP_NOTIFICATIONS='Dapp notifications', + PROFILE_HAS_BEEN_COMPLETED='The profile has been completed', + INCOMPLETE_PROFILE='Incomplete profile', + WELCOME='Welcome', + ADMIN_MESSAGE='Admin message', + PROJECT_BOOSTED_OWNER='Project boosted' + +} From a43b1b60bec0fb0ac671c7efb3700a05bf31081e Mon Sep 17 00:00:00 2001 From: Mohammad Ranjbar Z Date: Sun, 22 Jan 2023 14:15:38 +0330 Subject: [PATCH 3/4] Fix cancelled and listed notification for users who support the project related to https://github.com/Giveth/impact-graph/issues/809 --- .../1660716115917-seedNotificationType.ts | 84 +++++++++---------- src/routes/v1/notificationRouter.test.ts | 26 +++--- src/types/general.ts | 5 +- 3 files changed, 59 insertions(+), 56 deletions(-) diff --git a/migrations/1660716115917-seedNotificationType.ts b/migrations/1660716115917-seedNotificationType.ts index a1889da..31b2d22 100644 --- a/migrations/1660716115917-seedNotificationType.ts +++ b/migrations/1660716115917-seedNotificationType.ts @@ -218,6 +218,42 @@ export const GivethNotificationTypes = { ], content: 'Nice! Your {project name} project is listed.', }, + PROJECT_LISTED_FOR_SUPPORTERS: { + name: NOTIFICATION_TYPE_NAMES.PROJECT_LISTED_SUPPORTED, + description: 'Project has been listed!', + microService: MICRO_SERVICES.givethio, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + icon: 'Iconlisted', + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_LISTED, + emailNotifierService: null, + emailNotificationId: null, + pushNotifierService: null, + title: 'Project is listed', + htmlTemplate: [ + { + type: 'p', + content: 'The ', + }, + { + type: 'a', + content: '$projectTitle', + href: '$projectLink', + }, + { + type: 'p', + content: ' that you are supporting is visible now.', + }, + { + type: 'br', + }, + { + type: 'p', + content: '$reason', + }, + ], + content: + 'The {project name} that you are supporting is visible now', + }, PROJECT_UNLISTED: { name: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_OWNER, description: 'Project has been unlisted!', @@ -247,7 +283,7 @@ export const GivethNotificationTypes = { ], content: 'Your {project name} project is no longer visible.', }, - PROJECT_UNLISTED_FOR_DONORS: { + PROJECT_UNLISTED_FOR_SUPPORTERS: { name: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_SUPPORTED, description: 'Project has been unlisted!', microService: MICRO_SERVICES.givethio, @@ -307,7 +343,7 @@ export const GivethNotificationTypes = { content: 'Someone boosted your project {projectName}!', }, PROJECT_CANCELLED: { - name: 'Project cancelled', + name: NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_OWNER, description: 'Project has been cancelled', microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.PROJECT_RELATED, @@ -343,44 +379,8 @@ export const GivethNotificationTypes = { content: 'The {project name} project has been cancelled by admin action.\n{reason}', }, - PROJECT_CANCELLED_FOR_DONORS: { - name: 'Project cancelled - Donors', - description: 'Project has been cancelled', - microService: MICRO_SERVICES.givethio, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - icon: 'IconDeactivated', - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_CANCELLED, - emailNotifierService: null, - emailNotificationId: null, - pushNotifierService: null, - title: 'Project is cancelled by admin', - htmlTemplate: [ - { - type: 'p', - content: 'The ', - }, - { - type: 'a', - content: '$projectTitle', - href: '$projectLink', - }, - { - type: 'p', - content: ' project that you donated before has been cancelled', - }, - { - type: 'br', - }, - { - type: 'p', - content: '$reason', - }, - ], - content: - 'The {project name} project that you donated before has been cancelled.\n{reason}', - }, - PROJECT_CANCELLED_FOR_USERS_WHO_LIKED: { - name: 'Project cancelled - Users Who Liked', + PROJECT_CANCELLED_FOR_SUPPORTERS: { + name: NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_SUPPORTED, description: 'Project has been cancelled', microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.PROJECT_RELATED, @@ -403,7 +403,7 @@ export const GivethNotificationTypes = { }, { type: 'p', - content: ' project that you liked has been cancelled.', + content: ' project that you are supporting has been cancelled.', }, { type: 'br', @@ -414,7 +414,7 @@ export const GivethNotificationTypes = { }, ], content: - 'The {project name} project that you liked has been cancelled.\n{reason}', + 'The {project name} project that you are supporting has been cancelled.\n{reason}', }, PROJECT_ACTIVATED: { diff --git a/src/routes/v1/notificationRouter.test.ts b/src/routes/v1/notificationRouter.test.ts index c40065b..da40406 100644 --- a/src/routes/v1/notificationRouter.test.ts +++ b/src/routes/v1/notificationRouter.test.ts @@ -488,9 +488,10 @@ function sendNotificationTestCases() { } }); - it('should create *Project cancelled* notification, success, segment is off', async () => { + + it('should create *Project listed - Users who supported* notification, success, segment is off', async () => { const data = { - eventName: 'Project cancelled', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_LISTED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -509,10 +510,10 @@ function sendNotificationTestCases() { assert.isOk(result.data); assert.isTrue(result.data.success); }); - it('should create *Project cancelled* notification, failed invalid metadata, segment is off', async () => { + it('should create *Project listed - Users who supported* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project cancelled', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_LISTED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -537,9 +538,9 @@ function sendNotificationTestCases() { } }); - it('should create *Project cancelled - Donors* notification, success, segment is off', async () => { + it('should create *Project cancelled* notification, success, segment is off', async () => { const data = { - eventName: 'Project cancelled - Donors', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_OWNER, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -558,10 +559,10 @@ function sendNotificationTestCases() { assert.isOk(result.data); assert.isTrue(result.data.success); }); - it('should create *Project cancelled - Donors* notification, failed invalid metadata, segment is off', async () => { + it('should create *Project cancelled* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project cancelled - Donors', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_OWNER, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -585,10 +586,9 @@ function sendNotificationTestCases() { assert.equal(e.response.data.description, '"projectTitle" is required'); } }); - - it('should create *Project cancelled - Users Who Liked* notification, success, segment is off', async () => { + it('should create *Project cancelled - Users who supported* notification, success, segment is off', async () => { const data = { - eventName: 'Project cancelled - Users Who Liked', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -607,10 +607,10 @@ function sendNotificationTestCases() { assert.isOk(result.data); assert.isTrue(result.data.success); }); - it('should create *Project cancelled - Users Who Liked* notification, failed invalid metadata, segment is off', async () => { + it('should create *Project cancelled - Users who supported* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project cancelled - Users Who Liked', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), diff --git a/src/types/general.ts b/src/types/general.ts index fd7b97f..21bd71e 100644 --- a/src/types/general.ts +++ b/src/types/general.ts @@ -14,6 +14,7 @@ export enum NOTIFICATION_CATEGORY { export enum NOTIFICATION_TYPE_NAMES { PROJECT_UNLISTED_SUPPORTED='Project unlisted - Users who supported', + PROJECT_LISTED_SUPPORTED='Project listed - Users who supported', PROJECT_UNLISTED_OWNER='Project unlisted', PROJECT_LISTED_OWNER='Project listed', DRAFT_PUBLISHED_OWNER='Draft published', @@ -24,6 +25,8 @@ export enum NOTIFICATION_TYPE_NAMES { INCOMPLETE_PROFILE='Incomplete profile', WELCOME='Welcome', ADMIN_MESSAGE='Admin message', - PROJECT_BOOSTED_OWNER='Project boosted' + PROJECT_BOOSTED_OWNER='Project boosted', + PROJECT_CANCELLED_OWNER='Project cancelled', + PROJECT_CANCELLED_SUPPORTED='Project cancelled - Users who supported', } From f3ab14fe7699b2c8ec5fee7b8d3db6d9a5a7d78e Mon Sep 17 00:00:00 2001 From: Mohammad Ranjbar Z Date: Mon, 23 Jan 2023 17:14:15 +0330 Subject: [PATCH 4/4] Fix activated, deactivated, verified, unverified notification for users who support the project related to https://github.com/Giveth/impact-graph/issues/809 --- .../1660716115917-seedNotificationType.ts | 136 ++----------- src/entities/notificationType.ts | 2 +- src/routes/v1/notificationRouter.test.ts | 188 ++---------------- .../segment/segmentAnalyticsSingleton.ts | 2 +- src/types/general.ts | 8 + .../segmentAndMetadataValidators.ts | 2 +- 6 files changed, 51 insertions(+), 287 deletions(-) diff --git a/migrations/1660716115917-seedNotificationType.ts b/migrations/1660716115917-seedNotificationType.ts index 31b2d22..82b50a9 100644 --- a/migrations/1660716115917-seedNotificationType.ts +++ b/migrations/1660716115917-seedNotificationType.ts @@ -418,7 +418,7 @@ export const GivethNotificationTypes = { }, PROJECT_ACTIVATED: { - name: 'Project activated', + name: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_OWNER, description: 'Project has been activated!', microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.PROJECT_RELATED, @@ -446,38 +446,8 @@ export const GivethNotificationTypes = { ], content: 'The {project name} project is active now.', }, - - PROJECT_ACTIVATED_FOR_DONORS: { - name: 'Project activated - Donors', - description: 'Project has been activated!', - microService: MICRO_SERVICES.givethio, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - icon: 'IconActivated', - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_ACTIVATED, - emailNotifierService: null, - emailNotificationId: null, - pushNotifierService: null, - title: 'Project is activated', - htmlTemplate: [ - { - type: 'p', - content: 'The ', - }, - { - type: 'a', - content: '$projectTitle', - href: '$projectLink', - }, - { - type: 'p', - content: ' project that you donated before is active now.', - }, - ], - content: - 'The {project name} project that you donated before is active now.', - }, - PROJECT_ACTIVATED_FOR_USERS_WHO_LIKED: { - name: 'Project activated - Users Who Liked', + PROJECT_ACTIVATED_FOR_SUPPORTERS: { + name: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_SUPPORTED, description: 'Project has been activated!', microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.PROJECT_RELATED, @@ -500,14 +470,14 @@ export const GivethNotificationTypes = { }, { type: 'p', - content: ' project that you liked is active now.', + content: ' project that you are supporting is active now.', }, ], - content: 'The {project name} project that you liked is active now.', + content: 'The {project name} project that you are supporting is active now.', }, PROJECT_DEACTIVATED: { - name: 'Project deactivated', + name: NOTIFICATION_TYPE_NAMES.PROJECT_DEACTIVATED_OWNER, description: 'Project has been deactivated', microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.PROJECT_RELATED, @@ -535,50 +505,13 @@ export const GivethNotificationTypes = { ], content: 'The {project name} project is de-actived.', }, - PROJECT_DEACTIVATED_DONORS: { - name: 'Project deactivated - Donors', - description: 'Project has been deactivated', - microService: MICRO_SERVICES.givethio, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - icon: 'IconDeactivated', - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_DEACTIVATED, - emailNotifierService: null, - emailNotificationId: null, - pushNotifierService: null, - title: 'Project is deactivated', - htmlTemplate: [ - { - type: 'p', - content: 'The ', - }, - { - type: 'a', - content: '$projectTitle', - href: '$projectLink', - }, - { - type: 'p', - content: ' project that you donated before is de-actived.', - }, - { - type: 'br', - }, - { - type: 'p', - content: '$reason', - }, - ], - content: - 'The {project name} project that you donated before is de-actived.\n{reason}', - }, - PROJECT_DEACTIVATED_USERS_WHO_LIKED: { - name: 'Project deactivated - Users Who Liked', + PROJECT_DEACTIVATED_SUPPORTERS: { + name: NOTIFICATION_TYPE_NAMES.PROJECT_DEACTIVATED_SUPPORTED, description: 'Project has been deactivated', microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.PROJECT_RELATED, icon: 'IconDeactivated', schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_DEACTIVATED, - categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPPORTED_BY_YOU_PROJECT_GROUP, emailNotifierService: null, emailNotificationId: null, pushNotifierService: null, @@ -595,7 +528,7 @@ export const GivethNotificationTypes = { }, { type: 'p', - content: ' project that you liked is de-actived', + content: ' project that you are supporting is de-actived.', }, { type: 'br', @@ -606,10 +539,10 @@ export const GivethNotificationTypes = { }, ], content: - 'The {project name} project that you liked is de-actived.\n{reason}', + 'The {project name} project that you are supporting is de-actived.\n{reason}', }, PROJECT_VERIFIED: { - name: 'Project verified', + name: NOTIFICATION_TYPE_NAMES.PROJECT_VERIFIED_OWNER, description: 'Project has been verified!', microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.PROJECT_RELATED, @@ -636,8 +569,8 @@ export const GivethNotificationTypes = { ], content: 'Well done! {project name} project is officially verified! 🎉', }, - PROJECT_VERIFIED_DONORS: { - name: 'Project verified - Donors', + PROJECT_VERIFIED_SUPPORTERS: { + name: NOTIFICATION_TYPE_NAMES.PROJECT_VERIFIED_SUPPORTED, description: 'Project has been verified!', microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.PROJECT_RELATED, @@ -659,40 +592,11 @@ export const GivethNotificationTypes = { }, { type: 'p', - content: ' that you donated before has received verified badge!', + content: ' that you are supporting has received verified badge!', }, ], content: - 'The {project name} that you donated before has received verified badge!', - }, - PROJECT_VERIFIED_USERS_WHO_LIKED: { - name: 'Project verified - Users Who Liked', - description: 'Project has been verified!', - microService: MICRO_SERVICES.givethio, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - icon: 'IconVerifiedBadge', - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_VERIFIED, - categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPPORTED_BY_YOU_PROJECT_GROUP, - emailNotifierService: null, - emailNotificationId: null, - pushNotifierService: null, - title: 'Project verified', - htmlTemplate: [ - { - type: 'p', - content: 'The ', - }, - { - type: 'a', - content: '$projectTitle', - href: '$projectLink', - }, - { - type: 'p', - content: ' that you liked has received verified badge!', - }, - ], - content: 'The {project name} that you liked has received verified badge!', + 'The {project name} that you are supporting has received verified badge!', }, VERIFICATION_FORM_SENT: { name: 'Form sent (Under review)', @@ -1142,7 +1046,7 @@ export const GivethNotificationTypes = { content: 'You project {project name} would lose verification badge soon', }, PROJECT_UNVERIFIED: { - name: 'Project unverified', + name: NOTIFICATION_TYPE_NAMES.PROJECT_UNVERIFIED_OWNER, description: 'Project has been unverified', microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.PROJECT_RELATED, @@ -1169,14 +1073,14 @@ export const GivethNotificationTypes = { ], content: 'You project {project name} is not verified anymore', }, - PROJECT_UNVERIFIED_WHO_BOOSTED: { - name: 'Project unverified - Users Who Boosted', + PROJECT_UNVERIFIED_SUPPORTERS: { + name: NOTIFICATION_TYPE_NAMES.PROJECT_UNVERIFIED_SUPPORTED, microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.PROJECT_RELATED, icon: '', - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UNVERIFIED_WHO_BOOSTED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UNVERIFIED_WHO_SUPPORTED, emailNotifierService: THIRD_PARTY_EMAIL_SERVICES.SEGMENT, - emailNotificationId: SegmentEvents.PROJECT_UNVERIFIED_USERS_WHO_BOOSTED, + emailNotificationId: SegmentEvents.PROJECT_UNVERIFIED_USERS_WHO_SUPPORTED, pushNotifierService: null, title: 'Project unverified - Users Who Boosted', description: 'Project unverified - Users Who Boosted', diff --git a/src/entities/notificationType.ts b/src/entities/notificationType.ts index 425ec90..b92ef67 100644 --- a/src/entities/notificationType.ts +++ b/src/entities/notificationType.ts @@ -31,7 +31,7 @@ export const SCHEMA_VALIDATORS_NAMES = { PROJECT_BADGE_UP_FOR_REVOKING: 'projectBadgeUpForRevoking', PROJECT_VERIFIED: 'projectVerified', PROJECT_UNVERIFIED: 'projectUnverified', - PROJECT_UNVERIFIED_WHO_BOOSTED: 'projectUnverifiedWhoBoosted', + PROJECT_UNVERIFIED_WHO_SUPPORTED: 'projectUnverifiedWhoSupported', PROJECT_ACTIVATED: 'projectActivated', PROJECT_DEACTIVATED: 'projectDeactivated', PROJECT_CANCELLED: 'projectCancelled', diff --git a/src/routes/v1/notificationRouter.test.ts b/src/routes/v1/notificationRouter.test.ts index da40406..c8a4fae 100644 --- a/src/routes/v1/notificationRouter.test.ts +++ b/src/routes/v1/notificationRouter.test.ts @@ -637,7 +637,7 @@ function sendNotificationTestCases() { it('should create *Project activated* notification, success, segment is off', async () => { const data = { - eventName: 'Project activated', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_OWNER, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -659,7 +659,7 @@ function sendNotificationTestCases() { it('should create *Project activated* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project activated', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_OWNER, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -684,9 +684,9 @@ function sendNotificationTestCases() { } }); - it('should create *Project activated - Donors* notification, success, segment is off', async () => { + it('should create *Project activated - Users who supported* notification, success, segment is off', async () => { const data = { - eventName: 'Project activated - Donors', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -705,59 +705,10 @@ function sendNotificationTestCases() { assert.isOk(result.data); assert.isTrue(result.data.success); }); - it('should create *Project activated - Donors* notification, failed invalid metadata, segment is off', async () => { + it('should create *Project activated - Users who supported* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project activated - Donors', - sendEmail: false, - sendSegment: false, - userWalletAddress: generateRandomEthereumAddress(), - metadata: { - projectLink, - }, - }; - - await axios.post(sendNotificationUrl, data, { - headers: { - authorization: getGivethIoBasicAuth(), - }, - }); - // If request doesn't fail, it means this test failed - assert.isTrue(false); - } catch (e: any) { - assert.equal( - e.response.data.message, - errorMessagesEnum.IMPACT_GRAPH_VALIDATION_ERROR.message, - ); - assert.equal(e.response.data.description, '"projectTitle" is required'); - } - }); - - it('should create *Project activated - Users Who Liked* notification, success, segment is off', async () => { - const data = { - eventName: 'Project activated - Users Who Liked', - sendEmail: false, - sendSegment: false, - userWalletAddress: generateRandomEthereumAddress(), - metadata: { - projectTitle, - projectLink, - }, - }; - - const result = await axios.post(sendNotificationUrl, data, { - headers: { - authorization: getGivethIoBasicAuth(), - }, - }); - assert.equal(result.status, 200); - assert.isOk(result.data); - assert.isTrue(result.data.success); - }); - it('should create *Project activated - Users Who Liked* notification, failed invalid metadata, segment is off', async () => { - try { - const data = { - eventName: 'Project activated - Users Who Liked', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -784,7 +735,7 @@ function sendNotificationTestCases() { it('should create *Project deactivated* notification, success, segment is off', async () => { const data = { - eventName: 'Project deactivated', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_DEACTIVATED_OWNER, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -807,57 +758,7 @@ function sendNotificationTestCases() { it('should create *Project deactivated* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project deactivated', - sendEmail: false, - sendSegment: false, - userWalletAddress: generateRandomEthereumAddress(), - metadata: { - projectLink, - }, - }; - - await axios.post(sendNotificationUrl, data, { - headers: { - authorization: getGivethIoBasicAuth(), - }, - }); - // If request doesn't fail, it means this test failed - assert.isTrue(false); - } catch (e: any) { - assert.equal( - e.response.data.message, - errorMessagesEnum.IMPACT_GRAPH_VALIDATION_ERROR.message, - ); - assert.equal(e.response.data.description, '"projectTitle" is required'); - } - }); - - it('should create *Project deactivated - Donors* notification, success, segment is off', async () => { - const data = { - eventName: 'Project deactivated - Donors', - sendEmail: false, - sendSegment: false, - userWalletAddress: generateRandomEthereumAddress(), - metadata: { - projectTitle, - projectLink, - reason: 'hi', - }, - }; - - const result = await axios.post(sendNotificationUrl, data, { - headers: { - authorization: getGivethIoBasicAuth(), - }, - }); - assert.equal(result.status, 200); - assert.isOk(result.data); - assert.isTrue(result.data.success); - }); - it('should create *Project deactivated - Donors* notification, failed invalid metadata, segment is off', async () => { - try { - const data = { - eventName: 'Project deactivated - Donors', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_DEACTIVATED_OWNER, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -882,9 +783,9 @@ function sendNotificationTestCases() { } }); - it('should create *Project deactivated - Users Who Liked* notification, success, segment is off', async () => { + it('should create *Project deactivated - Users who supported* notification, success, segment is off', async () => { const data = { - eventName: 'Project deactivated - Users Who Liked', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_DEACTIVATED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -904,10 +805,10 @@ function sendNotificationTestCases() { assert.isOk(result.data); assert.isTrue(result.data.success); }); - it('should create *Project deactivated - Users Who Liked* notification, failed invalid metadata, segment is off', async () => { + it('should create *Project deactivated - Users who supported* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project deactivated - Users Who Liked', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_DEACTIVATED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -934,7 +835,7 @@ function sendNotificationTestCases() { it('should create *Project verified* notification, success, segment is off', async () => { const data = { - eventName: 'Project verified', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_VERIFIED_OWNER, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -956,56 +857,7 @@ function sendNotificationTestCases() { it('should create *Project verified* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project verified', - sendEmail: false, - sendSegment: false, - userWalletAddress: generateRandomEthereumAddress(), - metadata: { - projectLink, - }, - }; - - await axios.post(sendNotificationUrl, data, { - headers: { - authorization: getGivethIoBasicAuth(), - }, - }); - // If request doesn't fail, it means this test failed - assert.isTrue(false); - } catch (e: any) { - assert.equal( - e.response.data.message, - errorMessagesEnum.IMPACT_GRAPH_VALIDATION_ERROR.message, - ); - assert.equal(e.response.data.description, '"projectTitle" is required'); - } - }); - - it('should create *Project verified - Donors* notification, success, segment is off', async () => { - const data = { - eventName: 'Project verified - Donors', - sendEmail: false, - sendSegment: false, - userWalletAddress: generateRandomEthereumAddress(), - metadata: { - projectTitle, - projectLink, - }, - }; - - const result = await axios.post(sendNotificationUrl, data, { - headers: { - authorization: getGivethIoBasicAuth(), - }, - }); - assert.equal(result.status, 200); - assert.isOk(result.data); - assert.isTrue(result.data.success); - }); - it('should create *Project verified - Donors* notification, failed invalid metadata, segment is off', async () => { - try { - const data = { - eventName: 'Project verified - Donors', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_VERIFIED_OWNER, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -1030,9 +882,9 @@ function sendNotificationTestCases() { } }); - it('should create *Project verified - Users Who Liked* notification, success, segment is off', async () => { + it('should create *Project verified - Users who supported* notification, success, segment is off', async () => { const data = { - eventName: 'Project verified - Users Who Liked', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_VERIFIED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -1051,10 +903,10 @@ function sendNotificationTestCases() { assert.isOk(result.data); assert.isTrue(result.data.success); }); - it('should create *Project verified - Users Who Liked* notification, failed invalid metadata, segment is off', async () => { + it('should create *Project verified - Users who supported* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project verified - Users Who Liked', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_VERIFIED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -1581,7 +1433,7 @@ function sendNotificationTestCases() { it('should create *Project unverified* notification, success, segment is off', async () => { const data = { - eventName: 'Project unverified', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_UNVERIFIED_OWNER, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -1603,7 +1455,7 @@ function sendNotificationTestCases() { it('should create *Project unverified* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project unverified', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_UNVERIFIED_OWNER, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), diff --git a/src/services/segment/segmentAnalyticsSingleton.ts b/src/services/segment/segmentAnalyticsSingleton.ts index d0ab2c8..b1a8ba9 100644 --- a/src/services/segment/segmentAnalyticsSingleton.ts +++ b/src/services/segment/segmentAnalyticsSingleton.ts @@ -24,7 +24,7 @@ export enum SegmentEvents { PROJECT_VERIFIED = 'Project verified', PROJECT_REJECTED = 'Project rejected', PROJECT_UNVERIFIED = 'Project unverified', - PROJECT_UNVERIFIED_USERS_WHO_BOOSTED = 'Project unverified - Users Who Boosted', + PROJECT_UNVERIFIED_USERS_WHO_SUPPORTED = 'Project unverified - Users who supported', PROJECT_ACTIVATED = 'Project activated', PROJECT_DEACTIVATED = 'Project deactivated', PROJECT_CANCELLED = 'Project cancelled', diff --git a/src/types/general.ts b/src/types/general.ts index 21bd71e..f0f9181 100644 --- a/src/types/general.ts +++ b/src/types/general.ts @@ -28,5 +28,13 @@ export enum NOTIFICATION_TYPE_NAMES { PROJECT_BOOSTED_OWNER='Project boosted', PROJECT_CANCELLED_OWNER='Project cancelled', PROJECT_CANCELLED_SUPPORTED='Project cancelled - Users who supported', + PROJECT_ACTIVATED_OWNER='Project activated', + PROJECT_ACTIVATED_SUPPORTED='Project activated - Users who supported', + PROJECT_DEACTIVATED_OWNER='Project deactivated', + PROJECT_DEACTIVATED_SUPPORTED='Project deactivated - Users who supported', + PROJECT_VERIFIED_OWNER='Project verified', + PROJECT_VERIFIED_SUPPORTED='Project verified - Users who supported', + PROJECT_UNVERIFIED_OWNER='Project unverified', + PROJECT_UNVERIFIED_SUPPORTED='Project unverified - Users who supported', } diff --git a/src/utils/validators/segmentAndMetadataValidators.ts b/src/utils/validators/segmentAndMetadataValidators.ts index 343767e..42486f3 100644 --- a/src/utils/validators/segmentAndMetadataValidators.ts +++ b/src/utils/validators/segmentAndMetadataValidators.ts @@ -180,7 +180,7 @@ export const SEGMENT_METADATA_SCHEMA_VALIDATOR: { metadata: projectTitleProjectLinkSchema, segment: projectRelatedTrackerSchema, }, - projectUnverifiedWhoBoosted: { + projectUnverifiedWhoSupported: { metadata: projectTitleProjectLinkSchema, segment: null, },