Kantoor. Dav. Itip
(Kantoor v1.0.0)
iTIP over email (iMIP, RFC 6047) for CalDAV scheduling.
Sending
deliver/4 is the store's deliver_itip/4: for an attendee (or organiser, for
a reply) that Kantoor does not host it builds an iMIP message with
build_imip/2 and hands it to Kantoor.Karta.Client.send_raw/2. It returns
:queued when Karta accepted the message for sending, {:error, :invalid_address} for a malformed address and {:error, reason} otherwise.
Only the calendar user themselves can send: the ORGANIZER of a
REQUEST/CANCEL, or the replying ATTENDEE of a REPLY, must be one of the
authenticated user's own addresses. A collection shared with a user is
scheduled for its owner by the DAV library, so a read-write grantee changing
an event the owner organises would otherwise have the owner's invitation (or
cancellation) mailed from the grantee's own mailbox; that is refused with
{:error, :no_scheduling} (SCHEDULE-STATUS 5.3 on the owner's copy) and
nothing is sent. (Attendees on this server still get the library's own inbox
delivery; the in-app writers never run scheduling for shared collections.)
The sender is one of the user's attached mailboxes (the one named by
ORGANIZER/ATTENDEE when it is theirs, else the first), so the From can
differ from the calendar user address inside the invitation.
Receiving
receive_mail/2 applies an iTIP message that arrived as mail, through
Scheduling.receive_itip/4, only when the sender passed
authentication.
What is verified, and what is not:
- The verdict comes from the
auth_resultsKarta put in its push (Kantoor.Karta.InboundPayload). The message's ownAuthentication-Resultsheader is never read: the sender controls it. - A message passes when the From domain is authenticated:
dmarc=pass, ordkim=pass/spf=passfor a domain aligned (equal or sub/parent domain) with the From domain. No verdict, a failed verdict, or one about a different From domain means the mail is left alone in the inbox. - The sender handed to the DAV library is the
Fromaddress. Domain authentication does not prove the local part: anyone who can send as the authenticated domain can claim to be any organiser at that domain. A mailing list'sFromis not the organiser; the library rejects a message whose organiser/attendee is not that sender. - The recipient must belong to exactly one active Kantoor user (their sign-in email, or a mailbox attached to just them); shared mailboxes are skipped.
- Messages are never hidden or changed: an applied invitation also stays in
the inbox as ordinary mail. Unsupported methods (
COUNTER,PUBLISH...) and malformed calendars are left as plain mail.
Summary
Functions
Builds the iMIP message for an iTIP document.
The first text/calendar part of a parsed message whose method parameter is
REQUEST, REPLY or CANCEL: {:ok, method, ics}, else {:skipped, :no_itip}.
The store's scheduling-to-outsiders callback.
Runs receive_mail/2 for a freshly stored message, never raising. Emits
[:kantoor, :dav, :itip, :received] with %{result: :applied | :skipped | :error, reason: term} metadata. Mail without a text/calendar part is ignored cheaply.
Applies the iTIP part of a received message, if it was authenticated.
The authentication verdict for a From address given the push's auth_results
(see Kantoor.Karta.InboundPayload): :pass, :fail or :none (no verdict).
Types
Functions
Builds the iMIP message for an iTIP document.
multipart/mixed holding multipart/alternative (a text/plain summary and
the text/calendar; method=... part) and the document again as an .ics
attachment. Options: :from, :to (bare addresses, required), :from_name,
:now, :locale (the language of the subject and the summary; the default
locale when absent).
@spec calendar_part(Mail.Message.t()) :: {:ok, String.t(), binary()} | {:skipped, :no_itip}
The first text/calendar part of a parsed message whose method parameter is
REQUEST, REPLY or CANCEL: {:ok, method, ics}, else {:skipped, :no_itip}.
@spec deliver(String.t(), binary(), String.t(), map()) :: :queued | {:error, :invalid_address | term()}
The store's scheduling-to-outsiders callback.
@spec process_ingested(Kantoor.Mailboxes.Message.t(), binary() | nil) :: :ok
Runs receive_mail/2 for a freshly stored message, never raising. Emits
[:kantoor, :dav, :itip, :received] with %{result: :applied | :skipped | :error, reason: term} metadata. Mail without a text/calendar part is ignored cheaply.
@spec receive_mail(Kantoor.Mailboxes.Message.t(), binary() | Mail.Message.t()) :: outcome()
Applies the iTIP part of a received message, if it was authenticated.
message is the stored Kantoor.Mailboxes.Message (recipient, envelope and the
push's auth_results); raw is the RFC 822 source, or its parse tree from
Kantoor.Mime.parse_tree/1.
{:ok, received}- applied to the recipient's calendar;{:skipped, reason}- not applicable or not authenticated (:no_itip,:no_verdict,:unauthenticated,:no_sender,:unknown_recipient,:ambiguous_recipient); the mail is untouched either way;{:error, reason}- the DAV library refused it (:forged_sender,:unknown_uid,:stale_sequence, ...).
The authentication verdict for a From address given the push's auth_results
(see Kantoor.Karta.InboundPayload): :pass, :fail or :none (no verdict).