PhoenixKit.Mentions.AccessRequests (phoenix_kit v2.5.0)

Copy Markdown View Source

Asking to be let in to a record you were pointed at but cannot open.

A redacted mention says "there is something here you can't see". That is only worth showing if there is a next step, and this is the next step: the reader asks, the people who own the record decide.

Delivery reuses the activity → notification bridge, so a request arrives wherever the recipient already reads things — inbox, email, Telegram — with no new plumbing. Deciding is deliberately NOT automated: granting access means writing to whatever the owning module calls membership, and core has no business guessing that. The module handles the decision and calls grant/2 or deny/2 to close the loop.

Summary

Functions

The requester withdrawing their own ask.

Closes a request as denied, and tells the requester.

The open request from this person for this record, if any.

Closes a request as granted.

Every open request across all records — the admin queue.

Open requests for a record — the owner's queue.

Records a request, or returns the one already open.

Functions

cancel(request)

The requester withdrawing their own ask.

deny(request, decided_by_uuid)

Closes a request as denied, and tells the requester.

get_open(resource_type, resource_uuid, requester_uuid)

@spec get_open(String.t(), String.t(), String.t()) ::
  PhoenixKit.Mentions.AccessRequest.t() | nil

The open request from this person for this record, if any.

grant(request, decided_by_uuid)

@spec grant(PhoenixKit.Mentions.AccessRequest.t(), String.t() | nil) ::
  {:ok, PhoenixKit.Mentions.AccessRequest.t()} | {:error, term()}

Closes a request as granted.

Does NOT itself give anyone access: the owning module knows what its own membership means and does that part. This records the decision and tells the requester.

list_all_pending(opts \\ [])

@spec list_all_pending(keyword()) :: [PhoenixKit.Mentions.AccessRequest.t()]

Every open request across all records — the admin queue.

list_pending(resource_type, resource_uuid)

@spec list_pending(String.t(), String.t()) :: [PhoenixKit.Mentions.AccessRequest.t()]

Open requests for a record — the owner's queue.

request(resource_type, resource_uuid, requester_uuid, opts \\ [])

@spec request(String.t(), String.t(), String.t(), keyword()) ::
  {:ok, PhoenixKit.Mentions.AccessRequest.t()} | {:error, term()}

Records a request, or returns the one already open.

Asking twice is the same ask — the partial unique index enforces it, and this returns {:ok, existing} rather than an error so the UI can say "already asked" without a special case.

Rejects unknown resource_types, non-uuid targets, and accounts that have already submitted too many requests in the window — the chip only ever sends a type the renderer already resolved, so anything else is a client composing its own payload.