Skip to content

Commit

Permalink
Merge pull request #108 from Giveth/4194-make-orto-schema-compatible
Browse files Browse the repository at this point in the history
Change date schema to be compatible with ortto schema
  • Loading branch information
ae2079 authored Jul 22, 2024
2 parents 3a8e70b + 5eab9eb commit aa3423a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/services/notificationService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('activityCreator', () => {
it('should create attributes for NOTIFY_REWARD_AMOUNT', () => {
const payload = {
round: 1,
date: '2024-06-01',
date: '1721668910580',
amount: '1000',
contractAddress: '0x123',
farm: 'Test Farm',
Expand All @@ -24,10 +24,15 @@ describe('activityCreator', () => {
JSON.stringify({
activities: [
{
activity_id: 'act:cm:notify-reward-amount',
activity_id: 'act:cm:notify-reward',
attributes: {
'dtz:cm:date': {
year: 2024,
month: 7,
day: 22,
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
9 changes: 8 additions & 1 deletion src/services/notificationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const activityCreator = (
orttoEventName: NOTIFICATIONS_EVENT_NAMES,
): any => {
let attributes;
let date;
switch (orttoEventName) {
case NOTIFICATIONS_EVENT_NAMES.SUBSCRIBE_ONBOARDING:
attributes = {
Expand Down Expand Up @@ -179,9 +180,15 @@ export const activityCreator = (
};
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 @@ -79,6 +79,6 @@ export const ORTTO_EVENT_NAMES = {
[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 aa3423a

Please sign in to comment.