huskies: merge 644_story_chat_transport_consumers_slack_discord_whatsapp_matrix_for_the_unified_status_broadcaster
This commit is contained in:
@@ -233,6 +233,42 @@ pub async fn run_bot(
|
||||
watcher_rx_auto,
|
||||
);
|
||||
|
||||
// Subscribe to the status broadcaster if the matrix_status_consumer toggle is
|
||||
// enabled (default: true). The subscriber formats each StatusEvent via the
|
||||
// common formatter and sends the resulting text to all configured Matrix rooms.
|
||||
// The task exits automatically when the broadcaster is dropped (channel closed)
|
||||
// on bot shutdown.
|
||||
{
|
||||
use crate::config::ProjectConfig;
|
||||
use crate::service::status::format::format_status_event;
|
||||
|
||||
let status_enabled = ProjectConfig::load(project_root)
|
||||
.map(|c| c.matrix_status_consumer)
|
||||
.unwrap_or(true);
|
||||
|
||||
if status_enabled {
|
||||
let mut sub = services.status.subscribe();
|
||||
let status_transport = Arc::clone(&transport);
|
||||
let status_rooms: Vec<String> =
|
||||
announce_room_ids.iter().map(|r| r.to_string()).collect();
|
||||
tokio::spawn(async move {
|
||||
while let Some(event) = sub.recv().await {
|
||||
let plain = format_status_event(&event);
|
||||
let html = markdown_to_html(&plain);
|
||||
for room_id in &status_rooms {
|
||||
if let Err(e) = status_transport.send_message(room_id, &plain, &html).await
|
||||
{
|
||||
crate::slog!(
|
||||
"[matrix-bot] Failed to send status event to {room_id}: {e}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
crate::slog!("[matrix-bot] Status subscriber task exiting — broadcaster dropped");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let ctx = BotContext {
|
||||
services,
|
||||
matrix_user_id: bot_user_id,
|
||||
|
||||
Reference in New Issue
Block a user