# `Laev.Account`
[🔗](https://github.com/alexdont/laev/blob/main/lib/laev/account.ex#L1)

Is the debrid subscription still good?

Every source laev plays goes through Real-Debrid or TorBox, and when the
subscription behind them lapses the APIs stop resolving — a user whose plan
ran out mid-session watched laev try source after source, each one answered
the same way, with nothing on screen to say why. The answer was one request
away the whole time: both providers report their own expiry date.

So it is asked once a day and remembered. Once a day rather than once a
session because a session can outlive the subscription: laev left open in a
window overnight is laev holding an answer from yesterday, which is exactly
how somebody ends up staring at failures for a plan that expired at midnight.
The cache is keyed by the local date — when the date changes, the answer is
stale by definition, whether the app has been running for ten minutes or a
month.

Nothing here blocks on the network where a screen is waiting: `ensure/0` is
called at the edges (launch, and before a source search), and everything in
the hot path reads `blocked/0`, which only ever consults what is already
known.

# `blocked`

What is already known, without asking anyone: `{:expired, detail}` or nil.

For the paths that run per source, where a request would be both slow and
pointless. An unchecked or unreachable account is not blocked — being unsure
is never a reason to refuse to play something.

# `ensure`

The subscription state, checked at most once a day: `:ok`, `{:expired,
detail}` when a provider says the plan has lapsed, or `{:unknown, detail}`
when nothing could be reached — which is not the same thing and must never be
treated as one. A network laev can't reach is a network the provider can't be
asked about.

# `forget`

Forget what was checked — for tests, and for a key that just changed.

# `refresh`

Ask the providers now, whatever is remembered.

# `warm`

Check in the background, for the moments worth knowing early.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
