mobilizon/lib/mobilizon_web/controllers/participant_controller.ex
Thomas Citharel 559c889f1b Rename project to Mobilizon
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2018-10-11 17:37:39 +02:00

19 lines
534 B
Elixir

defmodule MobilizonWeb.ParticipantController do
@moduledoc """
Controller for participants to an event
"""
use MobilizonWeb, :controller
alias Mobilizon.Events
def join(conn, %{"uuid" => uuid}) do
with event <- Events.get_event_by_uuid(uuid),
%{actor: actor} <- Guardian.Plug.current_resource(conn) do
participant =
Events.create_participant(%{"event_id" => event.id, "actor_id" => actor.id, "role" => 1})
render(conn, "participant.json", %{participant: participant})
end
end
end