storkit: merge 393_story_pipeline_stage_notifications_for_whatsapp_and_slack_transports
This commit is contained in:
@@ -250,6 +250,10 @@ async fn main() -> Result<(), std::io::Error> {
|
||||
|
||||
// Clone watcher_tx for the Matrix bot before it is moved into AppContext.
|
||||
let watcher_tx_for_bot = watcher_tx.clone();
|
||||
// Subscribe to watcher events for WhatsApp/Slack notification listeners
|
||||
// before watcher_tx is moved into AppContext.
|
||||
let watcher_rx_for_whatsapp = watcher_tx.subscribe();
|
||||
let watcher_rx_for_slack = watcher_tx.subscribe();
|
||||
// Wrap perm_rx in Arc<Mutex> so it can be shared with both the WebSocket
|
||||
// handler (via AppContext) and the Matrix bot.
|
||||
let perm_rx = Arc::new(tokio::sync::Mutex::new(perm_rx));
|
||||
@@ -413,6 +417,31 @@ async fn main() -> Result<(), std::io::Error> {
|
||||
drop(matrix_shutdown_rx);
|
||||
}
|
||||
|
||||
// Spawn stage-transition notification listeners for WhatsApp and Slack.
|
||||
// These mirror the listener that the Matrix bot spawns internally.
|
||||
if let (Some(ctx), Some(root)) = (&whatsapp_ctx, &startup_root) {
|
||||
let ambient_rooms = Arc::clone(&ctx.ambient_rooms);
|
||||
chat::transport::matrix::notifications::spawn_notification_listener(
|
||||
Arc::clone(&ctx.transport),
|
||||
move || ambient_rooms.lock().unwrap().iter().cloned().collect(),
|
||||
watcher_rx_for_whatsapp,
|
||||
root.clone(),
|
||||
);
|
||||
} else {
|
||||
drop(watcher_rx_for_whatsapp);
|
||||
}
|
||||
if let (Some(ctx), Some(root)) = (&slack_ctx, &startup_root) {
|
||||
let channel_ids: Vec<String> = ctx.channel_ids.iter().cloned().collect();
|
||||
chat::transport::matrix::notifications::spawn_notification_listener(
|
||||
Arc::clone(&ctx.transport) as Arc<dyn crate::chat::ChatTransport>,
|
||||
move || channel_ids.clone(),
|
||||
watcher_rx_for_slack,
|
||||
root.clone(),
|
||||
);
|
||||
} else {
|
||||
drop(watcher_rx_for_slack);
|
||||
}
|
||||
|
||||
// On startup:
|
||||
// 1. Reconcile any stories whose agent work was committed while the server was
|
||||
// offline (worktree has commits ahead of master but pipeline didn't advance).
|
||||
|
||||
Reference in New Issue
Block a user