Skip to content

Commit

Permalink
Change date schema to be compatible with ortto schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ae2079 committed Jul 22, 2024
1 parent c3f34ed commit 10fe752
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/services/notificationService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion src/services/notificationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/types/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}

0 comments on commit 10fe752

Please sign in to comment.