PhoenixKitInbox.Schemas.MailboxGrant (PhoenixKitInbox v0.2.0)

Copy Markdown View Source

Grants a user access to a mailbox they do not own.

Modelled on phoenix_kit_calendar's per-calendar view/edit permissions: the module-level "inbox" permission decides whether a user can use Inbox at all, and a grant decides which mailboxes they see inside it. A user's own kind: "user" mailbox needs no grant — ownership implies "admin" access.

Access levels, in increasing order:

  • "read" — open the mailbox, read messages, mark seen/starred
  • "write" — the above, plus compose and send as the mailbox, move/trash
  • "admin" — the above, plus manage the mailbox's own grants

Tables are created by PhoenixKitInbox.Migrations, never by this schema.

Summary

Functions

Whether held satisfies required.

Valid access levels, weakest first.

Types

t()

@type t() :: %PhoenixKitInbox.Schemas.MailboxGrant{
  __meta__: term(),
  access: term(),
  granted_by_uuid: term(),
  inserted_at: term(),
  mailbox_uuid: term(),
  updated_at: term(),
  user_uuid: term(),
  uuid: term()
}

Functions

covers?(held, required)

@spec covers?(String.t() | nil, String.t()) :: boolean()

Whether held satisfies required.

iex> PhoenixKitInbox.Schemas.MailboxGrant.covers?("admin", "write")
true
iex> PhoenixKitInbox.Schemas.MailboxGrant.covers?("read", "write")
false

levels()

@spec levels() :: [String.t()]

Valid access levels, weakest first.