From a9cc4d9a78e8c1632a2c988ae84063b32395f752 Mon Sep 17 00:00:00 2001 From: ali ebrahimi Date: Tue, 13 Aug 2024 03:30:31 +0330 Subject: [PATCH 1/6] add migration for remove unique constraint for the notificationType names --- ...eUniqueConstraintOnNotificationTypeName.ts | 19 +++++++++++++++++++ src/entities/notificationType.ts | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 migrations/1723505195659-RemoveUniqueConstraintOnNotificationTypeName.ts diff --git a/migrations/1723505195659-RemoveUniqueConstraintOnNotificationTypeName.ts b/migrations/1723505195659-RemoveUniqueConstraintOnNotificationTypeName.ts new file mode 100644 index 0000000..43d755f --- /dev/null +++ b/migrations/1723505195659-RemoveUniqueConstraintOnNotificationTypeName.ts @@ -0,0 +1,19 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class RemoveUniqueConstraintOnNotificationTypeName1723505195659 + implements MigrationInterface +{ + public async up(queryRunner: QueryRunner): Promise { + // Dropping the unique constraint on the name column + await queryRunner.query( + `ALTER TABLE notification_type DROP CONSTRAINT IF EXISTS "UQ_notification_type_name";`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + // Re-adding the unique constraint if you need to roll back the migration + await queryRunner.query( + `ALTER TABLE notification_type ADD CONSTRAINT "UQ_notification_type_name" UNIQUE (name);`, + ); + } +} diff --git a/src/entities/notificationType.ts b/src/entities/notificationType.ts index a26fad5..066f420 100644 --- a/src/entities/notificationType.ts +++ b/src/entities/notificationType.ts @@ -110,7 +110,7 @@ export class NotificationType extends BaseEntity { categoryGroup?: string; @Index() - @Column('text', { nullable: false, unique: true }) + @Column('text', { nullable: false }) name: string; @Column('text', { nullable: false }) From daf697063f49482b89c20374b46fd42949e7ef1a Mon Sep 17 00:00:00 2001 From: ali ebrahimi Date: Tue, 13 Aug 2024 03:30:59 +0330 Subject: [PATCH 2/6] add migration for adding notification types for qacc microservice --- ...23505340806-addNotificationTypesForQacc.ts | 236 ++++++++++++++++++ src/utils/utils.ts | 1 + 2 files changed, 237 insertions(+) create mode 100644 migrations/1723505340806-addNotificationTypesForQacc.ts diff --git a/migrations/1723505340806-addNotificationTypesForQacc.ts b/migrations/1723505340806-addNotificationTypesForQacc.ts new file mode 100644 index 0000000..e7d347a --- /dev/null +++ b/migrations/1723505340806-addNotificationTypesForQacc.ts @@ -0,0 +1,236 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; +import { + NOTIFICATION_CATEGORY, + NOTIFICATION_TYPE_NAMES, +} from '../src/types/general'; +import { SCHEMA_VALIDATORS_NAMES } from '../src/entities/notificationType'; +import { MICRO_SERVICES } from '../src/utils/utils'; + +const QaccNotificationTypes = [ + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_SUPPORTED, + description: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_SUPPORTED, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UNVERIFIED_WHO_SUPPORTED, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_LISTED_SUPPORTED, + description: NOTIFICATION_TYPE_NAMES.PROJECT_LISTED_SUPPORTED, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_LISTED, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_OWNER, + description: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_OWNER, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UNLISTED, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_LISTED_OWNER, + description: NOTIFICATION_TYPE_NAMES.PROJECT_LISTED_OWNER, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_LISTED, + }, + { + name: NOTIFICATION_TYPE_NAMES.DRAFT_PUBLISHED_OWNER, + description: NOTIFICATION_TYPE_NAMES.DRAFT_PUBLISHED_OWNER, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.DRAFTED_PROJECT_ACTIVATED, + }, + { + name: NOTIFICATION_TYPE_NAMES.DRAFT_PROJECT_HAS_BEEN_SAVED_OWNER, + description: NOTIFICATION_TYPE_NAMES.DRAFT_PROJECT_HAS_BEEN_SAVED_OWNER, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.DRAFTED_PROJECT_SAVED, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_BOOSTED_OWNER, + description: NOTIFICATION_TYPE_NAMES.PROJECT_BOOSTED_OWNER, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_HAS_BEEN_BOOSTED, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_BOOSTED_BY_PROJECT_OWNER, + description: NOTIFICATION_TYPE_NAMES.PROJECT_BOOSTED_BY_PROJECT_OWNER, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.USER_BOOSTED, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_OWNER, + description: NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_OWNER, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_CANCELLED, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_SUPPORTED, + description: NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_SUPPORTED, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_CANCELLED, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_OWNER, + description: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_OWNER, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_ACTIVATED, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_SUPPORTED, + description: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_SUPPORTED, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_ACTIVATED, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_DEACTIVATED_OWNER, + description: NOTIFICATION_TYPE_NAMES.PROJECT_DEACTIVATED_OWNER, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_DEACTIVATED, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_DEACTIVATED_SUPPORTED, + description: NOTIFICATION_TYPE_NAMES.PROJECT_DEACTIVATED_SUPPORTED, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_DEACTIVATED, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_VERIFIED_OWNER, + description: NOTIFICATION_TYPE_NAMES.PROJECT_VERIFIED_OWNER, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_VERIFIED, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_VERIFIED_SUPPORTED, + description: NOTIFICATION_TYPE_NAMES.PROJECT_VERIFIED_SUPPORTED, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_VERIFIED, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_UNVERIFIED_OWNER, + description: NOTIFICATION_TYPE_NAMES.PROJECT_UNVERIFIED_OWNER, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UNVERIFIED, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_UNVERIFIED_SUPPORTED, + description: NOTIFICATION_TYPE_NAMES.PROJECT_UNVERIFIED_SUPPORTED, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UNVERIFIED_WHO_SUPPORTED, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_BADGE_REVOKE_REMINDER, + description: NOTIFICATION_TYPE_NAMES.PROJECT_BADGE_REVOKE_REMINDER, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_BADGE_REVOKE_REMINDER, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_BADGE_REVOKE_WARNING, + description: NOTIFICATION_TYPE_NAMES.PROJECT_BADGE_REVOKE_WARNING, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_BADGE_REVOKE_WARNING, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_BADGE_REVOKE_LAST_WARNING, + description: NOTIFICATION_TYPE_NAMES.PROJECT_BADGE_REVOKE_LAST_WARNING, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_BADGE_REVOKE_LAST_WARNING, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_BADGE_UP_FOR_REVOKING, + description: NOTIFICATION_TYPE_NAMES.PROJECT_BADGE_UP_FOR_REVOKING, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_BADGE_UP_FOR_REVOKING, + }, + { + name: NOTIFICATION_TYPE_NAMES.VERIFICATION_FORM_GOT_DRAFT_BY_ADMIN, + description: NOTIFICATION_TYPE_NAMES.VERIFICATION_FORM_GOT_DRAFT_BY_ADMIN, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: + SCHEMA_VALIDATORS_NAMES.VERIFICATION_FORM_GOT_DRAFT_BY_ADMIN, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_UPDATE_ADDED, + description: NOTIFICATION_TYPE_NAMES.PROJECT_UPDATE_ADDED, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UPDATED_ADDED_WHO_SUPPORTS, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_HAS_A_NEW_RANK, + description: NOTIFICATION_TYPE_NAMES.PROJECT_HAS_A_NEW_RANK, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_HAS_A_NEW_RANK, + }, + { + name: NOTIFICATION_TYPE_NAMES.PROJECT_HAS_RISEN_IN_THE_RANK, + description: NOTIFICATION_TYPE_NAMES.PROJECT_HAS_RISEN_IN_THE_RANK, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_HAS_RISEN_IN_THE_RANK, + }, + { + name: NOTIFICATION_TYPE_NAMES.YOUR_PROJECT_GOT_A_RANK, + description: NOTIFICATION_TYPE_NAMES.YOUR_PROJECT_GOT_A_RANK, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.PROJECT_RELATED, + schemaValidator: SCHEMA_VALIDATORS_NAMES.YOUR_PROJECT_GOT_A_RANK, + }, + { + name: NOTIFICATION_TYPE_NAMES.SUBSCRIBE_ONBOARDING, + description: NOTIFICATION_TYPE_NAMES.SUBSCRIBE_ONBOARDING, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.ORTTO, + schemaValidator: SCHEMA_VALIDATORS_NAMES.SUBSCRIBE_ONBOARDING, + }, + { + name: NOTIFICATION_TYPE_NAMES.CREATE_ORTTO_PROFILE, + description: NOTIFICATION_TYPE_NAMES.CREATE_ORTTO_PROFILE, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.ORTTO, + schemaValidator: SCHEMA_VALIDATORS_NAMES.CREATE_ORTTO_PROFILE, + }, + { + name: NOTIFICATION_TYPE_NAMES.NOTIFY_REWARD_AMOUNT, + description: NOTIFICATION_TYPE_NAMES.NOTIFY_REWARD_AMOUNT, + microService: MICRO_SERVICES.qacc, + category: NOTIFICATION_CATEGORY.ORTTO, + schemaValidator: SCHEMA_VALIDATORS_NAMES.NOTIFY_REWARD_AMOUNT, + }, +]; + +export class AddNotificationTypesForQacc1723505340806 + implements MigrationInterface +{ + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.manager.save('notification_type', QaccNotificationTypes); + } + + public async down(queryRunner: QueryRunner): Promise { + const names = QaccNotificationTypes.map(nt => nt.name); + await queryRunner.query( + `DELETE FROM notification_type WHERE name IN (${names.map(name => `'${name}'`).join(', ')}) AND "microService" = 'qacc';`, + ); + } +} diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 1d8c328..37d585d 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -20,6 +20,7 @@ export const MICRO_SERVICES = { givEconomyNotificationMicroService: 'giveconomy-notification-service', trace: 'trace', notifyReward: 'notifyreward', + qacc: 'qacc', }; // Need to define trace, blockchain and miscellaneos events From a62fe306f79baceeceb7140b1939da05704f29ef Mon Sep 17 00:00:00 2001 From: ali ebrahimi Date: Tue, 20 Aug 2024 04:53:14 +0330 Subject: [PATCH 3/6] add only donation received for qacc --- ...23505340806-addNotificationTypesForQacc.ts | 210 +----------------- src/entities/notificationType.ts | 1 + src/types/general.ts | 1 + 3 files changed, 5 insertions(+), 207 deletions(-) diff --git a/migrations/1723505340806-addNotificationTypesForQacc.ts b/migrations/1723505340806-addNotificationTypesForQacc.ts index e7d347a..5de67d8 100644 --- a/migrations/1723505340806-addNotificationTypesForQacc.ts +++ b/migrations/1723505340806-addNotificationTypesForQacc.ts @@ -8,215 +8,11 @@ import { MICRO_SERVICES } from '../src/utils/utils'; const QaccNotificationTypes = [ { - name: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_SUPPORTED, - description: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_SUPPORTED, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UNVERIFIED_WHO_SUPPORTED, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_LISTED_SUPPORTED, - description: NOTIFICATION_TYPE_NAMES.PROJECT_LISTED_SUPPORTED, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_LISTED, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_OWNER, - description: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_OWNER, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UNLISTED, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_LISTED_OWNER, - description: NOTIFICATION_TYPE_NAMES.PROJECT_LISTED_OWNER, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_LISTED, - }, - { - name: NOTIFICATION_TYPE_NAMES.DRAFT_PUBLISHED_OWNER, - description: NOTIFICATION_TYPE_NAMES.DRAFT_PUBLISHED_OWNER, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.DRAFTED_PROJECT_ACTIVATED, - }, - { - name: NOTIFICATION_TYPE_NAMES.DRAFT_PROJECT_HAS_BEEN_SAVED_OWNER, - description: NOTIFICATION_TYPE_NAMES.DRAFT_PROJECT_HAS_BEEN_SAVED_OWNER, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.DRAFTED_PROJECT_SAVED, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_BOOSTED_OWNER, - description: NOTIFICATION_TYPE_NAMES.PROJECT_BOOSTED_OWNER, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_HAS_BEEN_BOOSTED, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_BOOSTED_BY_PROJECT_OWNER, - description: NOTIFICATION_TYPE_NAMES.PROJECT_BOOSTED_BY_PROJECT_OWNER, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.USER_BOOSTED, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_OWNER, - description: NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_OWNER, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_CANCELLED, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_SUPPORTED, - description: NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_SUPPORTED, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_CANCELLED, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_OWNER, - description: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_OWNER, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_ACTIVATED, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_SUPPORTED, - description: NOTIFICATION_TYPE_NAMES.PROJECT_ACTIVATED_SUPPORTED, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_ACTIVATED, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_DEACTIVATED_OWNER, - description: NOTIFICATION_TYPE_NAMES.PROJECT_DEACTIVATED_OWNER, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_DEACTIVATED, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_DEACTIVATED_SUPPORTED, - description: NOTIFICATION_TYPE_NAMES.PROJECT_DEACTIVATED_SUPPORTED, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_DEACTIVATED, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_VERIFIED_OWNER, - description: NOTIFICATION_TYPE_NAMES.PROJECT_VERIFIED_OWNER, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_VERIFIED, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_VERIFIED_SUPPORTED, - description: NOTIFICATION_TYPE_NAMES.PROJECT_VERIFIED_SUPPORTED, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_VERIFIED, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_UNVERIFIED_OWNER, - description: NOTIFICATION_TYPE_NAMES.PROJECT_UNVERIFIED_OWNER, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UNVERIFIED, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_UNVERIFIED_SUPPORTED, - description: NOTIFICATION_TYPE_NAMES.PROJECT_UNVERIFIED_SUPPORTED, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UNVERIFIED_WHO_SUPPORTED, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_BADGE_REVOKE_REMINDER, - description: NOTIFICATION_TYPE_NAMES.PROJECT_BADGE_REVOKE_REMINDER, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_BADGE_REVOKE_REMINDER, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_BADGE_REVOKE_WARNING, - description: NOTIFICATION_TYPE_NAMES.PROJECT_BADGE_REVOKE_WARNING, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_BADGE_REVOKE_WARNING, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_BADGE_REVOKE_LAST_WARNING, - description: NOTIFICATION_TYPE_NAMES.PROJECT_BADGE_REVOKE_LAST_WARNING, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_BADGE_REVOKE_LAST_WARNING, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_BADGE_UP_FOR_REVOKING, - description: NOTIFICATION_TYPE_NAMES.PROJECT_BADGE_UP_FOR_REVOKING, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_BADGE_UP_FOR_REVOKING, - }, - { - name: NOTIFICATION_TYPE_NAMES.VERIFICATION_FORM_GOT_DRAFT_BY_ADMIN, - description: NOTIFICATION_TYPE_NAMES.VERIFICATION_FORM_GOT_DRAFT_BY_ADMIN, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: - SCHEMA_VALIDATORS_NAMES.VERIFICATION_FORM_GOT_DRAFT_BY_ADMIN, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_UPDATE_ADDED, - description: NOTIFICATION_TYPE_NAMES.PROJECT_UPDATE_ADDED, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_UPDATED_ADDED_WHO_SUPPORTS, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_HAS_A_NEW_RANK, - description: NOTIFICATION_TYPE_NAMES.PROJECT_HAS_A_NEW_RANK, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_HAS_A_NEW_RANK, - }, - { - name: NOTIFICATION_TYPE_NAMES.PROJECT_HAS_RISEN_IN_THE_RANK, - description: NOTIFICATION_TYPE_NAMES.PROJECT_HAS_RISEN_IN_THE_RANK, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_HAS_RISEN_IN_THE_RANK, - }, - { - name: NOTIFICATION_TYPE_NAMES.YOUR_PROJECT_GOT_A_RANK, - description: NOTIFICATION_TYPE_NAMES.YOUR_PROJECT_GOT_A_RANK, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.PROJECT_RELATED, - schemaValidator: SCHEMA_VALIDATORS_NAMES.YOUR_PROJECT_GOT_A_RANK, - }, - { - name: NOTIFICATION_TYPE_NAMES.SUBSCRIBE_ONBOARDING, - description: NOTIFICATION_TYPE_NAMES.SUBSCRIBE_ONBOARDING, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.ORTTO, - schemaValidator: SCHEMA_VALIDATORS_NAMES.SUBSCRIBE_ONBOARDING, - }, - { - name: NOTIFICATION_TYPE_NAMES.CREATE_ORTTO_PROFILE, - description: NOTIFICATION_TYPE_NAMES.CREATE_ORTTO_PROFILE, - microService: MICRO_SERVICES.qacc, - category: NOTIFICATION_CATEGORY.ORTTO, - schemaValidator: SCHEMA_VALIDATORS_NAMES.CREATE_ORTTO_PROFILE, - }, - { - name: NOTIFICATION_TYPE_NAMES.NOTIFY_REWARD_AMOUNT, - description: NOTIFICATION_TYPE_NAMES.NOTIFY_REWARD_AMOUNT, + name: NOTIFICATION_TYPE_NAMES.DONATION_RECEIVED_FOR_QACC, + description: 'Project has received a donation', microService: MICRO_SERVICES.qacc, category: NOTIFICATION_CATEGORY.ORTTO, - schemaValidator: SCHEMA_VALIDATORS_NAMES.NOTIFY_REWARD_AMOUNT, + schemaValidator: SCHEMA_VALIDATORS_NAMES.DONATION_RECEIVED_FOR_QACC, }, ]; diff --git a/src/entities/notificationType.ts b/src/entities/notificationType.ts index 066f420..8865d01 100644 --- a/src/entities/notificationType.ts +++ b/src/entities/notificationType.ts @@ -68,6 +68,7 @@ export const SCHEMA_VALIDATORS_NAMES = { YOUR_PROJECT_GOT_A_RANK: 'yourProjectGotARank', NOTIFY_REWARD_AMOUNT: 'notifyRewardAmount', + DONATION_RECEIVED_FOR_QACC: 'DonationReceivedForQacc', }; export type HtmlTemplate = { type: string; content: string; href?: string }[]; diff --git a/src/types/general.ts b/src/types/general.ts index c0e3059..2a15e92 100644 --- a/src/types/general.ts +++ b/src/types/general.ts @@ -55,4 +55,5 @@ export enum NOTIFICATION_TYPE_NAMES { CREATE_ORTTO_PROFILE = 'Create Ortto profile', NOTIFY_REWARD_AMOUNT = 'Notify reward amount', + DONATION_RECEIVED_FOR_QACC = 'Donation received for qacc', } From 050c87cae4cb08b28b1c90393d6b1aaebdf69b81 Mon Sep 17 00:00:00 2001 From: ali ebrahimi Date: Tue, 20 Aug 2024 05:38:34 +0330 Subject: [PATCH 4/6] Remove redundant migration --- ...eUniqueConstraintOnNotificationTypeName.ts | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 migrations/1723505195659-RemoveUniqueConstraintOnNotificationTypeName.ts diff --git a/migrations/1723505195659-RemoveUniqueConstraintOnNotificationTypeName.ts b/migrations/1723505195659-RemoveUniqueConstraintOnNotificationTypeName.ts deleted file mode 100644 index 43d755f..0000000 --- a/migrations/1723505195659-RemoveUniqueConstraintOnNotificationTypeName.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class RemoveUniqueConstraintOnNotificationTypeName1723505195659 - implements MigrationInterface -{ - public async up(queryRunner: QueryRunner): Promise { - // Dropping the unique constraint on the name column - await queryRunner.query( - `ALTER TABLE notification_type DROP CONSTRAINT IF EXISTS "UQ_notification_type_name";`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - // Re-adding the unique constraint if you need to roll back the migration - await queryRunner.query( - `ALTER TABLE notification_type ADD CONSTRAINT "UQ_notification_type_name" UNIQUE (name);`, - ); - } -} From 2b18f10dd17bd8717738493be37ec273c5f601d4 Mon Sep 17 00:00:00 2001 From: ali ebrahimi Date: Tue, 20 Aug 2024 05:40:23 +0330 Subject: [PATCH 5/6] Add donation received for Qacc flow --- src/entities/notificationType.ts | 4 ++-- src/services/notificationService.ts | 9 +++++++++ src/types/notifications.ts | 3 +++ .../validators/segmentAndMetadataValidators.ts | 13 +++++++++++++ src/validators/schemaValidators.ts | 5 +++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/entities/notificationType.ts b/src/entities/notificationType.ts index 8865d01..1777ee8 100644 --- a/src/entities/notificationType.ts +++ b/src/entities/notificationType.ts @@ -68,7 +68,7 @@ export const SCHEMA_VALIDATORS_NAMES = { YOUR_PROJECT_GOT_A_RANK: 'yourProjectGotARank', NOTIFY_REWARD_AMOUNT: 'notifyRewardAmount', - DONATION_RECEIVED_FOR_QACC: 'DonationReceivedForQacc', + DONATION_RECEIVED_FOR_QACC: 'donationReceivedForQacc', }; export type HtmlTemplate = { type: string; content: string; href?: string }[]; @@ -111,7 +111,7 @@ export class NotificationType extends BaseEntity { categoryGroup?: string; @Index() - @Column('text', { nullable: false }) + @Column('text', { nullable: false, unique: true }) name: string; @Column('text', { nullable: false }) diff --git a/src/services/notificationService.ts b/src/services/notificationService.ts index 1ed4a0f..c3879ec 100644 --- a/src/services/notificationService.ts +++ b/src/services/notificationService.ts @@ -198,6 +198,15 @@ export const activityCreator = ( 'str:cm:transactionhash': payload.transactionHash, }; break; + case NOTIFICATIONS_EVENT_NAMES.DONATION_RECEIVED_FOR_QACC: + attributes = { + 'str:cm:donationamount': payload.donationAmount, + 'str:cm:donationtoken': payload.donationToken, + 'str:cm:email': payload.email, + 'str:cm:projectlink': payload.projectLink, + 'str:cm:projecttitle': payload.projectTitle, + 'str:cm:transactionlink': payload.transactionLink, + }; default: logger.debug('activityCreator() invalid event name', orttoEventName); return; diff --git a/src/types/notifications.ts b/src/types/notifications.ts index 68d1d35..776d589 100644 --- a/src/types/notifications.ts +++ b/src/types/notifications.ts @@ -52,6 +52,7 @@ export enum NOTIFICATIONS_EVENT_NAMES { SEND_EMAIL_CONFIRMATION = 'Send email confirmation', SUBSCRIBE_ONBOARDING = 'Subscribe onboarding', NOTIFY_REWARD_AMOUNT = 'Notify reward amount', + DONATION_RECEIVED_FOR_QACC = 'Donation received for qacc', } export const ORTTO_EVENT_NAMES = { @@ -81,4 +82,6 @@ export const ORTTO_EVENT_NAMES = { 'verification-form-email-verification', [NOTIFICATIONS_EVENT_NAMES.NOTIFY_REWARD_AMOUNT]: 'notify-reward', [NOTIFICATIONS_EVENT_NAMES.SUBSCRIBE_ONBOARDING]: 'onboarding-form', + [NOTIFICATIONS_EVENT_NAMES.DONATION_RECEIVED_FOR_QACC]: + 'qacc-donation-received', }; diff --git a/src/utils/validators/segmentAndMetadataValidators.ts b/src/utils/validators/segmentAndMetadataValidators.ts index 915d5bf..09ff529 100644 --- a/src/utils/validators/segmentAndMetadataValidators.ts +++ b/src/utils/validators/segmentAndMetadataValidators.ts @@ -175,6 +175,15 @@ const notifyRewardAmountSegmentSchema = Joi.object({ email: Joi.string().required(), }); +const donationReceivedForQaccSegmentSchema = Joi.object({ + email: Joi.string().required(), + donationAmount: Joi.string().required(), + donationToken: Joi.string().required(), + projectLink: Joi.string().required(), + projectTitle: Joi.string().required(), + transactionLink: Joi.string().required(), +}); + export const SEGMENT_METADATA_SCHEMA_VALIDATOR: { [key: string]: { segment: ObjectSchema | null; @@ -352,4 +361,8 @@ export const SEGMENT_METADATA_SCHEMA_VALIDATOR: { metadata: null, segment: notifyRewardAmountSegmentSchema, }, + donationReceivedForQacc: { + metadata: null, + segment: donationReceivedForQaccSegmentSchema, + }, }; diff --git a/src/validators/schemaValidators.ts b/src/validators/schemaValidators.ts index ccd99ff..1853e7b 100644 --- a/src/validators/schemaValidators.ts +++ b/src/validators/schemaValidators.ts @@ -101,6 +101,11 @@ export const sendNotificationValidator = Joi.object({ network: Joi.string(), script: Joi.string(), transactionHash: Joi.string(), + + // Qacc donation received + donationAmount: Joi.string(), + donationToken: Joi.string(), + projectTitle: Joi.string(), }), }), }); From 2185931c972a0012d94d1e3779bcd39ed3c168ac Mon Sep 17 00:00:00 2001 From: ali ebrahimi Date: Tue, 20 Aug 2024 05:47:59 +0330 Subject: [PATCH 6/6] Fix lint error --- src/services/notificationService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/services/notificationService.ts b/src/services/notificationService.ts index c3879ec..adbb576 100644 --- a/src/services/notificationService.ts +++ b/src/services/notificationService.ts @@ -207,6 +207,7 @@ export const activityCreator = ( 'str:cm:projecttitle': payload.projectTitle, 'str:cm:transactionlink': payload.transactionLink, }; + break; default: logger.debug('activityCreator() invalid event name', orttoEventName); return;