Fix Mastodon API when actor's nickname is null
This commit is contained in:
parent
cce9d008f9
commit
ddc6f32b75
|
@ -28,7 +28,7 @@ def render("account.json", %{user: user}) do
|
||||||
|
|
||||||
%{
|
%{
|
||||||
id: to_string(user.id),
|
id: to_string(user.id),
|
||||||
username: hd(String.split(user.nickname, "@")),
|
username: username_from_nickname(user.nickname),
|
||||||
acct: user.nickname,
|
acct: user.nickname,
|
||||||
display_name: user.name || user.nickname,
|
display_name: user.name || user.nickname,
|
||||||
locked: user_info.locked,
|
locked: user_info.locked,
|
||||||
|
@ -56,7 +56,7 @@ def render("mention.json", %{user: user}) do
|
||||||
%{
|
%{
|
||||||
id: to_string(user.id),
|
id: to_string(user.id),
|
||||||
acct: user.nickname,
|
acct: user.nickname,
|
||||||
username: hd(String.split(user.nickname, "@")),
|
username: username_from_nickname(user.nickname),
|
||||||
url: user.ap_id
|
url: user.ap_id
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -76,4 +76,10 @@ def render("relationship.json", %{user: user, target: target}) do
|
||||||
def render("relationships.json", %{user: user, targets: targets}) do
|
def render("relationships.json", %{user: user, targets: targets}) do
|
||||||
render_many(targets, AccountView, "relationship.json", user: user, as: :target)
|
render_many(targets, AccountView, "relationship.json", user: user, as: :target)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp username_from_nickname(string) when is_binary(string) do
|
||||||
|
hd(String.split(string, "@"))
|
||||||
|
end
|
||||||
|
|
||||||
|
defp username_from_nickname(_), do: nil
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue