feat(routines): deliver notifications to all installed channels (#398)

* feat(routines): deliver notifications to all installed channels

Routine notifications were silently lost because the forwarder didn't
use NotifyConfig fields and WASM channels (Telegram, Slack) had
broadcast() as a no-op. This fixes three issues:

1. send_notification() now includes notify_user/notify_channel in
   metadata so the forwarder can route to specific channels
2. The routine forwarder mirrors the heartbeat pattern: try targeted
   channel first, fall back to broadcast_all
3. WasmChannel implements broadcast() using last-seen message metadata
   (chat_id), with persistence to the settings table so it survives
   restarts. Only writes to DB when the value actually changes.

Heartbeat notifications also benefit from the WASM broadcast fix.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* refactor(wasm): extract do_update_broadcast_metadata to eliminate duplication

The inline metadata-update block in `dispatch_emitted_messages` was
identical to the `update_broadcast_metadata` instance method. Extract
the shared logic into a private free function `do_update_broadcast_metadata`
that both call, so the persistence logic lives in one place.

Addresses Gemini code review comment on PR #398.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
Henry Park
2026-02-27 12:01:32 -08:00
committed by GitHub
co-authored by Claude Sonnet 4.6
parent a65b282066
commit 601d73d16b
8 changed files with 205 additions and 14 deletions
+7 -2
View File
@@ -1786,8 +1786,13 @@ impl ExtensionManager {
None
};
let loader =
WasmChannelLoader::new(Arc::clone(&channel_runtime), Arc::clone(&pairing_store));
let settings_store: Option<Arc<dyn crate::db::SettingsStore>> =
self.store.as_ref().map(|db| Arc::clone(db) as _);
let loader = WasmChannelLoader::new(
Arc::clone(&channel_runtime),
Arc::clone(&pairing_store),
settings_store,
);
let loaded = loader
.load_from_files(name, &wasm_path, cap_path_option)
.await