Kantoor.MailboxEvents (Kantoor v1.0.0)

Live-update notifications on Phoenix.PubSub topic mailbox:<id>.

Events carry ids only, never message content: receivers re-read what they need (the database stays the source of truth). Shape: {:mailbox_event, %{kind: :new | :updated | :removed, mailbox_id:, folder_id:, message_id:}}.

Summary

Functions

Broadcasts that message was added, changed or removed (folder_id overrides its folder).

Types

kind()

@type kind() :: :new | :updated | :removed

Functions

broadcast(kind, message, opts \\ [])

@spec broadcast(kind(), struct(), keyword()) :: :ok

Broadcasts that message was added, changed or removed (folder_id overrides its folder).

subscribe(mailbox_id)

@spec subscribe(Ecto.UUID.t()) :: :ok | {:error, term()}

topic(mailbox_id)

@spec topic(Ecto.UUID.t()) :: String.t()

unsubscribe(mailbox_id)

@spec unsubscribe(Ecto.UUID.t()) :: :ok