diff --git a/lib/clacks_web/templates/frontend/_status.html.eex b/lib/clacks_web/templates/frontend/_status.html.eex
index 76a7194..e344045 100644
--- a/lib/clacks_web/templates/frontend/_status.html.eex
+++ b/lib/clacks_web/templates/frontend/_status.html.eex
@@ -3,7 +3,7 @@
diff --git a/lib/clacks_web/views/frontend_view.ex b/lib/clacks_web/views/frontend_view.ex
index 48b9acc..f2b01b8 100644
--- a/lib/clacks_web/views/frontend_view.ex
+++ b/lib/clacks_web/views/frontend_view.ex
@@ -7,13 +7,27 @@ defmodule ClacksWeb.FrontendView do
@spec display_username(actor :: Actor.t()) :: String.t()
- def display_username(%Actor{local: true, data: %{"name" => name}}) do
- "@" <> name
+ def display_username(%Actor{local: true, data: %{"preferredUsername" => username}}) do
+ "@" <> username
end
- def display_username(%Actor{local: false, ap_id: ap_id, data: %{"name" => name}}) do
+ def display_username(%Actor{
+ local: false,
+ ap_id: ap_id,
+ data: %{"preferredUsername" => username}
+ }) do
%URI{host: host} = URI.parse(ap_id)
- "@" <> name <> "@" <> host
+ "@" <> username <> "@" <> host
+ end
+
+ @spec display_name(actor :: Actor.t()) :: String.t()
+
+ def display_name(%Actor{data: %{"name" => name, "preferredUsername" => username}}) do
+ if is_binary(name) && String.length(name) > 0 do
+ name
+ else
+ username
+ end
end
def local_actor_link(%Actor{local: true, ap_id: ap_id}), do: ap_id