Kantoor. Provisioning. CalendarSubscriptions
(Kantoor v1.0.0)
Subscribed calendars (Kantoor.Feeds) of a user, for the provisioning API: the
system that provisions a user can have them follow external iCalendar feeds. See
Kantoor.Provisioning for tenancy and idempotency.
A subscription is named by the caller's own reference under a user
(sub_ref, unique per user, so unique per operator), like users and domains are:
- creating it twice with the same feed is one subscription (
:existing, the settings of the repeat are ignored;update/4changes them); - the same reference with another feed is
:ref_conflict, never a silent change of which calendar a reference means; - two requests racing for one reference create one: the unique index in Postgres decides and the other finds it.
Only the subscriptions made through the API (they carry a reference) are listed and
reachable here; the ones a person made themselves in Settings, Calendars are not
the operator's. A user of another operator is :not_found. The feed address goes in
and never comes out: answers carry its host and the state of the subscription.
Kantoor has no calendars that belong to a domain, only to users (a domain is the customer and holds users and mailboxes), so there is no domain-level counterpart.
Summary
Functions
Removes the subscription with its calendar and events. Removing what is not there is :ok.
One subscription of the user.
The subscriptions the API made for the user.
Subscribes the user to the feed attrs["url"] under sub_ref, or returns the
subscription that exists. Other keys of attrs: "name", "color",
"refresh_minutes", "busy".
Changes the subscription: name, color, refresh_minutes, busy, paused, and
url (a new address for the same reference, for a feed whose address was renewed).
Functions
@spec delete(Kantoor.ApiKeys.ApiKey.t(), String.t(), String.t()) :: :ok
Removes the subscription with its calendar and events. Removing what is not there is :ok.
@spec get(Kantoor.ApiKeys.ApiKey.t(), String.t(), String.t()) :: {:ok, Kantoor.Feeds.Subscription.t()} | {:error, :not_found}
One subscription of the user.
@spec list(Kantoor.ApiKeys.ApiKey.t(), String.t()) :: {:ok, [Kantoor.Feeds.Subscription.t()]} | {:error, :not_found}
The subscriptions the API made for the user.
@spec put(Kantoor.ApiKeys.ApiKey.t(), String.t(), String.t(), map()) :: {:ok, Kantoor.Feeds.Subscription.t(), :created | :existing} | {:error, term()}
Subscribes the user to the feed attrs["url"] under sub_ref, or returns the
subscription that exists. Other keys of attrs: "name", "color",
"refresh_minutes", "busy".
{:ok, subscription, :created | :existing}, or {:error, reason}: :not_found
(user), :user_suspended, :ref_conflict, :vault_not_configured,
:subscription_limit, {:invalid, field, message} or a changeset.
@spec update(Kantoor.ApiKeys.ApiKey.t(), String.t(), String.t(), map()) :: {:ok, Kantoor.Feeds.Subscription.t()} | {:error, term()}
Changes the subscription: name, color, refresh_minutes, busy, paused, and
url (a new address for the same reference, for a feed whose address was renewed).