diff --git a/core/notifications/locales/en.yml b/core/notifications/locales/en.yml index 8040f1f186..35b9d11359 100644 --- a/core/notifications/locales/en.yml +++ b/core/notifications/locales/en.yml @@ -15,5 +15,13 @@ circle_threshold_reached.inner.body: "You have welcomed %{threshold} people to B circle_threshold_reached.outer.title: "Outer Circle gains 💪" circle_threshold_reached.outer.body: "Your Outer Circle reached %{threshold} people. You are driving Bitcoin adoption!" -documents_submitted.title: "Documents Received" -documents_submitted.body: "The documents for your verification are being processed." +identity_verification_approved.title: "Your Identity has been verified!" +identity_verification_approved.body: "The documents for your verification have been processed." + +identity_verification_declined.reason.documents_not_clear: "the uploaded documents were not clear" +identity_verification_declined.reason.photo_not_clear: "the picture you submitted was not clear" +identity_verification_declined.title: "Your Identity could not be verified!" +identity_verification_declined.body: "We were not able to process your documents because ${reason}." + +identity_verification_review_pending.title: "Your verification is in process!" +identity_verification_review_pending.body: "We have received your documents and are processing them." diff --git a/core/notifications/proto/notifications.proto b/core/notifications/proto/notifications.proto index 3ac4c58689..8298a7be4a 100644 --- a/core/notifications/proto/notifications.proto +++ b/core/notifications/proto/notifications.proto @@ -133,10 +133,9 @@ message NotificationEvent { oneof data { CircleGrew circle_grew = 1; CircleThresholdReached circle_threshold_reached = 2; - DocumentsSubmitted documents_submitted = 3; - DocumentsApproved documents_approved = 4; - DocumentsRejected documents_rejected = 5; - DocumentsReviewPending documents_review_pending = 6; + IdentityVerificationApproved identity_verification_approved = 3; + IdentityVerificationDeclined identity_verification_declined = 4; + IdentityVerificationReviewPending identity_verification_review_pending = 5; } } @@ -164,18 +163,20 @@ message CircleThresholdReached { uint32 threshold = 4; } -message DocumentsSubmitted { +message IdentityVerificationApproved { string user_id = 1; } -message DocumentsApproved { - string user_id = 1; +enum DeclinedReason { + DOCUMENTS_NOT_CLEAR = 0; + VERIFICATION_PHOTO_NOT_CLEAR = 1; } -message DocumentsRejected { +message IdentityVerificationDeclined { string user_id = 1; + DeclinedReason declined_reason = 2; } -message DocumentsReviewPending { +message IdentityVerificationReviewPending { string user_id = 1; } diff --git a/core/notifications/src/grpc/server/convert.rs b/core/notifications/src/grpc/server/convert.rs index 63f04bcd81..7c121af7a0 100644 --- a/core/notifications/src/grpc/server/convert.rs +++ b/core/notifications/src/grpc/server/convert.rs @@ -1,7 +1,7 @@ use super::proto; -use crate::app::error::ApplicationError; -use crate::primitives::*; -use crate::user_notification_settings; +use crate::{ + app::error::ApplicationError, notification_event, primitives::*, user_notification_settings, +}; impl From for UserNotificationCategory { fn from(category: proto::NotificationCategory) -> Self { @@ -81,3 +81,16 @@ impl From for CircleTimeFrame { } } } + +impl From for notification_event::IdentityVerificationDeclinedReason { + fn from(reason: proto::DeclinedReason) -> Self { + match reason { + proto::DeclinedReason::DocumentsNotClear => { + notification_event::IdentityVerificationDeclinedReason::DocumentsNotClear + } + proto::DeclinedReason::VerificationPhotoNotClear => { + notification_event::IdentityVerificationDeclinedReason::VerificationPhotoNotClear + } + } + } +} diff --git a/core/notifications/src/grpc/server/mod.rs b/core/notifications/src/grpc/server/mod.rs index 76024d8797..b40b36060a 100644 --- a/core/notifications/src/grpc/server/mod.rs +++ b/core/notifications/src/grpc/server/mod.rs @@ -287,50 +287,47 @@ impl NotificationsService for Notifications { } Some(proto::NotificationEvent { data: - Some(proto::notification_event::Data::DocumentsSubmitted( - proto::DocumentsSubmitted { user_id }, + Some(proto::notification_event::Data::IdentityVerificationApproved( + proto::IdentityVerificationApproved { user_id }, )), }) => { self.app - .handle_notification_event(notification_event::DocumentsSubmitted { + .handle_notification_event(notification_event::IdentityVerificationApproved { user_id: GaloyUserId::from(user_id), }) .await? } Some(proto::NotificationEvent { data: - Some(proto::notification_event::Data::DocumentsApproved(proto::DocumentsApproved { - user_id, - })), - }) => { - self.app - .handle_notification_event(notification_event::DocumentsApproved { - user_id: GaloyUserId::from(user_id), - }) - .await? - } - Some(proto::NotificationEvent { - data: - Some(proto::notification_event::Data::DocumentsRejected(proto::DocumentsRejected { - user_id, - })), + Some(proto::notification_event::Data::IdentityVerificationDeclined( + proto::IdentityVerificationDeclined { + user_id, + declined_reason, + }, + )), }) => { + let declined_reason = proto::DeclinedReason::try_from(declined_reason) + .map(notification_event::IdentityVerificationDeclinedReason::from) + .map_err(|e| Status::invalid_argument(e.to_string()))?; self.app - .handle_notification_event(notification_event::DocumentsRejected { + .handle_notification_event(notification_event::IdentityVerificationDeclined { user_id: GaloyUserId::from(user_id), + declined_reason, }) .await? } Some(proto::NotificationEvent { data: - Some(proto::notification_event::Data::DocumentsReviewPending( - proto::DocumentsReviewPending { user_id }, + Some(proto::notification_event::Data::IdentityVerificationReviewPending( + proto::IdentityVerificationReviewPending { user_id }, )), }) => { self.app - .handle_notification_event(notification_event::DocumentsReviewPending { - user_id: GaloyUserId::from(user_id), - }) + .handle_notification_event( + notification_event::IdentityVerificationReviewPending { + user_id: GaloyUserId::from(user_id), + }, + ) .await? } _ => return Err(Status::invalid_argument("event is required")), diff --git a/core/notifications/src/messages/mod.rs b/core/notifications/src/messages/mod.rs index 19e977a5cc..f3aa19da6d 100644 --- a/core/notifications/src/messages/mod.rs +++ b/core/notifications/src/messages/mod.rs @@ -56,29 +56,58 @@ impl Messages { LocalizedMessage { title, body } } - pub fn documents_submitted(locale: &str, _event: &DocumentsSubmitted) -> LocalizedMessage { - let title = t!("documents_submitted.title", locale = locale).to_string(); - let body = t!("documents_submitted.body", locale = locale).to_string(); + pub fn identity_verification_approved( + locale: &str, + _event: &IdentityVerificationApproved, + ) -> LocalizedMessage { + let title = t!("identity_verification_approved.title", locale = locale).to_string(); + let body = t!("identity_verification_approved.body", locale = locale).to_string(); LocalizedMessage { title, body } } - pub fn documents_approved(locale: &str, _event: &DocumentsApproved) -> LocalizedMessage { - let title = t!("documents_approved.title", locale = locale).to_string(); - let body = t!("documents_approved.body", locale = locale).to_string(); - LocalizedMessage { title, body } - } - pub fn documents_rejected(locale: &str, _event: &DocumentsRejected) -> LocalizedMessage { - let title = t!("documents_rejected.title", locale = locale).to_string(); - let body = t!("documents_rejected.body", locale = locale).to_string(); + pub fn identity_verification_declined( + locale: &str, + event: &IdentityVerificationDeclined, + ) -> LocalizedMessage { + let reason = match event.declined_reason { + IdentityVerificationDeclinedReason::DocumentsNotClear => { + t!( + "identity_verification_declined.reason.documents_not_clear", + locale = locale + ) + } + IdentityVerificationDeclinedReason::VerificationPhotoNotClear => { + t!( + "identity_verification_declined.reason.photo_not_clear", + locale = locale + ) + } + }; + let title = t!( + "identity_verification_declined.title", + locale = locale, + reason = reason + ) + .to_string(); + let body = t!( + "identity_verification_declined.body", + locale = locale, + reason = reason + ) + .to_string(); LocalizedMessage { title, body } } - pub fn documents_review_pending( + pub fn identity_verification_review_pending( locale: &str, - _event: &DocumentsReviewPending, + _event: &IdentityVerificationReviewPending, ) -> LocalizedMessage { - let title = t!("documents_review_pending.title", locale = locale).to_string(); - let body = t!("documents_review_pending.body", locale = locale).to_string(); + let title = t!( + "identity_verification_review_pending.title", + locale = locale + ) + .to_string(); + let body = t!("identity_verification_review_pending.body", locale = locale).to_string(); LocalizedMessage { title, body } } } diff --git a/core/notifications/src/notification_event.rs b/core/notifications/src/notification_event.rs index 100056ac97..e30447310a 100644 --- a/core/notifications/src/notification_event.rs +++ b/core/notifications/src/notification_event.rs @@ -18,10 +18,9 @@ pub trait NotificationEvent: std::fmt::Debug + Into { pub enum NotificationEventPayload { CircleGrew(CircleGrew), CircleThresholdReached(CircleThresholdReached), - DocumentsSubmitted(DocumentsSubmitted), - DocumentsApproved(DocumentsApproved), - DocumentsRejected(DocumentsRejected), - DocumentsReviewPending(DocumentsReviewPending), + IdentityVerificationApproved(IdentityVerificationApproved), + IdentityVerificationDeclined(IdentityVerificationDeclined), + IdentityVerificationReviewPending(IdentityVerificationReviewPending), } impl NotificationEvent for NotificationEventPayload { @@ -29,10 +28,9 @@ impl NotificationEvent for NotificationEventPayload { match self { NotificationEventPayload::CircleGrew(event) => event.user_id(), NotificationEventPayload::CircleThresholdReached(event) => event.user_id(), - NotificationEventPayload::DocumentsSubmitted(event) => event.user_id(), - NotificationEventPayload::DocumentsApproved(event) => event.user_id(), - NotificationEventPayload::DocumentsRejected(event) => event.user_id(), - NotificationEventPayload::DocumentsReviewPending(event) => event.user_id(), + NotificationEventPayload::IdentityVerificationApproved(event) => event.user_id(), + NotificationEventPayload::IdentityVerificationDeclined(event) => event.user_id(), + NotificationEventPayload::IdentityVerificationReviewPending(event) => event.user_id(), } } @@ -40,10 +38,9 @@ impl NotificationEvent for NotificationEventPayload { match self { NotificationEventPayload::CircleGrew(event) => event.deep_link(), NotificationEventPayload::CircleThresholdReached(event) => event.deep_link(), - NotificationEventPayload::DocumentsSubmitted(event) => event.deep_link(), - NotificationEventPayload::DocumentsApproved(event) => event.deep_link(), - NotificationEventPayload::DocumentsRejected(event) => event.deep_link(), - NotificationEventPayload::DocumentsReviewPending(event) => event.deep_link(), + NotificationEventPayload::IdentityVerificationApproved(event) => event.deep_link(), + NotificationEventPayload::IdentityVerificationDeclined(event) => event.deep_link(), + NotificationEventPayload::IdentityVerificationReviewPending(event) => event.deep_link(), } } @@ -53,10 +50,13 @@ impl NotificationEvent for NotificationEventPayload { NotificationEventPayload::CircleThresholdReached(event) => { event.to_localized_msg(locale) } - NotificationEventPayload::DocumentsSubmitted(event) => event.to_localized_msg(locale), - NotificationEventPayload::DocumentsApproved(event) => event.to_localized_msg(locale), - NotificationEventPayload::DocumentsRejected(event) => event.to_localized_msg(locale), - NotificationEventPayload::DocumentsReviewPending(event) => { + NotificationEventPayload::IdentityVerificationApproved(event) => { + event.to_localized_msg(locale) + } + NotificationEventPayload::IdentityVerificationDeclined(event) => { + event.to_localized_msg(locale) + } + NotificationEventPayload::IdentityVerificationReviewPending(event) => { event.to_localized_msg(locale) } } @@ -120,11 +120,11 @@ impl From for NotificationEventPayload { } #[derive(Debug, Serialize, Deserialize)] -pub struct DocumentsSubmitted { +pub struct IdentityVerificationApproved { pub user_id: GaloyUserId, } -impl NotificationEvent for DocumentsSubmitted { +impl NotificationEvent for IdentityVerificationApproved { fn user_id(&self) -> &GaloyUserId { &self.user_id } @@ -134,47 +134,29 @@ impl NotificationEvent for DocumentsSubmitted { } fn to_localized_msg(&self, locale: GaloyLocale) -> LocalizedMessage { - Messages::documents_submitted(locale.as_ref(), self) + Messages::identity_verification_approved(locale.as_ref(), self) } } -impl From for NotificationEventPayload { - fn from(event: DocumentsSubmitted) -> Self { - NotificationEventPayload::DocumentsSubmitted(event) +impl From for NotificationEventPayload { + fn from(event: IdentityVerificationApproved) -> Self { + NotificationEventPayload::IdentityVerificationApproved(event) } } #[derive(Debug, Serialize, Deserialize)] -pub struct DocumentsApproved { - pub user_id: GaloyUserId, -} - -impl NotificationEvent for DocumentsApproved { - fn user_id(&self) -> &GaloyUserId { - &self.user_id - } - - fn deep_link(&self) -> DeepLink { - DeepLink::None - } - - fn to_localized_msg(&self, locale: GaloyLocale) -> LocalizedMessage { - Messages::documents_approved(locale.as_ref(), self) - } -} - -impl From for NotificationEventPayload { - fn from(event: DocumentsApproved) -> Self { - NotificationEventPayload::DocumentsApproved(event) - } +pub enum IdentityVerificationDeclinedReason { + DocumentsNotClear, + VerificationPhotoNotClear, } #[derive(Debug, Serialize, Deserialize)] -pub struct DocumentsRejected { +pub struct IdentityVerificationDeclined { pub user_id: GaloyUserId, + pub declined_reason: IdentityVerificationDeclinedReason, } -impl NotificationEvent for DocumentsRejected { +impl NotificationEvent for IdentityVerificationDeclined { fn user_id(&self) -> &GaloyUserId { &self.user_id } @@ -184,22 +166,22 @@ impl NotificationEvent for DocumentsRejected { } fn to_localized_msg(&self, locale: GaloyLocale) -> LocalizedMessage { - Messages::documents_rejected(locale.as_ref(), self) + Messages::identity_verification_declined(locale.as_ref(), self) } } -impl From for NotificationEventPayload { - fn from(event: DocumentsRejected) -> Self { - NotificationEventPayload::DocumentsRejected(event) +impl From for NotificationEventPayload { + fn from(event: IdentityVerificationDeclined) -> Self { + NotificationEventPayload::IdentityVerificationDeclined(event) } } #[derive(Debug, Serialize, Deserialize)] -pub struct DocumentsReviewPending { +pub struct IdentityVerificationReviewPending { pub user_id: GaloyUserId, } -impl NotificationEvent for DocumentsReviewPending { +impl NotificationEvent for IdentityVerificationReviewPending { fn user_id(&self) -> &GaloyUserId { &self.user_id } @@ -209,12 +191,12 @@ impl NotificationEvent for DocumentsReviewPending { } fn to_localized_msg(&self, locale: GaloyLocale) -> LocalizedMessage { - Messages::documents_review_pending(locale.as_ref(), self) + Messages::identity_verification_review_pending(locale.as_ref(), self) } } -impl From for NotificationEventPayload { - fn from(event: DocumentsReviewPending) -> Self { - NotificationEventPayload::DocumentsReviewPending(event) +impl From for NotificationEventPayload { + fn from(event: IdentityVerificationReviewPending) -> Self { + NotificationEventPayload::IdentityVerificationReviewPending(event) } }