Kantoor.Feeds.Parser (Kantoor v1.0.0)

Turns the body of a feed into the calendar objects Kantoor stores: one object per UID, holding the event, all its overrides (RECURRENCE-ID, cancelled instances included) and the VTIMEZONEs it uses, as a CalDAV client expects to find them.

Uses the same iCalendar code as the rest of Kantoor (Kantoor.Dav.Ical). What it does to a feed:

  • keeps only VEVENTs (tasks and journals in a feed are ignored) that have a readable DTSTART; the others are counted in skipped;
  • drops the calendar-level METHOD (a stored calendar object must not carry one, RFC 4791 section 4.1) and the X-WR-* and refresh hints, keeping VERSION and PRODID;
  • keeps STATUS:CANCELLED events and instances as they are: a cancelled instance stays in the series so the occurrence is not generated;
  • gives an event without a UID a stable one derived from its content;
  • rewrites a TZID that is not a known time zone name to the one it stands for when the feed says so (X-LIC-LOCATION in its VTIMEZONE) or it is a common Windows zone name, so an Outlook or libical feed shows at the right hour;
  • names each object after its UID (made safe), so the same event keeps the same name on every fetch and CalDAV clients see changes, not replacements.

A feed that is not iCalendar is {:error, "not_calendar"}; one with more than 5000 events is {:error, "too_many_events"}. Nothing is stored here.

Summary

Functions

Parses body. See the module doc.

Types

object()

@type object() :: %{name: String.t(), uid: String.t(), body: binary()}

Functions

parse(body)

@spec parse(binary()) ::
  {:ok, %{objects: [object()], skipped: non_neg_integer()}}
  | {:error, String.t()}

Parses body. See the module doc.