Fix display names/usernames being switched
This commit is contained in:
parent
10a06fd634
commit
afff7c4fb3
|
@ -3,7 +3,7 @@
|
|||
<div class="p-author h-card">
|
||||
<h2 class="status-author-nickname">
|
||||
<a href="<%= local_actor_link(@author) %>">
|
||||
<%= @author.data["preferredUsername"] %>
|
||||
<%= display_name(@author) %>
|
||||
</a>
|
||||
</h2>
|
||||
<h3 class="status-author-username">
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue