2018-05-18 09:56:21 +02:00
|
|
|
defmodule Eventos.Actors.Follower do
|
|
|
|
@moduledoc """
|
|
|
|
Represents the following of an actor to another actor
|
|
|
|
"""
|
|
|
|
use Ecto.Schema
|
|
|
|
import Ecto.Changeset
|
|
|
|
alias Eventos.Actors.Follower
|
|
|
|
alias Eventos.Actors.Actor
|
|
|
|
|
|
|
|
schema "followers" do
|
2018-07-27 10:45:35 +02:00
|
|
|
field(:approved, :boolean, default: false)
|
|
|
|
field(:score, :integer, default: 1000)
|
|
|
|
belongs_to(:target_actor, Actor)
|
|
|
|
belongs_to(:actor, Actor)
|
2018-05-18 09:56:21 +02:00
|
|
|
|
|
|
|
timestamps()
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc false
|
|
|
|
def changeset(%Follower{} = member, attrs) do
|
|
|
|
member
|
|
|
|
|> cast(attrs, [:role, :approved, :target_actor_id, :actor_id])
|
|
|
|
|> validate_required([:role, :approved, :target_actor_id, :actor_id])
|
|
|
|
end
|
|
|
|
end
|