diff --git a/backend/windmill-api/src/oauth2.rs b/backend/windmill-api/src/oauth2.rs index 24a1864208..88fc9a0356 100644 --- a/backend/windmill-api/src/oauth2.rs +++ b/backend/windmill-api/src/oauth2.rs @@ -56,8 +56,6 @@ use windmill_queue::PushIsolationLevel; use std::{fs, str}; -pub const WORKSPACE_SLACK_BOT_TOKEN_PATH: &str = "f/slack_bot/bot_token"; - pub fn global_service() -> Router { Router::new() .route("/login/:client", get(login)) diff --git a/backend/windmill-api/src/workspaces.rs b/backend/windmill-api/src/workspaces.rs index a1422098d0..7af1f02861 100644 --- a/backend/windmill-api/src/workspaces.rs +++ b/backend/windmill-api/src/workspaces.rs @@ -21,7 +21,6 @@ use crate::{ variables::build_crypt, webhook_util::{InstanceEvent, WebhookShared} }; -use crate::oauth2::WORKSPACE_SLACK_BOT_TOKEN_PATH; #[cfg(feature = "enterprise")] use axum::response::Redirect; use axum::{ @@ -46,6 +45,7 @@ use windmill_common::{ scripts::{Schema, Script, ScriptLang}, utils::{paginate, rd_string, require_admin, Pagination}, variables::ExportableListableVariable, + oauth2::WORKSPACE_SLACK_BOT_TOKEN_PATH, }; use windmill_queue::QueueTransaction; diff --git a/backend/windmill-common/src/oauth2.rs b/backend/windmill-common/src/oauth2.rs index 62a162fa37..39a6060270 100644 --- a/backend/windmill-common/src/oauth2.rs +++ b/backend/windmill-common/src/oauth2.rs @@ -10,3 +10,5 @@ use hmac::Hmac; use sha2::Sha256; pub type HmacSha256 = Hmac; + +pub const WORKSPACE_SLACK_BOT_TOKEN_PATH: &str = "f/slack_bot/bot_token"; diff --git a/backend/windmill-queue/src/jobs.rs b/backend/windmill-queue/src/jobs.rs index f5dcb91877..c416e6a7cd 100644 --- a/backend/windmill-queue/src/jobs.rs +++ b/backend/windmill-queue/src/jobs.rs @@ -53,6 +53,7 @@ use windmill_common::{ get_payload_tag_from_prefixed_path, script_path_to_payload, CompletedJob, JobKind, JobPayload, QueuedJob, RawCode, }, + oauth2::WORKSPACE_SLACK_BOT_TOKEN_PATH, schedule::{schedule_to_user, Schedule}, scripts::{ScriptHash, ScriptLang}, users::{username_to_permissioned_as, SUPERADMIN_SECRET_EMAIL}, @@ -562,6 +563,14 @@ pub async fn run_error_handler< )); } } + if error_handler_path + .to_string() + .eq("hub/2431/slack/schedule-error-handler-slack") + { + // custom slack error handler being used -> we need to inject the slack token + let slack_resource = format!("$res:{WORKSPACE_SLACK_BOT_TOKEN_PATH}"); + extra.insert("slack".to_string(), to_raw_value(&slack_resource)); + } let tx = PushIsolationLevel::IsolatedRoot(db.clone(), rsmq);