Tayori.Reader (Tayori v0.1.0)

Copy Markdown View Source

Who reads the news, as the app knows them. The app's resolver builds it from the app's own user (Tayori.Resolver.resolve_reader/1):

%Tayori.Reader{
  id: "user:#{user.id}",
  segments: ["plan:#{user.plan}", "role:#{user.role}"],
  locale: user.locale,
  since: user.inserted_at
}
  • :id - a stable key of the reader, where Tayori keeps when they last saw the news. Nil for a visitor: the news shows, nothing is unread.
  • :segments - what the reader is, in the words of the app. An entry for segments shows to readers in at least one of them.
  • :locale - the language to show the news in, when the entry has it.
  • :since - entries published before this time are never unread, so that a new account does not start with all the news of the past.

Summary

Functions

A visitor: no id, no segments. They see the entries for everyone.

Types

t()

@type t() :: %Tayori.Reader{
  id: String.t() | nil,
  locale: String.t() | nil,
  segments: [String.t()],
  since: DateTime.t() | nil
}

Functions

visitor(locale \\ nil)

@spec visitor(String.t() | nil) :: t()

A visitor: no id, no segments. They see the entries for everyone.

Examples

iex> Tayori.Reader.visitor("pt-PT")
%Tayori.Reader{id: nil, segments: [], locale: "pt-PT", since: nil}