debianize-mobilizon/lib/mobilizon/events/feed_token.ex
Thomas Citharel 99ac6ef100
Add GraphQL support to handle FeedTokens
Closes #88

Automatically create tokens for new users and actors

Closes #89

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2019-03-08 18:52:27 +01:00

27 lines
639 B
Elixir

defmodule Mobilizon.Events.FeedToken do
@moduledoc """
Represents a Token for a Feed of events
"""
use Ecto.Schema
import Ecto.Changeset
alias Mobilizon.Events.FeedToken
alias Mobilizon.Actors.Actor
alias Mobilizon.Users.User
@primary_key false
schema "feed_tokens" do
field(:token, Ecto.UUID, primary_key: true)
belongs_to(:actor, Actor)
belongs_to(:user, User)
timestamps(updated_at: false)
end
@doc false
def changeset(%FeedToken{} = feed_token, attrs) do
feed_token
|> Ecto.Changeset.cast(attrs, [:token, :actor_id, :user_id])
|> validate_required([:token, :user_id])
end
end