Simplify Telegram channel config with host-injected tunnel/webhook settings

The WASM channel no longer needs its own polling_enabled/tunnel_url settings.
Instead, the host injects tunnel_url and webhook_secret into the channel config
at runtime before start() is called.

Changes:
- Add update_config() method to WasmChannel for runtime config injection
- Simplify TelegramConfig to only have bot_username, respond_to_all_group_messages
- Host injects tunnel_url (from Settings) and webhook_secret (from secrets store)
- Channel checks if tunnel_url is present to determine webhook vs polling mode
- Add delete_webhook() for clean transition to polling mode when no tunnel

Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
Illia Polosukhin
2026-02-05 00:05:32 -08:00
co-authored by Claude Opus 4.5
parent e6946172f7
commit 9edc666ee3
3 changed files with 141 additions and 36 deletions
+31 -1
View File
@@ -399,6 +399,36 @@ async fn main() -> anyhow::Result<()> {
let channel_arc = Arc::new(loaded.channel);
// Inject runtime config into the channel (tunnel_url, webhook_secret)
// This must be done before start() is called
{
let mut config_updates = std::collections::HashMap::new();
if let Some(ref tunnel_url) = config.tunnel.public_url {
config_updates.insert(
"tunnel_url".to_string(),
serde_json::Value::String(tunnel_url.clone()),
);
}
if let Some(ref secret) = webhook_secret {
config_updates.insert(
"webhook_secret".to_string(),
serde_json::Value::String(secret.clone()),
);
}
if !config_updates.is_empty() {
channel_arc.update_config(config_updates).await;
tracing::info!(
channel = %channel_name,
has_tunnel = config.tunnel.public_url.is_some(),
has_webhook_secret = webhook_secret.is_some(),
"Injected runtime config into channel"
);
}
}
tracing::info!(
channel = %channel_name,
has_webhook_secret = webhook_secret.is_some(),
@@ -410,7 +440,7 @@ async fn main() -> anyhow::Result<()> {
.register(
Arc::clone(&channel_arc),
endpoints,
webhook_secret,
webhook_secret.clone(),
secret_header,
)
.await;