PhoenixKitSync.Web.ConnectionsLive.Status (PhoenixKitSync v0.1.2)

Copy Markdown View Source

Status-resolution and connection-verification helpers for the Connections LiveView.

The LiveView spawns linked tasks that call into this module when it mounts or reloads the connections list:

  • fetch_sender_statuses/1 — for each receiver connection, asks the remote site's /sync/api/status endpoint whether this site's paired sender is still reachable, sending {:sender_status_fetched, uuid, status} back to the LV once the HTTP round-trip completes.
  • verify_receiver_connections/1 — for each sender connection we've previously handed off credentials to, asks the remote receiver whether the connection record still exists; sends {:receiver_connection_severed, uuid} when the remote says "no such connection," which the LV turns into a local suspend.

Both are display-only — the tasks die with the LiveView via Task.start_link/1.

Extracted from ConnectionsLive in 2026-04 to shrink the LiveView module without changing behavior. Task supervision semantics and message shapes are unchanged; the LV still owns the handle_info clauses that process the results.

Summary

Functions

For each receiver connection, fetches the paired sender's status from the remote site in a linked task. Result is sent back to the caller as {:sender_status_fetched, connection_uuid, status_string}.

For each sender connection we've previously propagated to a remote receiver, verifies the connection record still exists there. Sends {:receiver_connection_severed, uuid} when the remote returns not-found; logs but doesn't send on other failure modes (offline / transport error are treated as transient).

Functions

fetch_sender_statuses(receiver_connections, pid \\ self())

@spec fetch_sender_statuses(list(), pid()) :: :ok

For each receiver connection, fetches the paired sender's status from the remote site in a linked task. Result is sent back to the caller as {:sender_status_fetched, connection_uuid, status_string}.

Status strings: "active", "suspended", "revoked", "pending" (from the remote), or "offline" / "not_found" / "error" (from failure modes).

verify_receiver_connections(sender_connections, pid \\ self())

@spec verify_receiver_connections(list(), pid()) :: :ok

For each sender connection we've previously propagated to a remote receiver, verifies the connection record still exists there. Sends {:receiver_connection_severed, uuid} when the remote returns not-found; logs but doesn't send on other failure modes (offline / transport error are treated as transient).