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

fix: disable reminders stuff #236

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
13 changes: 9 additions & 4 deletions crates/api/src/event/create_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use nittei_domain::{
User,
};
use nittei_infra::NitteiContext;
use nittei_utils::config::APP_CONFIG;

use super::subscribers::CreateRemindersOnEventCreated;
use crate::{
Expand Down Expand Up @@ -234,10 +235,14 @@ impl UseCase for CreateEventUseCase {
}

fn subscribers() -> Vec<Box<dyn Subscriber<Self>>> {
vec![
Box::new(CreateRemindersOnEventCreated),
Box::new(CreateSyncedEventsOnEventCreated),
]
if APP_CONFIG.enable_reminders {
vec![
Box::new(CreateRemindersOnEventCreated),
Box::new(CreateSyncedEventsOnEventCreated),
]
} else {
vec![]
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion crates/api/src/event/delete_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use nittei_infra::{
google_calendar::GoogleCalendarProvider,
outlook_calendar::OutlookCalendarProvider,
};
use nittei_utils::config::APP_CONFIG;
use tracing::error;

use crate::{
Expand Down Expand Up @@ -105,7 +106,9 @@ impl UseCase for DeleteEventUseCase {
_ => return Err(UseCaseError::NotFound(self.event_id.clone())),
};

self.delete_synced_events(&e, ctx).await;
if APP_CONFIG.enable_reminders {
self.delete_synced_events(&e, ctx).await;
}

ctx.repos
.events
Expand Down
13 changes: 9 additions & 4 deletions crates/api/src/event/update_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use nittei_domain::{
User,
};
use nittei_infra::NitteiContext;
use nittei_utils::config::APP_CONFIG;

use crate::{
error::NitteiError,
Expand Down Expand Up @@ -354,10 +355,14 @@ impl UseCase for UpdateEventUseCase {
}

fn subscribers() -> Vec<Box<dyn Subscriber<Self>>> {
vec![
Box::new(SyncRemindersOnEventUpdated),
Box::new(UpdateSyncedEventsOnEventUpdated),
]
if APP_CONFIG.enable_reminders {
vec![
Box::new(SyncRemindersOnEventUpdated),
Box::new(UpdateSyncedEventsOnEventUpdated),
]
} else {
vec![]
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ pub struct AppConfig {
/// Env var: NITTEI__SKIP_DB_MIGRATIONS
pub skip_db_migrations: bool,

/// This is a flag to enable the reminders job
/// This is a flag to enable the reminders features
/// Default is false
/// Env var: NITTEI__ENABLE_REMINDERS_JOB
pub enable_reminders_job: bool,
/// Env var: NITTEI__ENABLE_REMINDERS
pub enable_reminders: bool,

/// The account configuration
/// This is used to find the superadmin account
Expand Down
Loading