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

Change date schema to be compatible with ortto schema #108

Merged
merged 5 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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',
}
Loading