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

feat(notifications): implement email reminder use case #4216

Merged
merged 15 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions core/notifications/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ transaction.paid_invoice.body_display_currency: "+%{displayCurrencyAmount} | %{f

price_changed.title: "Bitcoin is on the move!"
price_changed.body: "Bitcoin is up %{percent_increase}% in the last day to %{price}!"

onboarding.link_email_reminder.title: "Link Email to Secure Account"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: change this to security

onboarding.link_email_reminder.body: "Link your email to secure your account and receive important updates"
56 changes: 56 additions & 0 deletions core/notifications/src/notification_event/link_email_reminder.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
use rust_i18n::t;
use serde::{Deserialize, Serialize};

use super::{DeepLink, NotificationEvent};
use crate::{messages::*, primitives::*};

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct LinkEmailReminder {}

impl NotificationEvent for LinkEmailReminder {
fn category(&self) -> UserNotificationCategory {
UserNotificationCategory::Onboarding
}

fn deep_link(&self) -> Option<DeepLink> {
None
}

fn to_localized_push_msg(&self, locale: GaloyLocale) -> LocalizedPushMessage {
let title = t!(
"onboarding.link_email_reminder.title",
locale = locale.as_ref()
)
.to_string();
let body = t!(
"onboarding.link_email_reminder.body",
locale = locale.as_ref(),
)
.to_string();
LocalizedPushMessage { title, body }
}

fn to_localized_email(&self, _locale: GaloyLocale) -> Option<LocalizedEmail> {
None
}

fn should_send_email(&self) -> bool {
false
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn push_msg_correctly_formatted() {
let event = LinkEmailReminder {};
let localized_message = event.to_localized_push_msg(GaloyLocale::from("en".to_string()));
assert_eq!(localized_message.title, "Link Email to Secure Account");
assert_eq!(
localized_message.body,
"Link your email to secure your account and receive important updates"
);
}
}
10 changes: 10 additions & 0 deletions core/notifications/src/notification_event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mod circle_threshold_reached;
mod identity_verification_approved;
mod identity_verification_declined;
mod identity_verification_review_started;
mod link_email_reminder;
mod marketing_notification_triggered;
mod price_changed;
mod transaction_occurred;
Expand All @@ -16,6 +17,7 @@ pub(super) use circle_threshold_reached::*;
pub(super) use identity_verification_approved::*;
pub(super) use identity_verification_declined::*;
pub(super) use identity_verification_review_started::*;
pub(super) use link_email_reminder::*;
pub(super) use marketing_notification_triggered::*;
pub(super) use price_changed::*;
pub(super) use transaction_occurred::*;
Expand Down Expand Up @@ -48,6 +50,7 @@ pub enum NotificationEventPayload {
TransactionOccurred(TransactionOccurred),
PriceChanged(PriceChanged),
MarketingNotificationTriggered(MarketingNotificationTriggered),
LinkEmailReminder(LinkEmailReminder),
}

impl AsRef<dyn NotificationEvent> for NotificationEventPayload {
Expand All @@ -61,6 +64,7 @@ impl AsRef<dyn NotificationEvent> for NotificationEventPayload {
NotificationEventPayload::TransactionOccurred(event) => event,
NotificationEventPayload::PriceChanged(event) => event,
NotificationEventPayload::MarketingNotificationTriggered(event) => event,
NotificationEventPayload::LinkEmailReminder(event) => event,
}
}
}
Expand Down Expand Up @@ -120,3 +124,9 @@ impl From<MarketingNotificationTriggered> for NotificationEventPayload {
NotificationEventPayload::MarketingNotificationTriggered(event)
}
}

impl From<LinkEmailReminder> for NotificationEventPayload {
fn from(event: LinkEmailReminder) -> Self {
NotificationEventPayload::LinkEmailReminder(event)
}
}
1 change: 1 addition & 0 deletions core/notifications/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ pub enum UserNotificationCategory {
AdminNotification,
Marketing,
Price,
Onboarding,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not Onboarding - its security right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could fit in both categories

}

#[derive(Debug, Serialize, Deserialize, Clone)]
Expand Down
Loading