mobilizon.chapril.org-mobil.../lib/mobilizon/actors/bot.ex
Thomas Citharel 00c8be4d8c
Fix an issue with default bot type value
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2021-04-08 10:39:02 +02:00

42 lines
825 B
Elixir

defmodule Mobilizon.Actors.Bot do
@moduledoc """
Represents a local bot.
"""
use Ecto.Schema
import Ecto.Changeset
alias Mobilizon.Actors.Actor
alias Mobilizon.Users.User
@type t :: %__MODULE__{
source: String.t(),
type: String.t(),
actor: Actor.t(),
user: User.t()
}
@required_attrs [:source]
@optional_attrs [:type, :actor_id, :user_id]
@attrs @required_attrs ++ @optional_attrs
schema "bots" do
field(:source, :string)
field(:type, :string, default: "ics")
belongs_to(:actor, Actor)
belongs_to(:user, User)
timestamps()
end
@doc false
@spec changeset(t, map) :: Ecto.Changeset.t()
def changeset(%__MODULE__{} = bot, attrs) do
bot
|> cast(attrs, @attrs)
|> validate_required(@required_attrs)
end
end