Skip to content

Commit

Permalink
Merge pull request #91 from Giveth/Make-sure-Ortto-is-merging-by-user…
Browse files Browse the repository at this point in the history
…ID,-not-email-#1494

Make sure ortto is merging by user id, not email
  • Loading branch information
RamRamez authored May 13, 2024
2 parents 8145afc + a3d6d4a commit 9320423
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/services/notificationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES
}
if (process.env.ENVIRONMENT === 'production') {
fields['str:cm:user-id'] = payload.userId?.toString()
fields['str:cm:userid'] = payload.userId?.toString()
}
let attributes;
switch (orttoEventName) {
Expand Down Expand Up @@ -60,6 +61,7 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES
"str:cm:projectlink": payload.projectLink,
"bol:cm:verified": payload.verified,
"str:cm:transactionlink": payload.transactionLink,
"str:cm:userid": payload.userId?.toString(),
};
break
case NOTIFICATIONS_EVENT_NAMES.DRAFTED_PROJECT_ACTIVATED:
Expand All @@ -69,34 +71,39 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES
"str:cm:projectlink": payload.projectLink,
"str:cm:firstname": payload.firstName,
"str:cm:lastname": payload.lastName,
"str:cm:userid": payload.userId?.toString(),
};
break
case NOTIFICATIONS_EVENT_NAMES.PROJECT_LISTED:
attributes = {
"str:cm:projecttitle": payload.title,
"str:cm:email": payload.email,
"str:cm:projectlink": payload.projectLink,
"str:cm:userid": payload.userId?.toString(),
};
break
case NOTIFICATIONS_EVENT_NAMES.PROJECT_UNLISTED:
attributes = {
"str:cm:projecttitle": payload.title,
"str:cm:email": payload.email,
"str:cm:projectlink": payload.projectLink,
"str:cm:userid": payload.userId?.toString(),
};
break
case NOTIFICATIONS_EVENT_NAMES.PROJECT_CANCELLED:
attributes = {
"str:cm:projecttitle": payload.title,
"str:cm:email": payload.email,
"str:cm:projectlink": payload.projectLink,
"str:cm:userid": payload.userId?.toString(),
};
break
case NOTIFICATIONS_EVENT_NAMES.PROJECT_UPDATE_ADDED_OWNER:
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
case NOTIFICATIONS_EVENT_NAMES.PROJECT_VERIFIED:
Expand All @@ -105,6 +112,7 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES
"str:cm:email": payload.email,
"str:cm:projectlink": payload.projectLink,
"str:cm:verified-status": 'verified',
"str:cm:userid": payload.userId?.toString(),
};
break
case NOTIFICATIONS_EVENT_NAMES.VERIFICATION_FORM_REJECTED:
Expand All @@ -113,6 +121,7 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES
"str:cm:email": payload.email,
"str:cm:projectlink": payload.projectLink,
"str:cm:verified-status": 'rejected',
"str:cm:userid": payload.userId?.toString(),
};
break
case NOTIFICATIONS_EVENT_NAMES.PROJECT_UNVERIFIED:
Expand All @@ -121,6 +130,7 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES
"str:cm:email": payload.email,
"str:cm:projectlink": payload.projectLink,
"str:cm:verified-status": 'rejected',
"str:cm:userid": payload.userId?.toString(),
};
break
case NOTIFICATIONS_EVENT_NAMES.PROJECT_BADGE_REVOKED:
Expand Down Expand Up @@ -156,14 +166,21 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES
logger.debug('activityCreator() invalid ORTTO_EVENT_NAMES', orttoEventName)
return;
}
const merge_by = [];
if (process.env.ENVIRONMENT === 'production') {
merge_by.push("str:cm:userid")
} else {
merge_by.push("str::email")
}
return {
activities: [
{
activity_id: `act:cm:${ORTTO_EVENT_NAMES[orttoEventName]}`,
attributes,
fields,
}
]
],
merge_by
};
}

Expand Down

0 comments on commit 9320423

Please sign in to comment.