diff --git a/lib/clacks_web/controllers/frontend_controller.ex b/lib/clacks_web/controllers/frontend_controller.ex index 3f373ed..a67d4cb 100644 --- a/lib/clacks_web/controllers/frontend_controller.ex +++ b/lib/clacks_web/controllers/frontend_controller.ex @@ -151,11 +151,20 @@ defmodule ClacksWeb.FrontendController do def search(conn, %{"q" => q}) when is_binary(q) do current_user = conn.assigns[:user] + actor_results = + case Actor.fetch(q) do + %Actor{} = actor -> + [actor] + + _ -> + [] + end + status_results = with %Activity{ actor: actor_id, data: %{"type" => "Create", "object" => %{"type" => "Note"}} - } = activity <- Object.fetch(q, true, :activity) |> IO.inspect(), + } = activity <- Object.fetch(q, true, :activity), actor <- Actor.get_by_ap_id(actor_id) do [{activity, actor}] else @@ -166,7 +175,8 @@ defmodule ClacksWeb.FrontendController do render(conn, "search.html", %{ current_user: current_user, q: q, - status_results: status_results + status_results: status_results, + actor_results: actor_results }) end @@ -175,7 +185,9 @@ defmodule ClacksWeb.FrontendController do render(conn, "search.html", %{ current_user: current_user, - q: "" + q: "", + status_results: [], + actor_results: [] }) end diff --git a/lib/clacks_web/templates/frontend/search.html.eex b/lib/clacks_web/templates/frontend/search.html.eex index 46d111e..e4ae6c5 100644 --- a/lib/clacks_web/templates/frontend/search.html.eex +++ b/lib/clacks_web/templates/frontend/search.html.eex @@ -3,7 +3,26 @@ <%= submit "Search" %> <% end %> -<%= if @conn.assigns[:status_results] do %> +<%= if length(@actor_results) > 0 do %> +
+ + <%= for actor <- @actor_results do %> +
+

+ + <%= actor.data["preferredUsername"] %> + +

+

+ + <%= display_username(actor) %> + +

+
+ <% end %> +<% end %> + +<%= if length(@status_results) do %>
<%= for {status, author} <- @status_results do %>