2019-03-08 12:25:06 +01:00
|
|
|
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
|
2019-03-08 18:52:27 +01:00
|
|
|
schema "feed_tokens" do
|
|
|
|
field(:token, Ecto.UUID, primary_key: true)
|
2019-03-08 12:25:06 +01:00
|
|
|
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
|