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

chore(notifications): rename identity verification events #3985

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 10 additions & 2 deletions core/notifications/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
19 changes: 10 additions & 9 deletions core/notifications/proto/notifications.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}
19 changes: 16 additions & 3 deletions core/notifications/src/grpc/server/convert.rs
Original file line number Diff line number Diff line change
@@ -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<proto::NotificationCategory> for UserNotificationCategory {
fn from(category: proto::NotificationCategory) -> Self {
Expand Down Expand Up @@ -81,3 +81,16 @@ impl From<proto::CircleTimeFrame> for CircleTimeFrame {
}
}
}

impl From<proto::DeclinedReason> 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
}
}
}
}
45 changes: 21 additions & 24 deletions core/notifications/src/grpc/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
Expand Down
59 changes: 44 additions & 15 deletions core/notifications/src/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
Expand Down
Loading
Loading