mobilizon/lib/mobilizon_web/controllers/search_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

24 lines
536 B
Elixir

defmodule MobilizonWeb.SearchController do
@moduledoc """
Controller for Search
"""
use MobilizonWeb, :controller
alias Mobilizon.Events
alias Mobilizon.Actors
action_fallback(MobilizonWeb.FallbackController)
def search(conn, %{"name" => name}) do
events = Events.find_events_by_name(name)
# find already saved accounts
case Actors.search(name) do
{:ok, actors} ->
render(conn, "search.json", events: events, actors: actors)
{:error, err} ->
json(conn, err)
end
end
end