From 10fe75278ea46570c15ee3f1d47b83a96687f9cd Mon Sep 17 00:00:00 2001 From: ali ebrahimi Date: Mon, 22 Jul 2024 17:39:20 +0330 Subject: [PATCH] Change date schema to be compatible with ortto schema --- src/services/notificationService.test.ts | 2 +- src/services/notificationService.ts | 9 ++++++++- src/types/notifications.ts | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/services/notificationService.test.ts b/src/services/notificationService.test.ts index 9f5a5ce..72b1c67 100644 --- a/src/services/notificationService.test.ts +++ b/src/services/notificationService.test.ts @@ -20,7 +20,7 @@ describe('activityCreator', () => { expect(JSON.stringify(result)).equal(JSON.stringify({ activities: [ { - activity_id: "act:cm:notify-reward-amount", + activity_id: "act:cm:notify-reward", attributes: { 'int:cm:round': payload.round, 'str:cm:date': payload.date, diff --git a/src/services/notificationService.ts b/src/services/notificationService.ts index 09d0bf1..293fd37 100644 --- a/src/services/notificationService.ts +++ b/src/services/notificationService.ts @@ -15,6 +15,7 @@ import { NOTIFICATION_CATEGORY } from '../types/general'; export const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES) : any=> { let attributes; + let date; switch (orttoEventName) { case NOTIFICATIONS_EVENT_NAMES.SUBSCRIBE_ONBOARDING: attributes = { @@ -170,9 +171,15 @@ export const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVEN } break case NOTIFICATIONS_EVENT_NAMES.NOTIFY_REWARD_AMOUNT: + date = new Date(Number(payload.date)); attributes = { + "dtz:cm:date": { + "year": date.getUTCFullYear(), + "month": date.getUTCMonth() + 1, // JavaScript's months are zero-indexed + "day": date.getUTCDate(), + "timezone": "UTC" + }, "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, diff --git a/src/types/notifications.ts b/src/types/notifications.ts index 4247a02..cfb40ce 100644 --- a/src/types/notifications.ts +++ b/src/types/notifications.ts @@ -71,6 +71,6 @@ export const ORTTO_EVENT_NAMES = { [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.NOTIFY_REWARD_AMOUNT]: 'notify-reward-amount', + [NOTIFICATIONS_EVENT_NAMES.NOTIFY_REWARD_AMOUNT]: 'notify-reward', [NOTIFICATIONS_EVENT_NAMES.SUBSCRIBE_ONBOARDING]: 'onboarding-form', } \ No newline at end of file