story-kit: merge 316_refactor_abstract_bot_transport_layer_for_multi_platform_support

This commit is contained in:
Dave
2026-03-19 20:43:38 +00:00
parent 3b9cea22bb
commit 7eb9686bfb
10 changed files with 510 additions and 163 deletions

View File

@@ -6,10 +6,9 @@
use crate::io::story_metadata::parse_front_matter;
use crate::io::watcher::WatcherEvent;
use crate::slog;
use matrix_sdk::ruma::events::room::message::RoomMessageEventContent;
use matrix_sdk::ruma::OwnedRoomId;
use matrix_sdk::Client;
use crate::transport::ChatTransport;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use tokio::sync::broadcast;
/// Human-readable display name for a pipeline stage directory.
@@ -100,10 +99,11 @@ pub fn format_error_notification(
}
/// Spawn a background task that listens for watcher events and posts
/// stage-transition notifications to all configured Matrix rooms.
/// stage-transition notifications to all configured rooms via the
/// [`ChatTransport`] abstraction.
pub fn spawn_notification_listener(
client: Client,
room_ids: Vec<OwnedRoomId>,
transport: Arc<dyn ChatTransport>,
room_ids: Vec<String>,
watcher_rx: broadcast::Receiver<WatcherEvent>,
project_root: PathBuf,
) {
@@ -133,14 +133,10 @@ pub fn spawn_notification_listener(
slog!("[matrix-bot] Sending stage notification: {plain}");
for room_id in &room_ids {
if let Some(room) = client.get_room(room_id) {
let content =
RoomMessageEventContent::text_html(plain.clone(), html.clone());
if let Err(e) = room.send(content).await {
slog!(
"[matrix-bot] Failed to send notification to {room_id}: {e}"
);
}
if let Err(e) = transport.send_message(room_id, &plain, &html).await {
slog!(
"[matrix-bot] Failed to send notification to {room_id}: {e}"
);
}
}
}
@@ -159,14 +155,10 @@ pub fn spawn_notification_listener(
slog!("[matrix-bot] Sending error notification: {plain}");
for room_id in &room_ids {
if let Some(room) = client.get_room(room_id) {
let content =
RoomMessageEventContent::text_html(plain.clone(), html.clone());
if let Err(e) = room.send(content).await {
slog!(
"[matrix-bot] Failed to send error notification to {room_id}: {e}"
);
}
if let Err(e) = transport.send_message(room_id, &plain, &html).await {
slog!(
"[matrix-bot] Failed to send error notification to {room_id}: {e}"
);
}
}
}