feat: BridgeType detection + UnifiedContact + ContactsDb (#47, #48, #49, #51) #138

Closed
charles wants to merge 5 commits from feat/47-49-51-bridge-foundation into main
Owner

Summary

Implements issues #47, #48, #49 and #51 in the fractal-bridge crate.

#47BridgeType::detect()

  • Rewrote bridge_type.rs with Serialize/Deserialize derives and Option-returning detect()
  • Added Instagram variant and Custom(String) for config-driven prefixes
  • Added detect_with_custom(), icon_name(), display_name()
  • 7 unit tests covering all main bridge types, human users, and custom prefixes

#48UnifiedContact + BridgedIdentity

  • Rewrote contact.rs with the canonical field names from the spec (matrix_user_id, external_id, external_username, primary_matrix_user_id, bridged_identities)
  • Both structs derive Serialize/Deserialize
  • BridgedIdentity::new() and UnifiedContact::{new, add_identity, bridge_types} helpers

#49 — Crate wiring

  • lib.rs now exposes contacts_db module and re-exports ContactsDb + default_db_path
  • Cargo.toml extended with serde_json, sqlx (workspace), dirs = "5"

#51 — SQLite CRUD

  • New contacts_db.rs with ContactsDb::open() (creates dir + tables), upsert_contact(), get_contact(), delete_contact()
  • DB path: ~/.local/share/fractal-plus/contacts.db
  • Tables: unified_contacts, bridged_identities (FK with ON DELETE CASCADE)
  • BridgeType round-tripped via serde_json in the bridge_type column

Test plan

  • cargo test -p fractal-bridge — all unit tests in bridge_type and contact pass
  • Manual smoke test: open a DB, upsert a contact with a Telegram identity, fetch it back, delete it
  • Verify ~/.local/share/fractal-plus/contacts.db is created at runtime with correct schema
## Summary Implements issues #47, #48, #49 and #51 in the `fractal-bridge` crate. ### #47 — `BridgeType::detect()` - Rewrote `bridge_type.rs` with `Serialize`/`Deserialize` derives and `Option`-returning `detect()` - Added `Instagram` variant and `Custom(String)` for config-driven prefixes - Added `detect_with_custom()`, `icon_name()`, `display_name()` - 7 unit tests covering all main bridge types, human users, and custom prefixes ### #48 — `UnifiedContact` + `BridgedIdentity` - Rewrote `contact.rs` with the canonical field names from the spec (`matrix_user_id`, `external_id`, `external_username`, `primary_matrix_user_id`, `bridged_identities`) - Both structs derive `Serialize`/`Deserialize` - `BridgedIdentity::new()` and `UnifiedContact::{new, add_identity, bridge_types}` helpers ### #49 — Crate wiring - `lib.rs` now exposes `contacts_db` module and re-exports `ContactsDb` + `default_db_path` - `Cargo.toml` extended with `serde_json`, `sqlx` (workspace), `dirs = "5"` ### #51 — SQLite CRUD - New `contacts_db.rs` with `ContactsDb::open()` (creates dir + tables), `upsert_contact()`, `get_contact()`, `delete_contact()` - DB path: `~/.local/share/fractal-plus/contacts.db` - Tables: `unified_contacts`, `bridged_identities` (FK with `ON DELETE CASCADE`) - `BridgeType` round-tripped via `serde_json` in the `bridge_type` column ## Test plan - [ ] `cargo test -p fractal-bridge` — all unit tests in `bridge_type` and `contact` pass - [ ] Manual smoke test: open a DB, upsert a contact with a Telegram identity, fetch it back, delete it - [ ] Verify `~/.local/share/fractal-plus/contacts.db` is created at runtime with correct schema
charles closed this pull request 2026-04-06 02:21:51 +00:00
Some checks are pending
CI / cargo check (pull_request) Has been cancelled
CI / cargo test (pull_request) Has been cancelled
CI / clippy + rustfmt (pull_request) Has been cancelled
qa
Required

Pull request closed

Sign in to join this conversation.
No description provided.