story-kit: merge 324_story_slack_bot_integration_for_bot_commands
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user