Skip to content

Commit

Permalink
chore(notifications): remove Email from UserNotificationChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
thevaibhav-dixit committed Feb 15, 2024
1 parent c39a046 commit 5d78fb1
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 8 deletions.
1 change: 0 additions & 1 deletion core/notifications/proto/notifications.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ service NotificationsService {

enum NotificationChannel {
PUSH = 0;
EMAIL = 1;
}

enum NotificationCategory {
Expand Down
3 changes: 2 additions & 1 deletion core/notifications/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ pub struct NotificationsApp {
impl NotificationsApp {
pub async fn init(pool: Pool<Postgres>, config: AppConfig) -> Result<Self, ApplicationError> {
let settings = UserNotificationSettingsRepo::new(&pool);
let executor = Executor::init(config.executor.clone(), settings.clone()).await?;
let executor = PushExecutor::init(config.executor.clone(), settings.clone()).await?;

let _email_executor = EmailExecutor::init(config.email_executor.clone(), settings.clone())?;
let runner = job::start_job_runner(&pool, executor).await?;
Ok(Self {
Expand Down
5 changes: 1 addition & 4 deletions core/notifications/src/email_executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod config;
pub mod error;
mod smtp;

use crate::{notification_event::*, primitives::*, user_notification_settings::*};
use crate::{notification_event::*, user_notification_settings::*};

pub use config::*;
use error::*;
Expand Down Expand Up @@ -30,9 +30,6 @@ impl EmailExecutor {

pub async fn notify<T: NotificationEvent>(&self, event: &T) -> Result<(), EmailExecutorError> {
let settings = self.settings.find_for_user_id(event.user_id()).await?;
if !settings.should_send_notification(UserNotificationChannel::Email, event.category()) {
return Ok(());
}
let msg = event.to_localized_msg(settings.locale().unwrap_or_default());

self.smtp.send_email(msg).await?;
Expand Down
1 change: 0 additions & 1 deletion core/notifications/src/grpc/server/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ impl From<proto::NotificationChannel> for UserNotificationChannel {
fn from(channel: proto::NotificationChannel) -> Self {
match channel {
proto::NotificationChannel::Push => UserNotificationChannel::Push,
proto::NotificationChannel::Email => UserNotificationChannel::Email,
}
}
}
Expand Down
1 change: 0 additions & 1 deletion core/notifications/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ impl std::fmt::Display for PushDeviceToken {
#[graphql(name = "UserNotificationChannel")]
pub enum UserNotificationChannel {
Push,
Email,
}

#[derive(async_graphql::Enum, Debug, Hash, Copy, Clone, Eq, PartialEq, Deserialize, Serialize)]
Expand Down

0 comments on commit 5d78fb1

Please sign in to comment.