From 0adf73b9548f4c05ceca24d107b400727a4f9410 Mon Sep 17 00:00:00 2001 From: Ramin Date: Tue, 30 Jan 2024 21:49:31 +0330 Subject: [PATCH 01/19] replace Segment with Ortto API --- src/services/notificationService.ts | 49 ++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/src/services/notificationService.ts b/src/services/notificationService.ts index f76c5c7..5ebc52a 100644 --- a/src/services/notificationService.ts +++ b/src/services/notificationService.ts @@ -1,3 +1,4 @@ +import axios from 'axios'; import { createNotification, findNotificationByTrackId, @@ -10,10 +11,37 @@ import { logger } from '../utils/logger'; import { EMAIL_STATUSES, Notification } from '../entities/notification'; import { SEGMENT_METADATA_SCHEMA_VALIDATOR } from '../utils/validators/segmentAndMetadataValidators'; import { validateWithJoiSchema } from '../validators/schemaValidators'; -import { SegmentAnalyticsSingleton } from './segment/segmentAnalyticsSingleton'; import { SendNotificationRequest } from '../types/requestResponses'; import { StandardError } from '../types/StandardError'; +enum EmailNotificationId { + donationReceived = 'donationReceived', +} + +const activityCreator = (payload: any, emailNotificationId: EmailNotificationId) => { + if (emailNotificationId === EmailNotificationId.donationReceived) { + return { + "activities": [ + { + "activity_id": `act:cm:${emailNotificationId}`, + "attributes": { + "str:cm:projecttitle": payload.title, + "int:cm:donationamount": payload.amount, + "str:cm:donationtoken": payload.token, + "str:cm:email": payload.email, + "str:cm:projectlink": payload.slug, + "bol:cm:verified": payload.verified, + "str:cm:transactionlink": payload.transactionId + }, + "fields": { + "str::email": payload.email + } + } + ] + }; + } +} + export const sendNotification = async ( body: SendNotificationRequest, microService: string, @@ -80,12 +108,17 @@ export const sendNotification = async ( // And it's not good, we should find another solution to separate sending segment and email const segmentData = body.segment?.payload; validateWithJoiSchema(segmentData, segmentValidator); - await SegmentAnalyticsSingleton.getInstance().track({ - eventName: notificationType.emailNotificationId as string, - anonymousId: body?.segment?.anonymousId, - properties: segmentData, - analyticsUserId: body?.segment?.analyticsUserId, - }); + const config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api-us.ortto.app/v1/activities/create', + headers: { + 'X-Api-Key': process.env.ORTTO_API_KEY as string, + 'Content-Type': 'application/json' + }, + data: activityCreator(segmentData, EmailNotificationId.donationReceived) + }; + await axios.request(config); emailStatus = EMAIL_STATUSES.SENT; } @@ -99,7 +132,7 @@ export const sendNotification = async ( } if (!notificationSetting?.allowDappPushNotification) { - //TODO In future we can add a create notification but with disabledNotification:true + //TODO In future we can add a create notification but with disabledNotification:true // So we can exclude them in list of notifications return { success: true, From 9e062e23a8942b89d47bd8a7ead33e73fc40d9cd Mon Sep 17 00:00:00 2001 From: Ramin Date: Wed, 31 Jan 2024 13:41:58 +0330 Subject: [PATCH 02/19] add projectlink and transactionlink --- src/services/notificationService.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/notificationService.ts b/src/services/notificationService.ts index 5ebc52a..83d737c 100644 --- a/src/services/notificationService.ts +++ b/src/services/notificationService.ts @@ -29,9 +29,9 @@ const activityCreator = (payload: any, emailNotificationId: EmailNotificationId) "int:cm:donationamount": payload.amount, "str:cm:donationtoken": payload.token, "str:cm:email": payload.email, - "str:cm:projectlink": payload.slug, + "str:cm:projectlink": payload.projectLink, "bol:cm:verified": payload.verified, - "str:cm:transactionlink": payload.transactionId + "str:cm:transactionlink": payload.transactionLink, }, "fields": { "str::email": payload.email From ef1dd90d99faf5adae0275fff4d751ceaa9cbf35 Mon Sep 17 00:00:00 2001 From: Ramin Date: Thu, 1 Feb 2024 14:17:34 +0330 Subject: [PATCH 03/19] add notification and ortto types --- src/types/notifications.ts | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/types/notifications.ts diff --git a/src/types/notifications.ts b/src/types/notifications.ts new file mode 100644 index 0000000..5f6299a --- /dev/null +++ b/src/types/notifications.ts @@ -0,0 +1,59 @@ +export enum NOTIFICATIONS_EVENT_NAMES { + DRAFTED_PROJECT_ACTIVATED = 'Draft published', + PROJECT_LISTED = 'Project listed', + PROJECT_UNLISTED = 'Project unlisted', + PROJECT_UNLISTED_SUPPORTED = 'Project unlisted - Users who supported', + PROJECT_LISTED_SUPPORTED = 'Project listed - Users who supported', + PROJECT_EDITED = 'Project edited', + PROJECT_BADGE_REVOKED = 'Project badge revoked', + PROJECT_BADGE_REVOKE_REMINDER = 'Project badge revoke reminder', + PROJECT_BADGE_REVOKE_WARNING = 'Project badge revoke warning', + PROJECT_BADGE_REVOKE_LAST_WARNING = 'Project badge revoke last warning', + PROJECT_BADGE_UP_FOR_REVOKING = 'Project badge up for revoking', + PROJECT_BOOSTED = 'Project boosted', + PROJECT_BOOSTED_BY_PROJECT_OWNER = 'Project boosted by project owner', + PROJECT_VERIFIED = 'Project verified', + PROJECT_VERIFIED_USERS_WHO_SUPPORT = 'Project verified - Users who supported', + + // https://github.com/Giveth/impact-graph/issues/624#issuecomment-1240364389 + PROJECT_REJECTED = 'Project unverified', + PROJECT_NOT_REVIEWED = 'Project not reviewed', + PROJECT_UNVERIFIED = 'Project unverified', + VERIFICATION_FORM_REJECTED = 'Form rejected', + PROJECT_UNVERIFIED_USERS_WHO_SUPPORT = 'Project unverified - Users who supported', + PROJECT_ACTIVATED = 'Project activated', + PROJECT_ACTIVATED_USERS_WHO_SUPPORT = 'Project activated - Users who supported', + PROJECT_DEACTIVATED = 'Project deactivated', + PROJECT_DEACTIVATED_USERS_WHO_SUPPORT = 'Project deactivated - Users who supported', + + PROJECT_CANCELLED = 'Project cancelled', + PROJECT_CANCELLED_USERS_WHO_SUPPORT = 'Project cancelled - Users who supported', + MADE_DONATION = 'Made donation', + DONATION_RECEIVED = 'Donation received', + DONATION_GET_PRICE_FAILED = 'Donation get price failed', + PROJECT_RECEIVED_HEART = 'project liked', + PROJECT_UPDATE_ADDED_OWNER = 'Project update added - owner', + PROJECT_CREATED = 'The project saved as draft', + UPDATED_PROFILE = 'Updated profile', + GET_DONATION_PRICE_FAILED = 'Get Donation Price Failed', + VERIFICATION_FORM_GOT_DRAFT_BY_ADMIN = 'Verification form got draft by admin', + RAW_HTML_BROADCAST = 'Raw HTML Broadcast', + PROJECT_ADD_AN_UPDATE_USERS_WHO_SUPPORT = 'Project update added - Users who supported', + + // https://github.com/Giveth/impact-graph/issues/774#issuecomment-1542337083 + PROJECT_HAS_RISEN_IN_THE_RANK = 'Your Project has risen in the rank', + PROJECT_HAS_A_NEW_RANK = 'Your project has a new rank', + YOUR_PROJECT_GOT_A_RANK = 'Your project got a rank', +} + +export const ORTTO_EVENT_NAMES = { + [NOTIFICATIONS_EVENT_NAMES.DONATION_RECEIVED]: 'testing-donation-received', + [NOTIFICATIONS_EVENT_NAMES.PROJECT_CREATED]: 'project-created', + [NOTIFICATIONS_EVENT_NAMES.PROJECT_LISTED]: 'project-listed', + [NOTIFICATIONS_EVENT_NAMES.PROJECT_UNLISTED]: 'project-unlisted', + [NOTIFICATIONS_EVENT_NAMES.PROJECT_DEACTIVATED]: 'project-deactivated', + [NOTIFICATIONS_EVENT_NAMES.MADE_DONATION]: 'donation-made', + [NOTIFICATIONS_EVENT_NAMES.VERIFICATION_FORM_REJECTED]: 'project-verification', + [NOTIFICATIONS_EVENT_NAMES.PROJECT_VERIFIED]: 'project-verification', + [NOTIFICATIONS_EVENT_NAMES.PROJECT_UNVERIFIED]: 'project-verification', +} \ No newline at end of file From 52306c9542d98afd983aef3da26532108964e1aa Mon Sep 17 00:00:00 2001 From: Ramin Date: Thu, 1 Feb 2024 14:18:04 +0330 Subject: [PATCH 04/19] replace segment with emailData --- src/controllers/v1/notificationsController.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/controllers/v1/notificationsController.ts b/src/controllers/v1/notificationsController.ts index cd4936a..64d1a62 100644 --- a/src/controllers/v1/notificationsController.ts +++ b/src/controllers/v1/notificationsController.ts @@ -35,7 +35,6 @@ import { markNotificationsAsRead, } from '../../repositories/notificationRepository'; import { UserAddress } from '../../entities/userAddress'; -import { Notification } from '../../entities/notification'; import { createNewUserAddressIfNotExists } from '../../repositories/userAddressRepository'; import { sendNotification } from '../../services/notificationService'; import { StandardError } from '../../types/StandardError'; @@ -62,7 +61,7 @@ export class NotificationsController { logger.error('sendNotification() error', { error: e, requestBody: body, - segmentPayload: body?.segment?.payload, + segmentPayload: body?.emailData?.payload, }); throw e; } From b351651c201aefb16d4b8cc81955ae4786fbcaae Mon Sep 17 00:00:00 2001 From: Ramin Date: Thu, 1 Feb 2024 14:18:37 +0330 Subject: [PATCH 05/19] add ortto call to adapters --- src/services/notificationService.ts | 68 +++++++++++++---------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/src/services/notificationService.ts b/src/services/notificationService.ts index 83d737c..0bf00ad 100644 --- a/src/services/notificationService.ts +++ b/src/services/notificationService.ts @@ -13,32 +13,33 @@ import { SEGMENT_METADATA_SCHEMA_VALIDATOR } from '../utils/validators/segmentAn import { validateWithJoiSchema } from '../validators/schemaValidators'; import { SendNotificationRequest } from '../types/requestResponses'; import { StandardError } from '../types/StandardError'; +import { NOTIFICATIONS_EVENT_NAMES } from '../types/notifications'; +import { orttoActivityCall } from '../adapters/orttoEmailService/orttoAdapter'; -enum EmailNotificationId { - donationReceived = 'donationReceived', -} - -const activityCreator = (payload: any, emailNotificationId: EmailNotificationId) => { - if (emailNotificationId === EmailNotificationId.donationReceived) { - return { - "activities": [ - { - "activity_id": `act:cm:${emailNotificationId}`, - "attributes": { - "str:cm:projecttitle": payload.title, - "int:cm:donationamount": payload.amount, - "str:cm:donationtoken": payload.token, - "str:cm:email": payload.email, - "str:cm:projectlink": payload.projectLink, - "bol:cm:verified": payload.verified, - "str:cm:transactionlink": payload.transactionLink, - }, - "fields": { - "str::email": payload.email +const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES) => { + switch (orttoEventName) { + case NOTIFICATIONS_EVENT_NAMES.DONATION_RECEIVED: + return { + "activities": [ + { + "activity_id": `act:cm:${orttoEventName}`, + "attributes": { + "str:cm:projecttitle": payload.title, + "int:cm:donationamount": payload.amount, + "str:cm:donationtoken": payload.token, + "str:cm:email": payload.email, + "str:cm:projectlink": payload.projectLink, + "bol:cm:verified": payload.verified, + "str:cm:transactionlink": payload.transactionLink, + }, + "fields": { + "str::email": payload.email + } } - } - ] - }; + ] + }; + default: + throw new Error('Invalid event name'); } } @@ -106,19 +107,10 @@ export const sendNotification = async ( 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 segmentData = body.segment?.payload; - validateWithJoiSchema(segmentData, segmentValidator); - const config = { - method: 'post', - maxBodyLength: Infinity, - url: 'https://api-us.ortto.app/v1/activities/create', - headers: { - 'X-Api-Key': process.env.ORTTO_API_KEY as string, - 'Content-Type': 'application/json' - }, - data: activityCreator(segmentData, EmailNotificationId.donationReceived) - }; - await axios.request(config); + const emailData = body.emailData?.payload; + validateWithJoiSchema(emailData, segmentValidator); + const data = activityCreator(emailData, body.eventName as NOTIFICATIONS_EVENT_NAMES); + await orttoActivityCall(data); emailStatus = EMAIL_STATUSES.SENT; } @@ -146,7 +138,7 @@ export const sendNotification = async ( emailStatus, trackId: body?.trackId, metadata: body?.metadata, - segmentData: body.segment, + segmentData: body.emailData, projectId, }; if (body.creationTime) { From f11d2a92f07223e4178b09aa67f758aabee64b74 Mon Sep 17 00:00:00 2001 From: Ramin Date: Thu, 1 Feb 2024 14:18:46 +0330 Subject: [PATCH 06/19] create ortto adapter --- .../orttoEmailService/orttoAdapter.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/adapters/orttoEmailService/orttoAdapter.ts diff --git a/src/adapters/orttoEmailService/orttoAdapter.ts b/src/adapters/orttoEmailService/orttoAdapter.ts new file mode 100644 index 0000000..6d357eb --- /dev/null +++ b/src/adapters/orttoEmailService/orttoAdapter.ts @@ -0,0 +1,23 @@ +import { logger } from '../../utils/logger'; +import axios from 'axios'; + +export const orttoActivityCall = async (data: any) => { + try { + const config = { + method: 'post', + maxBodyLength: Infinity, + url: process.env.ORTTO_ACTIVITY_API, + headers: { + 'X-Api-Key': process.env.ORTTO_API_KEY as string, + 'Content-Type': 'application/json' + }, + data + }; + await axios.request(config); + } catch (e) { + logger.error('orttoActivityCall error', { + e, + }); + throw e; + } +} \ No newline at end of file From 9c9ac0a4715ae7339a3e6ca898ba69c85e234c58 Mon Sep 17 00:00:00 2001 From: Ramin Date: Thu, 1 Feb 2024 14:19:10 +0330 Subject: [PATCH 07/19] replace segment with emailData --- src/types/requestResponses.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/requestResponses.ts b/src/types/requestResponses.ts index a043218..605f5d0 100644 --- a/src/types/requestResponses.ts +++ b/src/types/requestResponses.ts @@ -46,7 +46,7 @@ export interface SendNotificationRequest { * @description Sample token for above wallet address and mock authentication service eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwdWJsaWNBZGRyZXNzIjoiMHgxMUJFNTVGNGVBNDFFOTlBM2ZiMDZBRGRBNTA3ZDk5ZDdiYjBhNTcxIiwiZXhwaXJhdGlvbkRhdGUiOiIyMDIyLTA5LTIzVDA4OjA5OjA2LjQ1N1oiLCJqdGkiOiIxNjYxMzI4NTQ2NDU3LTc1YzNhNGI2YWUiLCJpYXQiOjE2NjEzMjg1NDYsImV4cCI6MTY2MzkyMDU0Nn0.Tdd2f7bCMtg3F1ojX1AQQpJ7smTU7vR7Nixromr0ju4 */ userWalletAddress?: string; - segment?: { + emailData?: { payload: any; /** From c67663c1f29ead39df6ef81eaf1a7f6e2003f3d2 Mon Sep 17 00:00:00 2001 From: Ramin Date: Sat, 3 Feb 2024 23:58:20 +0330 Subject: [PATCH 08/19] add PROJECT_CREATED event --- src/services/notificationService.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/services/notificationService.ts b/src/services/notificationService.ts index 0bf00ad..c449fcf 100644 --- a/src/services/notificationService.ts +++ b/src/services/notificationService.ts @@ -13,7 +13,7 @@ import { SEGMENT_METADATA_SCHEMA_VALIDATOR } from '../utils/validators/segmentAn import { validateWithJoiSchema } from '../validators/schemaValidators'; import { SendNotificationRequest } from '../types/requestResponses'; import { StandardError } from '../types/StandardError'; -import { NOTIFICATIONS_EVENT_NAMES } from '../types/notifications'; +import { NOTIFICATIONS_EVENT_NAMES, ORTTO_EVENT_NAMES } from '../types/notifications'; import { orttoActivityCall } from '../adapters/orttoEmailService/orttoAdapter'; const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES) => { @@ -22,7 +22,7 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES return { "activities": [ { - "activity_id": `act:cm:${orttoEventName}`, + "activity_id": `act:cm:${ORTTO_EVENT_NAMES[orttoEventName]}`, "attributes": { "str:cm:projecttitle": payload.title, "int:cm:donationamount": payload.amount, @@ -38,6 +38,25 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES } ] }; + case NOTIFICATIONS_EVENT_NAMES.PROJECT_CREATED: + return { + "activities": [ + { + "activity_id": `act:cm:${ORTTO_EVENT_NAMES[orttoEventName]}`, + "attributes": { + "str:cm:projecttitle": payload.title, + "str:cm:email": payload.email, + "str:cm:firstname": payload.firstName, + "str:cm:lastname": payload.lastName, + "str:cm:projectsowned": payload.projectsOwned, + "str:cm:projectlink": payload.projectLink, + }, + "fields": { + "str::email": payload.email + } + } + ] + }; default: throw new Error('Invalid event name'); } From 2148f032c7d693727e135522b063157054319d4b Mon Sep 17 00:00:00 2001 From: Ramin Date: Sun, 4 Feb 2024 19:40:35 +0330 Subject: [PATCH 09/19] add PROJECT_LISTED PROJECT_UNLISTED PROJECT_DEACTIVATED PROJECT_UPDATE_ADDED_OWNER PROJECT_VERIFIED VERIFICATION_FORM_REJECTED PROJECT_UNVERIFIED --- src/services/notificationService.ts | 117 +++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-) diff --git a/src/services/notificationService.ts b/src/services/notificationService.ts index c449fcf..5c4abc2 100644 --- a/src/services/notificationService.ts +++ b/src/services/notificationService.ts @@ -48,7 +48,7 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES "str:cm:email": payload.email, "str:cm:firstname": payload.firstName, "str:cm:lastname": payload.lastName, - "str:cm:projectsowned": payload.projectsOwned, + "obj:cm:projectsowned": payload.projectsOwned, "str:cm:projectlink": payload.projectLink, }, "fields": { @@ -57,6 +57,121 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES } ] }; + case NOTIFICATIONS_EVENT_NAMES.PROJECT_LISTED: + return { + "activities": [ + { + "activity_id": `act:cm:${ORTTO_EVENT_NAMES[orttoEventName]}`, + "attributes": { + "str:cm:projecttitle": payload.title, + "str:cm:email": payload.email, + "str:cm:projectlink": payload.projectLink, + }, + "fields": { + "str::email": payload.email + } + } + ] + }; + case NOTIFICATIONS_EVENT_NAMES.PROJECT_UNLISTED: + return { + "activities": [ + { + "activity_id": `act:cm:${ORTTO_EVENT_NAMES[orttoEventName]}`, + "attributes": { + "str:cm:projecttitle": payload.title, + "str:cm:email": payload.email, + "str:cm:projectlink": payload.projectLink, + }, + "fields": { + "str::email": payload.email + } + } + ] + }; + case NOTIFICATIONS_EVENT_NAMES.PROJECT_DEACTIVATED: + return { + "activities": [ + { + "activity_id": `act:cm:${ORTTO_EVENT_NAMES[orttoEventName]}`, + "attributes": { + "str:cm:projecttitle": payload.title, + "str:cm:email": payload.email, + "str:cm:projectlink": payload.projectLink, + }, + "fields": { + "str::email": payload.email + } + } + ] + }; + case NOTIFICATIONS_EVENT_NAMES.PROJECT_UPDATE_ADDED_OWNER: + return { + "activities": [ + { + "activity_id": `act:cm:${ORTTO_EVENT_NAMES[orttoEventName]}`, + "attributes": { + "str:cm:projecttitle": payload.title, + "str:cm:email": payload.email, + "str:cm:projectupdatelink": payload.projectLink + '?tab=updates', + }, + "fields": { + "str::email": payload.email + } + } + ] + }; + case NOTIFICATIONS_EVENT_NAMES.PROJECT_VERIFIED: + return { + "activities": [ + { + "activity_id": `act:cm:${ORTTO_EVENT_NAMES[orttoEventName]}`, + "attributes": { + "str:cm:projecttitle": payload.title, + "str:cm:email": payload.email, + "str:cm:projectlink": payload.projectLink, + "str:cm:verified-status": 'verified', + }, + "fields": { + "str::email": payload.email + } + } + ] + }; + case NOTIFICATIONS_EVENT_NAMES.VERIFICATION_FORM_REJECTED: + return { + "activities": [ + { + "activity_id": `act:cm:${ORTTO_EVENT_NAMES[orttoEventName]}`, + "attributes": { + "str:cm:projecttitle": payload.title, + "str:cm:email": payload.email, + "str:cm:projectlink": payload.projectLink, + "str:cm:verified-status": 'rejected', + }, + "fields": { + "str::email": payload.email + } + } + ] + }; + case NOTIFICATIONS_EVENT_NAMES.PROJECT_UNVERIFIED: + return { + "activities": [ + { + "activity_id": `act:cm:${ORTTO_EVENT_NAMES[orttoEventName]}`, + "attributes": { + "str:cm:projecttitle": payload.title, + "str:cm:email": payload.email, + "str:cm:projectlink": payload.projectLink, + "str:cm:verified-status": 'revoked', + }, + "fields": { + "str::email": payload.email + } + } + ] + }; default: throw new Error('Invalid event name'); } From d359e59f962d2eedcc93a1f3985827d99904ec41 Mon Sep 17 00:00:00 2001 From: Ramin Date: Mon, 5 Feb 2024 23:57:11 +0330 Subject: [PATCH 10/19] replace emailData with segment --- src/controllers/v1/notificationsController.ts | 2 +- src/services/notificationService.ts | 4 ++-- src/types/requestResponses.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/v1/notificationsController.ts b/src/controllers/v1/notificationsController.ts index 64d1a62..3fb0963 100644 --- a/src/controllers/v1/notificationsController.ts +++ b/src/controllers/v1/notificationsController.ts @@ -61,7 +61,7 @@ export class NotificationsController { logger.error('sendNotification() error', { error: e, requestBody: body, - segmentPayload: body?.emailData?.payload, + segmentPayload: body?.segment?.payload, }); throw e; } diff --git a/src/services/notificationService.ts b/src/services/notificationService.ts index 5c4abc2..a5573e0 100644 --- a/src/services/notificationService.ts +++ b/src/services/notificationService.ts @@ -241,7 +241,7 @@ export const sendNotification = async ( 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.emailData?.payload; + const emailData = body.segment?.payload; validateWithJoiSchema(emailData, segmentValidator); const data = activityCreator(emailData, body.eventName as NOTIFICATIONS_EVENT_NAMES); await orttoActivityCall(data); @@ -272,7 +272,7 @@ export const sendNotification = async ( emailStatus, trackId: body?.trackId, metadata: body?.metadata, - segmentData: body.emailData, + segmentData: body.segment, projectId, }; if (body.creationTime) { diff --git a/src/types/requestResponses.ts b/src/types/requestResponses.ts index 605f5d0..a043218 100644 --- a/src/types/requestResponses.ts +++ b/src/types/requestResponses.ts @@ -46,7 +46,7 @@ export interface SendNotificationRequest { * @description Sample token for above wallet address and mock authentication service eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwdWJsaWNBZGRyZXNzIjoiMHgxMUJFNTVGNGVBNDFFOTlBM2ZiMDZBRGRBNTA3ZDk5ZDdiYjBhNTcxIiwiZXhwaXJhdGlvbkRhdGUiOiIyMDIyLTA5LTIzVDA4OjA5OjA2LjQ1N1oiLCJqdGkiOiIxNjYxMzI4NTQ2NDU3LTc1YzNhNGI2YWUiLCJpYXQiOjE2NjEzMjg1NDYsImV4cCI6MTY2MzkyMDU0Nn0.Tdd2f7bCMtg3F1ojX1AQQpJ7smTU7vR7Nixromr0ju4 */ userWalletAddress?: string; - emailData?: { + segment?: { payload: any; /** From ddfb7641482b7b727786be4b31f82884ec92bf74 Mon Sep 17 00:00:00 2001 From: Ramin Date: Wed, 7 Feb 2024 14:02:27 +0330 Subject: [PATCH 11/19] fix verification event names --- src/services/notificationService.ts | 26 +++----------------------- src/types/notifications.ts | 4 ++-- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/src/services/notificationService.ts b/src/services/notificationService.ts index a5573e0..b2d0c4d 100644 --- a/src/services/notificationService.ts +++ b/src/services/notificationService.ts @@ -1,4 +1,3 @@ -import axios from 'axios'; import { createNotification, findNotificationByTrackId, @@ -38,25 +37,6 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES } ] }; - case NOTIFICATIONS_EVENT_NAMES.PROJECT_CREATED: - return { - "activities": [ - { - "activity_id": `act:cm:${ORTTO_EVENT_NAMES[orttoEventName]}`, - "attributes": { - "str:cm:projecttitle": payload.title, - "str:cm:email": payload.email, - "str:cm:firstname": payload.firstName, - "str:cm:lastname": payload.lastName, - "obj:cm:projectsowned": payload.projectsOwned, - "str:cm:projectlink": payload.projectLink, - }, - "fields": { - "str::email": payload.email - } - } - ] - }; case NOTIFICATIONS_EVENT_NAMES.PROJECT_LISTED: return { "activities": [ @@ -138,7 +118,7 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES } ] }; - case NOTIFICATIONS_EVENT_NAMES.VERIFICATION_FORM_REJECTED: + case NOTIFICATIONS_EVENT_NAMES.PROJECT_UNVERIFIED: return { "activities": [ { @@ -155,7 +135,7 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES } ] }; - case NOTIFICATIONS_EVENT_NAMES.PROJECT_UNVERIFIED: + case NOTIFICATIONS_EVENT_NAMES.PROJECT_BADGE_REVOKED: return { "activities": [ { @@ -173,7 +153,7 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES ] }; default: - throw new Error('Invalid event name'); + throw new Error('activityCreator: Invalid event name'); } } diff --git a/src/types/notifications.ts b/src/types/notifications.ts index 5f6299a..2ec5cc8 100644 --- a/src/types/notifications.ts +++ b/src/types/notifications.ts @@ -53,7 +53,7 @@ export const ORTTO_EVENT_NAMES = { [NOTIFICATIONS_EVENT_NAMES.PROJECT_UNLISTED]: 'project-unlisted', [NOTIFICATIONS_EVENT_NAMES.PROJECT_DEACTIVATED]: 'project-deactivated', [NOTIFICATIONS_EVENT_NAMES.MADE_DONATION]: 'donation-made', - [NOTIFICATIONS_EVENT_NAMES.VERIFICATION_FORM_REJECTED]: 'project-verification', - [NOTIFICATIONS_EVENT_NAMES.PROJECT_VERIFIED]: 'project-verification', [NOTIFICATIONS_EVENT_NAMES.PROJECT_UNVERIFIED]: 'project-verification', + [NOTIFICATIONS_EVENT_NAMES.PROJECT_VERIFIED]: 'project-verification', + [NOTIFICATIONS_EVENT_NAMES.PROJECT_BADGE_REVOKED]: 'project-verification', } \ No newline at end of file From 9aa3e86a5736cbfcb266b70670ca3df21e0f5318 Mon Sep 17 00:00:00 2001 From: Ramin Date: Wed, 7 Feb 2024 14:03:00 +0330 Subject: [PATCH 12/19] add logger for Ortto --- src/adapters/orttoEmailService/orttoAdapter.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/adapters/orttoEmailService/orttoAdapter.ts b/src/adapters/orttoEmailService/orttoAdapter.ts index 6d357eb..bc8e01f 100644 --- a/src/adapters/orttoEmailService/orttoAdapter.ts +++ b/src/adapters/orttoEmailService/orttoAdapter.ts @@ -13,6 +13,7 @@ export const orttoActivityCall = async (data: any) => { }, data }; + data.activities.map((a: any) => logger.debug('orttoActivityCall', a)); await axios.request(config); } catch (e) { logger.error('orttoActivityCall error', { From 66ce68807c85c8279fb92c8ccbfd475a98d1a491 Mon Sep 17 00:00:00 2001 From: Ramin Date: Wed, 7 Feb 2024 14:05:35 +0330 Subject: [PATCH 13/19] add projectLink to validators --- src/utils/validators/segmentAndMetadataValidators.ts | 1 + src/validators/schemaValidators.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/utils/validators/segmentAndMetadataValidators.ts b/src/utils/validators/segmentAndMetadataValidators.ts index 3a5a438..605faaa 100644 --- a/src/utils/validators/segmentAndMetadataValidators.ts +++ b/src/utils/validators/segmentAndMetadataValidators.ts @@ -27,6 +27,7 @@ const projectRelatedTrackerSchema = Joi.object({ lastName: Joi.string().allow(null, ''), OwnerId: Joi.number(), slug: Joi.string().required(), + projectLink: Joi.string().allow(null).allow(''), // it's for project updates update: Joi.string().allow(null, ''), diff --git a/src/validators/schemaValidators.ts b/src/validators/schemaValidators.ts index dad4ffd..cc88303 100644 --- a/src/validators/schemaValidators.ts +++ b/src/validators/schemaValidators.ts @@ -56,6 +56,7 @@ export const sendNotificationValidator = Joi.object({ title: Joi.string(), slug: Joi.string(), firstName: Joi.string().allow(null).allow(''), + projectLink: Joi.string().allow(null).allow(''), // Donation related attributes projectOwnerId: Joi.string(), From 48e5cd2d2db845e05b2544cbb08cc4abfa00ea90 Mon Sep 17 00:00:00 2001 From: Ramin Date: Thu, 8 Feb 2024 00:33:29 +0330 Subject: [PATCH 14/19] send email for projectCancelled instead of projectDeactivated --- src/services/notificationService.ts | 2 +- src/types/notifications.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/notificationService.ts b/src/services/notificationService.ts index b2d0c4d..4e737a5 100644 --- a/src/services/notificationService.ts +++ b/src/services/notificationService.ts @@ -69,7 +69,7 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES } ] }; - case NOTIFICATIONS_EVENT_NAMES.PROJECT_DEACTIVATED: + case NOTIFICATIONS_EVENT_NAMES.PROJECT_CANCELLED: return { "activities": [ { diff --git a/src/types/notifications.ts b/src/types/notifications.ts index 2ec5cc8..fb2c024 100644 --- a/src/types/notifications.ts +++ b/src/types/notifications.ts @@ -51,7 +51,7 @@ export const ORTTO_EVENT_NAMES = { [NOTIFICATIONS_EVENT_NAMES.PROJECT_CREATED]: 'project-created', [NOTIFICATIONS_EVENT_NAMES.PROJECT_LISTED]: 'project-listed', [NOTIFICATIONS_EVENT_NAMES.PROJECT_UNLISTED]: 'project-unlisted', - [NOTIFICATIONS_EVENT_NAMES.PROJECT_DEACTIVATED]: 'project-deactivated', + [NOTIFICATIONS_EVENT_NAMES.PROJECT_CANCELLED]: 'project-deactivated', [NOTIFICATIONS_EVENT_NAMES.MADE_DONATION]: 'donation-made', [NOTIFICATIONS_EVENT_NAMES.PROJECT_UNVERIFIED]: 'project-verification', [NOTIFICATIONS_EVENT_NAMES.PROJECT_VERIFIED]: 'project-verification', From 2f60591ae90cf9f9fb1d4f2a8f599a29b18d4c71 Mon Sep 17 00:00:00 2001 From: Mohammad Ranjbar Z Date: Thu, 8 Feb 2024 12:56:17 +0330 Subject: [PATCH 15/19] Refactor ortto part --- config/example.env | 4 +++ config/test.env | 3 +- src/adapters/adapterFactory.ts | 16 ++++++++++ src/adapters/emailAdapter/orttoAdapter.ts | 29 +++++++++++++++++++ .../emailAdapter/orttoAdapterInterface.ts | 5 ++++ src/adapters/emailAdapter/orttoMockAdapter.ts | 11 +++++++ .../orttoEmailService/orttoAdapter.ts | 24 --------------- src/routes/v1/notificationRouter.test.ts | 10 ------- src/services/notificationService.ts | 4 +-- src/utils/errorMessages.ts | 1 + 10 files changed, 70 insertions(+), 37 deletions(-) create mode 100644 src/adapters/emailAdapter/orttoAdapter.ts create mode 100644 src/adapters/emailAdapter/orttoAdapterInterface.ts create mode 100644 src/adapters/emailAdapter/orttoMockAdapter.ts delete mode 100644 src/adapters/orttoEmailService/orttoAdapter.ts diff --git a/config/example.env b/config/example.env index 63cd251..ad7f233 100644 --- a/config/example.env +++ b/config/example.env @@ -19,3 +19,7 @@ JWT_AUTHORIZATION_ADAPTER=mock AUTH_MICROSERVICE_AUTHORIZATION_URL= HOSTNAME_WHITELIST=next.giveth.io,www.next.giveth.io,staging.giveth.io,www.staging.giveth.io,localhost,giveth.io,vercel.app,www.giveth.io + + +EMAIL_ADAPTER=mock +#EMAIL_ADAPTER=ortto diff --git a/config/test.env b/config/test.env index 73ecf21..a699c35 100644 --- a/config/test.env +++ b/config/test.env @@ -11,7 +11,6 @@ REDIS_HOST=127.0.0.1 REDIS_PORT=6490 REDIS_PASSWORD= - SEGMENT_API_KEY=FAKE_API_KEY JWT_AUTHORIZATION_ADAPTER=mock @@ -26,3 +25,5 @@ GIV_ECONOMY_THIRD_PARTY_MICRO_SERVICE=giveconomy-notification-service # OPTIONAL - force logging to stdout when the value is true LOG_STDOUT=false + +EMAIL_ADAPTER=mock diff --git a/src/adapters/adapterFactory.ts b/src/adapters/adapterFactory.ts index 334e6f5..bdfb103 100644 --- a/src/adapters/adapterFactory.ts +++ b/src/adapters/adapterFactory.ts @@ -1,6 +1,8 @@ import { SiweAuthenticationMicroserviceAdapter } from './jwtAuthentication/siweAuthenticationMicroserviceAdapter'; import { MockJwtAdapter } from './jwtAuthentication/mockJwtAdapter'; import { errorMessages } from '../utils/errorMessages'; +import {OrttoAdapter} from "./emailAdapter/orttoAdapter"; +import {OrttoMockAdapter} from "./emailAdapter/orttoMockAdapter"; const siweAuthenricationAdapter = new SiweAuthenticationMicroserviceAdapter(); const jwtMockAdapter = new MockJwtAdapter(); @@ -15,3 +17,17 @@ export const getJwtAuthenticationAdapter = () => { throw new Error(errorMessages.SPECIFY_JWT_AUTHENTICATION_ADAPTER); } }; + + +const orttoEmailAdapter = new OrttoAdapter() +const emailMockAdapter = new OrttoMockAdapter() +export const getEmailAdapter = () => { + switch (process.env.EMAIL_ADAPTER) { + case 'ortto': + return orttoEmailAdapter; + case 'mock': + return emailMockAdapter; + default: + throw new Error(errorMessages.SPECIFY_JWT_AUTHENTICATION_ADAPTER); + } +}; diff --git a/src/adapters/emailAdapter/orttoAdapter.ts b/src/adapters/emailAdapter/orttoAdapter.ts new file mode 100644 index 0000000..a99179f --- /dev/null +++ b/src/adapters/emailAdapter/orttoAdapter.ts @@ -0,0 +1,29 @@ +import { logger } from '../../utils/logger'; +import axios from 'axios'; +import {OrttoAdapterInterface} from "./orttoAdapterInterface"; + + +export class OrttoAdapter implements OrttoAdapterInterface{ + async callOrttoActivity(data: any): Promise { + try { + const config = { + method: 'post', + maxBodyLength: Infinity, + url: process.env.ORTTO_ACTIVITY_API, + headers: { + 'X-Api-Key': process.env.ORTTO_API_KEY as string, + 'Content-Type': 'application/json' + }, + data + }; + data.activities.map((a: any) => logger.debug('orttoActivityCall', a)); + await axios.request(config); + } catch (e) { + logger.error('orttoActivityCall error', { + e, + }); + throw e; + } + } + +} diff --git a/src/adapters/emailAdapter/orttoAdapterInterface.ts b/src/adapters/emailAdapter/orttoAdapterInterface.ts new file mode 100644 index 0000000..95ea016 --- /dev/null +++ b/src/adapters/emailAdapter/orttoAdapterInterface.ts @@ -0,0 +1,5 @@ +import internal from "stream"; + +export interface OrttoAdapterInterface { + callOrttoActivity (data: any): Promise +} diff --git a/src/adapters/emailAdapter/orttoMockAdapter.ts b/src/adapters/emailAdapter/orttoMockAdapter.ts new file mode 100644 index 0000000..7c46e94 --- /dev/null +++ b/src/adapters/emailAdapter/orttoMockAdapter.ts @@ -0,0 +1,11 @@ +import { logger } from '../../utils/logger'; +import axios from 'axios'; +import {OrttoAdapterInterface} from "./orttoAdapterInterface"; + + +export class OrttoMockAdapter implements OrttoAdapterInterface{ + async callOrttoActivity(data: any): Promise { + logger.debug('OrttoMockAdapter has been called', data) + } + +} diff --git a/src/adapters/orttoEmailService/orttoAdapter.ts b/src/adapters/orttoEmailService/orttoAdapter.ts deleted file mode 100644 index bc8e01f..0000000 --- a/src/adapters/orttoEmailService/orttoAdapter.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { logger } from '../../utils/logger'; -import axios from 'axios'; - -export const orttoActivityCall = async (data: any) => { - try { - const config = { - method: 'post', - maxBodyLength: Infinity, - url: process.env.ORTTO_ACTIVITY_API, - headers: { - 'X-Api-Key': process.env.ORTTO_API_KEY as string, - 'Content-Type': 'application/json' - }, - data - }; - data.activities.map((a: any) => logger.debug('orttoActivityCall', a)); - await axios.request(config); - } catch (e) { - logger.error('orttoActivityCall error', { - e, - }); - throw e; - } -} \ No newline at end of file diff --git a/src/routes/v1/notificationRouter.test.ts b/src/routes/v1/notificationRouter.test.ts index cc3e1bf..5d8021d 100644 --- a/src/routes/v1/notificationRouter.test.ts +++ b/src/routes/v1/notificationRouter.test.ts @@ -355,8 +355,6 @@ function sendNotificationTestCases() { sendEmail: true, sendSegment: true, segment: { - analyticsUserId: 'givethId-255', - anonymousId: 'givethId-255', payload: { title: 'Test verify and reject form emails', lastName: 'Ranjbar', @@ -1385,8 +1383,6 @@ function sendNotificationTestCases() { projectLink, }, segment: { - analyticsUserId: 'givethId-255', - anonymousId: 'givethId-255', payload: { email: 'test@giveth.com', title: 'How many photos is too many photos?', @@ -1428,8 +1424,6 @@ function sendNotificationTestCases() { projectLink, }, segment: { - analyticsUserId: 'givethId-255', - anonymousId: 'givethId-255', payload: { email: 'test@giveth.com', title: 'How many photos is too many photos?', @@ -1499,8 +1493,6 @@ function sendNotificationTestCases() { projectLink, }, segment: { - analyticsUserId: 'givethId-255', - anonymousId: 'givethId-255', payload: { email: 'test@giveth.com', title: 'How many photos is too many photos?', @@ -1542,8 +1534,6 @@ function sendNotificationTestCases() { projectLink, }, segment: { - analyticsUserId: 'givethId-255', - anonymousId: 'givethId-255', payload: { email: 'test@giveth.com', title: 'How many photos is too many photos?', diff --git a/src/services/notificationService.ts b/src/services/notificationService.ts index b2d0c4d..1883074 100644 --- a/src/services/notificationService.ts +++ b/src/services/notificationService.ts @@ -13,7 +13,7 @@ import { validateWithJoiSchema } from '../validators/schemaValidators'; import { SendNotificationRequest } from '../types/requestResponses'; import { StandardError } from '../types/StandardError'; import { NOTIFICATIONS_EVENT_NAMES, ORTTO_EVENT_NAMES } from '../types/notifications'; -import { orttoActivityCall } from '../adapters/orttoEmailService/orttoAdapter'; +import {getEmailAdapter} from "../adapters/adapterFactory"; const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES) => { switch (orttoEventName) { @@ -224,7 +224,7 @@ export const sendNotification = async ( const emailData = body.segment?.payload; validateWithJoiSchema(emailData, segmentValidator); const data = activityCreator(emailData, body.eventName as NOTIFICATIONS_EVENT_NAMES); - await orttoActivityCall(data); + await getEmailAdapter().callOrttoActivity(data); emailStatus = EMAIL_STATUSES.SENT; } diff --git a/src/utils/errorMessages.ts b/src/utils/errorMessages.ts index b1ad8a7..07ed457 100644 --- a/src/utils/errorMessages.ts +++ b/src/utils/errorMessages.ts @@ -50,6 +50,7 @@ export const errorMessagesEnum = { export const errorMessages = { SPECIFY_JWT_AUTHENTICATION_ADAPTER: 'Specify authentication jwt adapter', + SPECIFY_Email_ADAPTER: 'Specify email adapter', CHANGE_API_INVALID_TITLE_OR_EIN: 'ChangeAPI title or EIN not found or invalid', INVALID_SOCIAL_NETWORK: 'Invalid social network', From b7e14021ff7e614417910a09a7c0682acd2121fb Mon Sep 17 00:00:00 2001 From: Ramin Date: Thu, 8 Feb 2024 14:21:21 +0330 Subject: [PATCH 16/19] add DRAFTED_PROJECT_ACTIVATED --- src/services/notificationService.ts | 18 ++++++++++++++++++ src/types/notifications.ts | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/services/notificationService.ts b/src/services/notificationService.ts index 4e737a5..66bf0da 100644 --- a/src/services/notificationService.ts +++ b/src/services/notificationService.ts @@ -37,6 +37,24 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES } ] }; + case NOTIFICATIONS_EVENT_NAMES.DRAFTED_PROJECT_ACTIVATED: + return { + "activities": [ + { + "activity_id": `act:cm:${ORTTO_EVENT_NAMES[orttoEventName]}`, + "attributes": { + "str:cm:projecttitle": payload.title, + "str:cm:email": payload.email, + "str:cm:projectlink": payload.projectLink, + "str:cm:firstname": payload.firstName, + "str:cm:lastname": payload.lastName, + }, + "fields": { + "str::email": payload.email + } + } + ] + }; case NOTIFICATIONS_EVENT_NAMES.PROJECT_LISTED: return { "activities": [ diff --git a/src/types/notifications.ts b/src/types/notifications.ts index fb2c024..a57883c 100644 --- a/src/types/notifications.ts +++ b/src/types/notifications.ts @@ -48,7 +48,7 @@ export enum NOTIFICATIONS_EVENT_NAMES { export const ORTTO_EVENT_NAMES = { [NOTIFICATIONS_EVENT_NAMES.DONATION_RECEIVED]: 'testing-donation-received', - [NOTIFICATIONS_EVENT_NAMES.PROJECT_CREATED]: 'project-created', + [NOTIFICATIONS_EVENT_NAMES.DRAFTED_PROJECT_ACTIVATED]: 'project-created', [NOTIFICATIONS_EVENT_NAMES.PROJECT_LISTED]: 'project-listed', [NOTIFICATIONS_EVENT_NAMES.PROJECT_UNLISTED]: 'project-unlisted', [NOTIFICATIONS_EVENT_NAMES.PROJECT_CANCELLED]: 'project-deactivated', From b7829e1c498ec7428092493a1e43742fafd1a5c8 Mon Sep 17 00:00:00 2001 From: Mohammad Ranjbar Z Date: Thu, 8 Feb 2024 14:42:57 +0330 Subject: [PATCH 17/19] Fix activityCreator() --- src/adapters/emailAdapter/orttoAdapter.ts | 7 +++++-- src/services/notificationService.ts | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/adapters/emailAdapter/orttoAdapter.ts b/src/adapters/emailAdapter/orttoAdapter.ts index a99179f..3ce533d 100644 --- a/src/adapters/emailAdapter/orttoAdapter.ts +++ b/src/adapters/emailAdapter/orttoAdapter.ts @@ -6,6 +6,9 @@ import {OrttoAdapterInterface} from "./orttoAdapterInterface"; export class OrttoAdapter implements OrttoAdapterInterface{ async callOrttoActivity(data: any): Promise { try { + if (!data){ + throw new Error('callOrttoActivity input data is empty') + } const config = { method: 'post', maxBodyLength: Infinity, @@ -20,9 +23,9 @@ export class OrttoAdapter implements OrttoAdapterInterface{ await axios.request(config); } catch (e) { logger.error('orttoActivityCall error', { - e, + error: e, + data }); - throw e; } } diff --git a/src/services/notificationService.ts b/src/services/notificationService.ts index 1883074..0aaa1f6 100644 --- a/src/services/notificationService.ts +++ b/src/services/notificationService.ts @@ -15,7 +15,7 @@ import { StandardError } from '../types/StandardError'; import { NOTIFICATIONS_EVENT_NAMES, ORTTO_EVENT_NAMES } from '../types/notifications'; import {getEmailAdapter} from "../adapters/adapterFactory"; -const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES) => { +const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES) : any=> { switch (orttoEventName) { case NOTIFICATIONS_EVENT_NAMES.DONATION_RECEIVED: return { @@ -153,7 +153,8 @@ const activityCreator = (payload: any, orttoEventName: NOTIFICATIONS_EVENT_NAMES ] }; default: - throw new Error('activityCreator: Invalid event name'); + logger.debug('activityCreator() invalid event name', orttoEventName) + return undefined } } From 71c29d71f2d5170cab8b8f60b9f1150ecc3c2a3f Mon Sep 17 00:00:00 2001 From: Mohammad Ranjbar Z Date: Thu, 8 Feb 2024 15:19:17 +0330 Subject: [PATCH 18/19] Fix getEmailAdapter error message --- src/adapters/adapterFactory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adapters/adapterFactory.ts b/src/adapters/adapterFactory.ts index bdfb103..b13919a 100644 --- a/src/adapters/adapterFactory.ts +++ b/src/adapters/adapterFactory.ts @@ -28,6 +28,6 @@ export const getEmailAdapter = () => { case 'mock': return emailMockAdapter; default: - throw new Error(errorMessages.SPECIFY_JWT_AUTHENTICATION_ADAPTER); + throw new Error(errorMessages.SPECIFY_Email_ADAPTER); } }; From 57367e8e79f698de576fcd43b771a0a5036c1563 Mon Sep 17 00:00:00 2001 From: Ramin Date: Thu, 8 Feb 2024 15:37:28 +0330 Subject: [PATCH 19/19] add new env vars to example.env --- config/example.env | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/example.env b/config/example.env index ad7f233..59c489c 100644 --- a/config/example.env +++ b/config/example.env @@ -13,6 +13,8 @@ REDIS_PORT=6490 REDIS_PASSWORD= SEGMENT_API_KEY=FAKE_API_KEY +ORTTO_API_KEY=FAKE_API_KEY +ORTTO_ACTIVITY_API=https://api-us.ortto.app/v1/activities/create #JWT_AUTHORIZATION_ADAPTER=siweMicroservice JWT_AUTHORIZATION_ADAPTER=mock