mirror of
https://github.com/spartanz51/tutabridge.git
synced 2026-06-24 10:54:32 +02:00
Wire event bus into the CLI binary
The CLI (`src/main.rs`) only spawned the syncer + IMAP + SMTP servers and never started an `EventBusClient` — so the realtime push the GUI's `BridgeHandle` ships had no effect when running `cargo run` or the headless binary. Mails that arrived after a bootstrap sync were silently missed until the next restart with a forced full re-sync; that's the irritant that triggered today's WS heartbeat/timeout audit. Replicate the bridge.rs initialisation directly: build an `EventBusClient`, hydrate `last_batch_ids` from `event_bus_state` (with the same 44-day expiration guard), spawn `bus_client.run` alongside the syncer and an `event_handler::run_event_handler` to consume the mpsc, and log WsState transitions at INFO so reconnect storms are visible without `RUST_LOG=debug`. Shutdown aborts the bus + handler handles in the same Ctrl-C arm as the syncer. To avoid duplicating the model-version + client-name plumbing, the helpers `bridge::sys_model_version`, `bridge::tutanota_model_version` and `bridge::CLIENT_NAME` are now public, and the root crate gains a direct `tuta-sdk` dependency (already present transitively through `tutabridge-core`).
This commit is contained in:
@@ -9,7 +9,7 @@ use crate::tuta::{self, MailBackend, TwoFactorCallback};
|
||||
use crate::{imap, smtp, tls};
|
||||
|
||||
/// Identifier the server uses for telemetry/rate-limit bucketing.
|
||||
const CLIENT_NAME: &str = "tutabridge";
|
||||
pub const CLIENT_NAME: &str = "tutabridge";
|
||||
|
||||
// Tuta `modelVersions=` for the event-bus URL. Read at compile-time from the
|
||||
// vendored SDK's type-model JSONs so the values track the submodule bump
|
||||
@@ -32,13 +32,13 @@ fn parse_model_version(json: &str) -> u32 {
|
||||
.expect("type model JSON has no version field")
|
||||
}
|
||||
|
||||
fn sys_model_version() -> u32 {
|
||||
pub fn sys_model_version() -> u32 {
|
||||
static V: std::sync::LazyLock<u32> =
|
||||
std::sync::LazyLock::new(|| parse_model_version(SYS_TYPE_MODELS_JSON));
|
||||
*V
|
||||
}
|
||||
|
||||
fn tutanota_model_version() -> u32 {
|
||||
pub fn tutanota_model_version() -> u32 {
|
||||
static V: std::sync::LazyLock<u32> =
|
||||
std::sync::LazyLock::new(|| parse_model_version(TUTANOTA_TYPE_MODELS_JSON));
|
||||
*V
|
||||
|
||||
Reference in New Issue
Block a user