Skip to content

Commit

Permalink
Merge pull request #77 from Giveth/main
Browse files Browse the repository at this point in the history
merge Main to staging
  • Loading branch information
RamRamez authored Feb 28, 2024
2 parents 4422ea9 + 90734ad commit 05a9322
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
22 changes: 19 additions & 3 deletions src/services/notificationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES
"str:cm:verified-status": 'verified',
};
break
case NOTIFICATIONS_EVENT_NAMES.VERIFICATION_FORM_REJECTED:
attributes = {
"str:cm:projecttitle": payload.title,
"str:cm:email": payload.email,
"str:cm:projectlink": payload.projectLink,
"str:cm:verified-status": 'rejected',
};
break
case NOTIFICATIONS_EVENT_NAMES.PROJECT_UNVERIFIED:
attributes = {
"str:cm:projecttitle": payload.title,
Expand All @@ -98,6 +106,11 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES
break
default:
logger.debug('activityCreator() invalid event name', orttoEventName)
return;
}
if (!ORTTO_EVENT_NAMES[orttoEventName]) {
logger.debug('activityCreator() invalid ORTTO_EVENT_NAMES', orttoEventName)
return;
}
return {
activities: [
Expand Down Expand Up @@ -158,6 +171,9 @@ export const sendNotification = async (
},
trackId: body.trackId,
metadata: body.metadata,
payload: body.segment?.payload,
sendEmail: body.sendEmail,
sendSegment: body.sendSegment,
});

const shouldSendEmail =
Expand All @@ -172,12 +188,12 @@ export const sendNotification = async (
]?.segment;

if (shouldSendEmail && body.sendSegment && segmentValidator) {
//TODO Currently sending email and segment event are tightly coupled, we can't send segment event without sending email
// And it's not good, we should find another solution to separate sending segment and email
const emailData = body.segment?.payload;
validateWithJoiSchema(emailData, segmentValidator);
const data = activityCreator(emailData, body.eventName as NOTIFICATIONS_EVENT_NAMES);
await getEmailAdapter().callOrttoActivity(data);
if (data) {
await getEmailAdapter().callOrttoActivity(data);
}
emailStatus = EMAIL_STATUSES.SENT;
}

Expand Down
1 change: 1 addition & 0 deletions src/types/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ export const ORTTO_EVENT_NAMES = {
[NOTIFICATIONS_EVENT_NAMES.PROJECT_UNVERIFIED]: 'project-verification',
[NOTIFICATIONS_EVENT_NAMES.PROJECT_VERIFIED]: 'project-verification',
[NOTIFICATIONS_EVENT_NAMES.PROJECT_BADGE_REVOKED]: 'project-verification',
[NOTIFICATIONS_EVENT_NAMES.VERIFICATION_FORM_REJECTED]: 'project-verification',
}
2 changes: 1 addition & 1 deletion src/utils/validators/segmentAndMetadataValidators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export const SEGMENT_METADATA_SCHEMA_VALIDATOR: {
},
verificationFormRejected: {
metadata: projectTitleProjectLinkReasonSchema,
segment: null,
segment: projectRelatedTrackerSchema,
},
verificationFormReapplyReminder: {
metadata: verificationFormReapplyReminderSchema,
Expand Down
1 change: 1 addition & 0 deletions src/validators/schemaValidators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const throwHttpErrorIfJoiValidatorFails = (
throw error;
}
};

export const countUnreadValidator = Joi.object({
walletAddress: Joi.alternatives().try(
Joi.string().required().pattern(ethereumWalletAddressRegex),
Expand Down

0 comments on commit 05a9322

Please sign in to comment.