Skip to content

Commit

Permalink
chore(notifications): fix formatting errors on ci
Browse files Browse the repository at this point in the history
  • Loading branch information
thevaibhav-dixit committed Jan 16, 2024
1 parent 4cb9095 commit 9a724bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
2 changes: 1 addition & 1 deletion 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::{UserNotificationCategory, UserNotificationChannel};
use crate::user_notification_settings;
use super::proto;

impl From<proto::NotificationCategory> for UserNotificationCategory {
fn from(category: proto::NotificationCategory) -> Self {
Expand Down
31 changes: 10 additions & 21 deletions core/notifications/src/grpc/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ use self::proto::{notifications_service_server::NotificationsService, *};
use super::config::*;
use crate::{
app::*,
primitives::{UserNotificationCategory, UserNotificationChannel, GaloyUserId},
primitives::{GaloyUserId, UserNotificationCategory, UserNotificationChannel},
};

pub struct Notifications {
app: NotificationsApp,
}


#[tonic::async_trait]
impl NotificationsService for Notifications {
async fn should_send_notification(
Expand Down Expand Up @@ -54,17 +53,12 @@ impl NotificationsService for Notifications {
request: Request<UserEnableNotificationChannelRequest>,
) -> Result<Response<UserEnableNotificationChannelResponse>, Status> {
let request = request.into_inner();
let UserEnableNotificationChannelRequest {
user_id,
channel,
} = request;
let UserEnableNotificationChannelRequest { user_id, channel } = request;
let channel = proto::NotificationChannel::try_from(channel)
.map(UserNotificationChannel::from)
.map_err(|e| Status::invalid_argument(e.to_string()))?;
let user_id = GaloyUserId::from(user_id);
let notification_settings = self.app
.enable_channel_on_user(user_id, channel)
.await?;
let notification_settings = self.app.enable_channel_on_user(user_id, channel).await?;

Ok(Response::new(UserEnableNotificationChannelResponse {
notification_settings: Some(notification_settings.into()),
Expand All @@ -76,17 +70,12 @@ impl NotificationsService for Notifications {
request: Request<UserDisableNotificationChannelRequest>,
) -> Result<Response<UserDisableNotificationChannelResponse>, Status> {
let request = request.into_inner();
let UserDisableNotificationChannelRequest {
user_id,
channel,
} = request;
let UserDisableNotificationChannelRequest { user_id, channel } = request;
let channel = proto::NotificationChannel::try_from(channel)
.map(UserNotificationChannel::from)
.map_err(|e| Status::invalid_argument(e.to_string()))?;
let user_id = GaloyUserId::from(user_id);
let notification_settings = self.app
.disable_channel_on_user(user_id, channel)
.await?;
let notification_settings = self.app.disable_channel_on_user(user_id, channel).await?;

Ok(Response::new(UserDisableNotificationChannelResponse {
notification_settings: Some(notification_settings.into()),
Expand All @@ -110,7 +99,8 @@ impl NotificationsService for Notifications {
.map(UserNotificationCategory::from)
.map_err(|e| Status::invalid_argument(e.to_string()))?;
let user_id = GaloyUserId::from(user_id);
let notification_settings = self.app
let notification_settings = self
.app
.enable_category_on_user(user_id, channel, category)
.await?;

Expand All @@ -136,7 +126,8 @@ impl NotificationsService for Notifications {
.map(UserNotificationCategory::from)
.map_err(|e| Status::invalid_argument(e.to_string()))?;
let user_id = GaloyUserId::from(user_id);
let notification_settings = self.app
let notification_settings = self
.app
.disable_category_on_user(user_id, channel, category)
.await?;

Expand All @@ -152,9 +143,7 @@ impl NotificationsService for Notifications {
let request = request.into_inner();
let UserNotificationSettingsRequest { user_id } = request;
let user_id = GaloyUserId::from(user_id);
let notification_settings = self.app
.notification_settings_for_user(user_id)
.await?;
let notification_settings = self.app.notification_settings_for_user(user_id).await?;

Ok(Response::new(UserNotificationSettingsResponse {
notification_settings: Some(notification_settings.into()),
Expand Down

0 comments on commit 9a724bc

Please sign in to comment.