Add searching for remote actors
This commit is contained in:
parent
e7c19940b0
commit
e7dcbdc6a4
|
@ -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
|
||||
|
||||
|
|
|
@ -3,7 +3,26 @@
|
|||
<%= submit "Search" %>
|
||||
<% end %>
|
||||
|
||||
<%= if @conn.assigns[:status_results] do %>
|
||||
<%= if length(@actor_results) > 0 do %>
|
||||
<hr>
|
||||
|
||||
<%= for actor <- @actor_results do %>
|
||||
<div class="actor">
|
||||
<h2 class="actor-nickname">
|
||||
<a href="<%= local_actor_link(actor) %>">
|
||||
<%= actor.data["preferredUsername"] %>
|
||||
</a>
|
||||
</h2>
|
||||
<h3 class="actor-username">
|
||||
<a href="<%= actor.ap_id %>">
|
||||
<%= display_username(actor) %>
|
||||
</a>
|
||||
</h3>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= if length(@status_results) do %>
|
||||
<hr>
|
||||
|
||||
<%= for {status, author} <- @status_results do %>
|
||||
|
|
Loading…
Reference in New Issue