1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-23 16:33:28 +00:00
mobilizon/lib/mix/tasks/create_bot.ex
Thomas Citharel cac4dd3ca3
Search
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2018-06-06 18:16:14 +02:00

21 lines
571 B
Elixir

defmodule Mix.Tasks.CreateBot do
use Mix.Task
alias Eventos.Actors
alias Eventos.Actors.Bot
alias Eventos.Repo
import Logger
@shortdoc "Register user"
def run([email, name, summary, type, url]) do
Mix.Task.run("app.start")
with user <- Actors.find_by_email(email),
actor <- Actors.register_bot_account(%{name: name, summary: summary}),
{:ok, %Bot{} = bot} <- Actors.create_bot(%{"type" => type, "source" => url, "actor_id" => actor.id, "user_id" => user.id}) do
bot
else
e -> Logger.error(inspect e)
end
end
end