Skip to content

Commit

Permalink
chore(notifications): update config (#3924)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleSamtoshi authored Feb 1, 2024
1 parent 264e57d commit 04f0e1d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions core/notifications/src/cli/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ fn default_tracing_config() -> TracingConfig {
pub struct EnvOverride {
pub db_con: String,
pub mongodb_connection: Option<String>,
pub novu_api_key: Option<String>,
}

impl Config {
Expand All @@ -42,6 +43,7 @@ impl Config {
EnvOverride {
db_con,
mongodb_connection,
novu_api_key,
}: EnvOverride,
) -> anyhow::Result<Self> {
let mut config: Config = if let Some(path) = path {
Expand All @@ -54,6 +56,10 @@ impl Config {
config.db.pg_con = db_con;
config.mongo_import.connection = mongodb_connection;

if let Some(novu_api_key) = novu_api_key {
config.app.novu.api_key = novu_api_key;
}

Ok(config)
}
}
3 changes: 3 additions & 0 deletions core/notifications/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ struct Cli {
pg_con: String,
#[clap(env = "MONGODB_CON")]
mongodb_connection: Option<String>,
#[clap(env = "NOVU_API_KEY")]
novu_api_key: Option<String>,
}

pub async fn run() -> anyhow::Result<()> {
Expand All @@ -26,6 +28,7 @@ pub async fn run() -> anyhow::Result<()> {
EnvOverride {
db_con: cli.pg_con,
mongodb_connection: cli.mongodb_connection,
novu_api_key: cli.novu_api_key,
},
)?;

Expand Down
6 changes: 3 additions & 3 deletions core/notifications/src/executor/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ pub struct NovuWorkflows {
#[serde(default = "default_circle_grew_workflow_id")]
pub circle_grew: String,
#[serde(default = "default_circle_threshold_reached_workflow_id")]
pub threshold_reached: String,
pub circle_threshold_reached: String,
}

impl NovuWorkflows {
pub fn for_name(&self, name: &str) -> String {
match name {
"circle_grew" => self.circle_grew.clone(),
"threshold_reached" => self.threshold_reached.clone(),
"circle_threshold_reached" => self.circle_threshold_reached.clone(),
_ => unreachable!("unknown workflow name: {}", name),
}
}
Expand All @@ -28,7 +28,7 @@ impl Default for NovuWorkflows {
fn default() -> Self {
Self {
circle_grew: default_circle_grew_workflow_id(),
threshold_reached: default_circle_threshold_reached_workflow_id(),
circle_threshold_reached: default_circle_threshold_reached_workflow_id(),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/notifications/src/notification_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct CircleThresholdReached {

impl NotificationEvent for CircleThresholdReached {
fn workflow_name() -> &'static str {
"threshold_reached"
"circle_threshold_reached"
}

fn user_id(&self) -> &GaloyUserId {
Expand All @@ -69,7 +69,7 @@ impl NotificationEvent for CircleThresholdReached {
AllowedPayloadValues::String(self.circle_type.to_string()),
),
(
"circle_time_frame".to_string(),
"time_frame".to_string(),
AllowedPayloadValues::String(self.time_frame.to_string()),
),
]
Expand Down

0 comments on commit 04f0e1d

Please sign in to comment.