"""Shared "who is an active, non-suspended account" predicate. Used wherever a user must be filtered out of a recipient list or rejected as a target: the download share-by-email and recipient-picker endpoints. Kept in one place so the two forms (SQL clauses for a query, Python check for a loaded row) can't drift apart, and so a route module doesn't have to import another route module just to reuse the rule. """ from app.models import User def messageable_clauses() -> list: """SQL clauses for "an active, non-suspended account" — splat into a recipient query.""" return [ User.is_active.is_(True), User.is_suspended.is_(False), ] def is_messageable_user(u: User | None) -> bool: """Python mirror of `messageable_clauses()` for an already-loaded row (a share recipient).""" return bool(u and u.is_active and not u.is_suspended)