Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notification types for Qacc #118

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class RemoveUniqueConstraintOnNotificationTypeName1723505195659
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
// 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<void> {
// 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);`,
);
}
}
236 changes: 236 additions & 0 deletions migrations/1723505340806-addNotificationTypesForQacc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
ae2079 marked this conversation as resolved.
Show resolved Hide resolved
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<void> {
await queryRunner.manager.save('notification_type', QaccNotificationTypes);
}

public async down(queryRunner: QueryRunner): Promise<void> {
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';`,
);
}
}
2 changes: 1 addition & 1 deletion src/entities/notificationType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class NotificationType extends BaseEntity {
categoryGroup?: string;

@Index()
@Column('text', { nullable: false, unique: true })
@Column('text', { nullable: false })
ae2079 marked this conversation as resolved.
Show resolved Hide resolved
name: string;

@Column('text', { nullable: false })
Expand Down
1 change: 1 addition & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading