diff --git a/migrations/1660716115917-seedNotificationType.ts b/migrations/1660716115917-seedNotificationType.ts index fd80bf3..82b50a9 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', @@ -218,22 +218,21 @@ export const GivethNotificationTypes = { ], content: 'Nice! Your {project name} project is listed.', }, - PROJECT_UNLISTED: { - name: 'Project unlisted', - description: 'Project has been unlisted!', + 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: 'IconUnlisted', - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UNLISTED, - emailNotifierService: THIRD_PARTY_EMAIL_SERVICES.SEGMENT, - emailNotificationId: SegmentEvents.PROJECT_UNLISTED, + icon: 'Iconlisted', + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_LISTED, + emailNotifierService: null, + emailNotificationId: null, pushNotifierService: null, - categoryGroup: NOTIFICATION_CATEGORY_GROUPS.PROJECT_STATUS, - title: 'Project is unlisted', + title: 'Project is listed', htmlTemplate: [ { type: 'p', - content: 'Your ', + content: 'The ', }, { type: 'a', @@ -242,26 +241,35 @@ export const GivethNotificationTypes = { }, { type: 'p', - content: ' project is no longer visible.', + content: ' that you are supporting is visible now.', + }, + { + type: 'br', + }, + { + type: 'p', + content: '$reason', }, ], - content: 'Your {project name} project is no longer visible.', + content: + 'The {project name} that you are supporting is visible now', }, - PROJECT_UNLISTED_FOR_DONORS: { - name: 'Project unlisted - Donors', + PROJECT_UNLISTED: { + name: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_OWNER, description: 'Project has been unlisted!', microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.PROJECT_RELATED, icon: 'IconUnlisted', schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UNLISTED, - emailNotifierService: null, - emailNotificationId: null, + emailNotifierService: THIRD_PARTY_EMAIL_SERVICES.SEGMENT, + emailNotificationId: SegmentEvents.PROJECT_UNLISTED, pushNotifierService: null, + categoryGroup: NOTIFICATION_CATEGORY_GROUPS.PROJECT_STATUS, title: 'Project is unlisted', htmlTemplate: [ { type: 'p', - content: 'The ', + content: 'Your ', }, { type: 'a', @@ -270,27 +278,18 @@ export const GivethNotificationTypes = { }, { type: 'p', - content: ' that you donated before is no longer visible.', - }, - { - type: 'br', - }, - { - type: 'p', - content: '$reason', + content: ' project is no longer visible.', }, ], - content: - 'The {project name} that you donated before is no longer visible.\n{reason}', + content: 'Your {project name} project is no longer visible.', }, - PROJECT_UNLISTED_FOR_USERS_WHO_LIKED: { - name: 'Project unlisted - Users Who Liked', + PROJECT_UNLISTED_FOR_SUPPORTERS: { + name: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_SUPPORTED, 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.LIKED_BY_YOU_PROJECT_GROUP, emailNotifierService: null, emailNotificationId: null, pushNotifierService: null, @@ -307,7 +306,7 @@ export const GivethNotificationTypes = { }, { type: 'p', - content: ' that you liked is no longer visible.', + content: ' that you are supporting is no longer visible.', }, { type: 'br', @@ -318,10 +317,10 @@ export const GivethNotificationTypes = { }, ], 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, @@ -344,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, @@ -380,13 +379,14 @@ export const GivethNotificationTypes = { content: 'The {project name} project has been cancelled by admin action.\n{reason}', }, - PROJECT_CANCELLED_FOR_DONORS: { - name: 'Project cancelled - Donors', + 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, icon: 'IconDeactivated', schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_CANCELLED, + categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPPORTED_BY_YOU_PROJECT_GROUP, emailNotifierService: null, emailNotificationId: null, pushNotifierService: null, @@ -403,7 +403,7 @@ export const GivethNotificationTypes = { }, { type: 'p', - content: ' project that you donated before has been cancelled', + content: ' project that you are supporting has been cancelled.', }, { type: 'br', @@ -414,48 +414,11 @@ export const GivethNotificationTypes = { }, ], 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', - description: 'Project has been cancelled', - microService: MICRO_SERVICES.givethio, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - icon: 'IconDeactivated', - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_CANCELLED, - categoryGroup: NOTIFICATION_CATEGORY_GROUPS.LIKED_BY_YOU_PROJECT_GROUP, - 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 liked has been cancelled.', - }, - { - type: 'br', - }, - { - type: 'p', - content: '$reason', - }, - ], - 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: { - name: 'Project activated', + name: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_OWNER, description: 'Project has been activated!', microService: MICRO_SERVICES.givethio, category: NOTIFICATION_CATEGORY.PROJECT_RELATED, @@ -483,44 +446,14 @@ 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, 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, @@ -537,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, @@ -572,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.LIKED_BY_YOU_PROJECT_GROUP, emailNotifierService: null, emailNotificationId: null, pushNotifierService: null, @@ -632,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', @@ -643,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, @@ -673,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, @@ -696,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.LIKED_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)', @@ -1179,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, @@ -1206,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', @@ -1358,58 +1225,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 +1235,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 +1245,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 +1304,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 +1325,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 +1696,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..b92ef67 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', @@ -30,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', @@ -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..c8a4fae 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,10 +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 () => { + it('should create *Project unlisted - Users who supported* notification, success, segment is off', async () => { const data = { - eventName: 'Project unlisted - Donors', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -460,10 +460,10 @@ function sendNotificationTestCases() { assert.isOk(result.data); assert.isTrue(result.data.success); }); - it('should create *Project unlisted - Donors* 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 - Donors', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -488,9 +488,10 @@ function sendNotificationTestCases() { } }); - it('should create *Project unlisted - Users Who Liked* notification, success, segment is off', async () => { + + it('should create *Project listed - Users who supported* notification, success, segment is off', async () => { const data = { - eventName: 'Project unlisted - Users Who Liked', + 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 unlisted - Users Who Liked* 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 unlisted - Users Who Liked', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_LISTED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -539,7 +540,7 @@ function sendNotificationTestCases() { it('should create *Project cancelled* notification, success, segment is off', async () => { const data = { - eventName: 'Project cancelled', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_OWNER, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -561,56 +562,7 @@ function sendNotificationTestCases() { it('should create *Project cancelled* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project cancelled', - 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 cancelled - Donors* notification, success, segment is off', async () => { - const data = { - eventName: 'Project cancelled - 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 cancelled - Donors* 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(), @@ -634,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(), @@ -656,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(), @@ -686,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(), @@ -708,56 +659,7 @@ function sendNotificationTestCases() { it('should create *Project activated* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project activated', - 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 - Donors* notification, success, segment is off', async () => { - const data = { - eventName: 'Project activated - 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 activated - Donors* notification, failed invalid metadata, segment is off', async () => { - try { - const data = { - eventName: 'Project activated - Donors', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_OWNER, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -782,9 +684,9 @@ function sendNotificationTestCases() { } }); - it('should create *Project activated - Users Who Liked* 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 - Users Who Liked', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -803,10 +705,10 @@ function sendNotificationTestCases() { 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 () => { + it('should create *Project activated - Users who supported* 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(), @@ -833,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(), @@ -856,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(), @@ -931,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(), @@ -953,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(), @@ -983,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(), @@ -1005,7 +857,7 @@ function sendNotificationTestCases() { it('should create *Project verified* notification, failed invalid metadata, segment is off', async () => { try { const data = { - eventName: 'Project verified', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_VERIFIED_OWNER, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -1030,9 +882,9 @@ function sendNotificationTestCases() { } }); - it('should create *Project verified - Donors* 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 - Donors', + eventName: NOTIFICATION_TYPE_NAMES.PROJECT_VERIFIED_SUPPORTED, sendEmail: false, sendSegment: false, userWalletAddress: generateRandomEthereumAddress(), @@ -1051,59 +903,10 @@ function sendNotificationTestCases() { assert.isOk(result.data); assert.isTrue(result.data.success); }); - it('should create *Project verified - Donors* 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 - 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 verified - Users Who Liked* notification, success, segment is off', async () => { - const data = { - eventName: 'Project verified - 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 verified - Users Who Liked* 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(), @@ -1630,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(), @@ -1652,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(), @@ -1871,55 +1674,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 +1723,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 +1744,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 +1772,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 +1793,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..b1a8ba9 100644 --- a/src/services/segment/segmentAnalyticsSingleton.ts +++ b/src/services/segment/segmentAnalyticsSingleton.ts @@ -23,20 +23,14 @@ 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_UNVERIFIED_USERS_WHO_SUPPORTED = 'Project unverified - Users who supported', PROJECT_ACTIVATED = 'Project activated', PROJECT_DEACTIVATED = 'Project deactivated', 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/types/general.ts b/src/types/general.ts index dcc47ae..f0f9181 100644 --- a/src/types/general.ts +++ b/src/types/general.ts @@ -11,3 +11,30 @@ export enum NOTIFICATION_CATEGORY { GIV_ECONOMY = 'givEconomy', GIV_POWER = 'givPower', } + +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', + 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', + 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 496bfd2..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, }, @@ -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, },