story-kit: merge 324_story_slack_bot_integration_for_bot_commands

This commit is contained in:
Dave
2026-03-20 01:09:55 +00:00
parent 4fe61c643b
commit 09890b5ea4
7 changed files with 1380 additions and 5 deletions

View File

@@ -29,6 +29,7 @@ use settings::SettingsApi;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use crate::slack::SlackWebhookContext;
use crate::whatsapp::WhatsAppWebhookContext;
const DEFAULT_PORT: u16 = 3001;
@@ -56,6 +57,7 @@ pub fn remove_port_file(path: &Path) {
pub fn build_routes(
ctx: AppContext,
whatsapp_ctx: Option<Arc<WhatsAppWebhookContext>>,
slack_ctx: Option<Arc<SlackWebhookContext>>,
) -> impl poem::Endpoint {
let ctx_arc = std::sync::Arc::new(ctx);
@@ -87,6 +89,13 @@ pub fn build_routes(
);
}
if let Some(sl_ctx) = slack_ctx {
route = route.at(
"/webhook/slack",
post(crate::slack::webhook_receive).data(sl_ctx),
);
}
route.data(ctx_arc)
}
@@ -196,6 +205,6 @@ mod tests {
fn build_routes_constructs_without_panic() {
let tmp = tempfile::tempdir().unwrap();
let ctx = context::AppContext::new_test(tmp.path().to_path_buf());
let _endpoint = build_routes(ctx, None);
let _endpoint = build_routes(ctx, None, None);
}
}