Skip to content

Commit

Permalink
Merge branch 'refs/heads/staging' into add-eslint
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/services/notificationService.ts
#	src/types/general.ts
#	src/types/notifications.ts
  • Loading branch information
RamRamez committed Jul 2, 2024
2 parents dfe1590 + 8087902 commit 8a0d320
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { MigrationInterface, QueryRunner } from "typeorm"
import { NOTIFICATION_CATEGORY, NOTIFICATION_TYPE_NAMES } from '../src/types/general';
import { MICRO_SERVICES } from '../src/utils/utils';
import { NotificationType, SCHEMA_VALIDATORS_NAMES } from '../src/entities/notificationType';

const NotifyRewardAmountNotificationType = [
{
name: NOTIFICATION_TYPE_NAMES.NOTIFY_REWARD_AMOUNT,
description: NOTIFICATION_TYPE_NAMES.NOTIFY_REWARD_AMOUNT,
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.NOTIFY_REWARD_AMOUNT,
schemaValidator: SCHEMA_VALIDATORS_NAMES.NOTIFY_REWARD_AMOUNT,
title: "Notify reward report",
}
]

export class seedNotificationTypeForNotifyRewardAmount1718888344202 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.manager.save(NotificationType, NotifyRewardAmountNotificationType);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`DELETE FROM notification_type WHERE "name" = ${NOTIFICATION_TYPE_NAMES.NOTIFY_REWARD_AMOUNT};`,
);
}
}
2 changes: 2 additions & 0 deletions src/entities/notificationType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export const SCHEMA_VALIDATORS_NAMES = {
PROJECT_HAS_A_NEW_RANK: 'projectHasANewRank',
PROJECT_HAS_RISEN_IN_THE_RANK: 'projectHasRisenInTheRank',
YOUR_PROJECT_GOT_A_RANK: 'yourProjectGotARank',

NOTIFY_REWARD_AMOUNT: 'notifyRewardAmount',
};
export type HtmlTemplate = { type: string; content: string; href?: string }[];

Expand Down
25 changes: 19 additions & 6 deletions src/services/notificationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,25 @@ const activityCreator = (
break;
case NOTIFICATIONS_EVENT_NAMES.PROJECT_BADGE_REVOKE_LAST_WARNING:
attributes = {
'str:cm:projecttitle': payload.title,
'str:cm:email': payload.email,
'str:cm:projectupdatelink': payload.projectLink + '?tab=updates',
'str:cm:userid': payload.userId?.toString(),
};
break;
"str:cm:projecttitle": payload.title,
"str:cm:email": payload.email,
"str:cm:projectupdatelink": payload.projectLink + '?tab=updates',
"str:cm:userid": payload.userId?.toString(),
}
break
case NOTIFICATIONS_EVENT_NAMES.NOTIFY_REWARD_AMOUNT:
attributes = {
"int:cm:round": payload.round,
"str:cm:date": payload.date,
"str:cm:amount": payload.amount,
"str:cm:contractaddress": payload.contractAddress,
"str:cm:farm": payload.farm,
"str:cm:message": payload.message,
"str:cm:network": payload.network,
"str:cm:script": payload.script,
"str:cm:transactionhash": payload.transactionHash,
}
break
default:
logger.debug('activityCreator() invalid event name', orttoEventName);
return;
Expand Down
3 changes: 3 additions & 0 deletions src/types/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export enum NOTIFICATION_CATEGORY {
SUPPORTED_PROJECTS = 'supportedProjects',
GIV_POWER = 'givPower',
ORTTO = 'ortto',
NOTIFY_REWARD_AMOUNT = 'notifyRewardAmount',
}

export enum NOTIFICATION_TYPE_NAMES {
Expand Down Expand Up @@ -53,4 +54,6 @@ export enum NOTIFICATION_TYPE_NAMES {
YOUR_PROJECT_GOT_A_RANK = 'Your project got a rank',
SUBSCRIBE_ONBOARDING = 'Subscribe onboarding',
CREATE_ORTTO_PROFILE = 'Create Ortto profile',

NOTIFY_REWARD_AMOUNT = 'Notify reward amount',
}
8 changes: 5 additions & 3 deletions src/types/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export enum NOTIFICATIONS_EVENT_NAMES {
SUPER_TOKENS_BALANCE_DEPLETED = 'Stream balance depleted',
CREATE_ORTTO_PROFILE = 'Create Ortto profile',
SEND_EMAIL_CONFIRMATION = 'Send email confirmation',

NOTIFY_REWARD_AMOUNT = 'Notify reward amount',
}

export const ORTTO_EVENT_NAMES: any = {
Expand All @@ -75,6 +77,6 @@ export const ORTTO_EVENT_NAMES: any = {
[NOTIFICATIONS_EVENT_NAMES.PROJECT_BADGE_REVOKE_LAST_WARNING]:
'second-update-warning',
[NOTIFICATIONS_EVENT_NAMES.CREATE_ORTTO_PROFILE]: 'created-profile',
[NOTIFICATIONS_EVENT_NAMES.SEND_EMAIL_CONFIRMATION]:
'verification-form-email-verification',
};
[NOTIFICATIONS_EVENT_NAMES.SEND_EMAIL_CONFIRMATION]: 'verification-form-email-verification',
[NOTIFICATIONS_EVENT_NAMES.NOTIFY_REWARD_AMOUNT]: 'notify-reward-amount'
}
16 changes: 16 additions & 0 deletions src/utils/validators/segmentAndMetadataValidators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@ const sendEmailConfirmationSchema = Joi.object({
verificationLink: Joi.string().required(),
});

const notifyRewardAmountSegmentSchema = Joi.object({
round: Joi.number().required(),
date: Joi.string().required(),
amount: Joi.string().required(),
contractAddress: Joi.string().required(),
farm: Joi.string().required(),
message: Joi.string().required(),
network: Joi.string().required(),
script: Joi.string().required(),
transactionHash: Joi.string().required(),
})

export const SEGMENT_METADATA_SCHEMA_VALIDATOR: {
[key: string]: {
segment: ObjectSchema | null;
Expand Down Expand Up @@ -334,4 +346,8 @@ export const SEGMENT_METADATA_SCHEMA_VALIDATOR: {
metadata: projectTitleProjectLinkSchema,
segment: null,
},
notifyRewardAmount: {
metadata: null,
segment: notifyRewardAmountSegmentSchema,
},
};
4 changes: 4 additions & 0 deletions src/validators/schemaValidators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ export const sendNotificationValidator = Joi.object({

// Project update
update: Joi.string(),

// Notify reward attributes
contractAddress: Joi.string(),
farm: Joi.string(),
}),
}),
});
Expand Down

0 comments on commit 8a0d320

Please sign in to comment.