Kantoor.Contacts (Kantoor v1.0.0)

Contacts (vCards) for the signed-in user, stored in the user's address books by Kantoor.Dav.Local - the same resources a CardDAV client syncs. Editing keeps every vCard property the form does not manage (photo, addresses, X- fields), so contacts made on a phone survive a round trip. Every function takes a Kantoor.Accounts.Scope and only touches that user's data and the address books shared with them.

Address books shared with the user (Kantoor.Sharing) are listed next to their own. The permission is read from the database on every call and checked again by Kantoor.Dav.Local, as on the DAV path: with a read-only share a contact cannot be created, changed or deleted ({:error, :forbidden}).

Summary

Functions

The user's address books.

Creates a contact. attrs (string keys): "name" (required), "emails" and "phones" (one per line or comma-separated), "urls" (one per line), "org", "title", "notes", "birthday" (any form Kantoor.Contacts.Birthday reads; with "birthday_no_year" set to "true" the year is dropped), "book". On update/3 a key that is left out keeps the card's title, urls and birthday; an empty value removes them.

Deletes a contact. {:error, :forbidden} in a read-only shared address book.

One of the user's contacts.

The user's contacts by name. Options: :q filters by text in any field, :book limits to one address book (its ref: slug, or shared-<id>).

Updates a contact, keeping the vCard properties the form does not manage.

The address books as Kantoor.Dav.Views: the user's own, then those shared with them.

Types

scope()

@type scope() :: Kantoor.Accounts.Scope.t() | nil

Functions

books(arg1)

@spec books(scope()) :: [Kantoor.Dav.Collection.t()]

The user's address books.

create(scope, attrs)

@spec create(scope(), map()) ::
  {:ok, Kantoor.Contacts.Contact.t()} | {:error, [String.t()]}

Creates a contact. attrs (string keys): "name" (required), "emails" and "phones" (one per line or comma-separated), "urls" (one per line), "org", "title", "notes", "birthday" (any form Kantoor.Contacts.Birthday reads; with "birthday_no_year" set to "true" the year is dropped), "book". On update/3 a key that is left out keeps the card's title, urls and birthday; an empty value removes them.

delete(arg1, id)

@spec delete(scope(), term()) :: :ok | {:error, :not_found | :forbidden}

Deletes a contact. {:error, :forbidden} in a read-only shared address book.

get(arg1, id)

@spec get(scope(), term()) ::
  {:ok, Kantoor.Contacts.Contact.t()} | {:error, :not_found}

One of the user's contacts.

list(scope, opts \\ [])

@spec list(scope(), keyword()) :: [Kantoor.Contacts.Contact.t()]

The user's contacts by name. Options: :q filters by text in any field, :book limits to one address book (its ref: slug, or shared-<id>).

update(scope, id, attrs)

@spec update(scope(), term(), map()) ::
  {:ok, Kantoor.Contacts.Contact.t()}
  | {:error, [String.t()] | :not_found | :forbidden}

Updates a contact, keeping the vCard properties the form does not manage.

views(arg1)

@spec views(scope()) :: [Kantoor.Dav.View.t()]

The address books as Kantoor.Dav.Views: the user's own, then those shared with them.