projects
/
akkoma
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
cce9d00
)
Fix Mastodon API when actor's nickname is null
author
href
<href@random.sh>
Wed, 29 Aug 2018 14:26:36 +0000
(16:26 +0200)
committer
href
<href@random.sh>
Wed, 29 Aug 2018 14:32:50 +0000
(16:32 +0200)
lib/pleroma/web/mastodon_api/views/account_view.ex
patch
|
blob
|
history
diff --git
a/lib/pleroma/web/mastodon_api/views/account_view.ex
b/lib/pleroma/web/mastodon_api/views/account_view.ex
index d9edcae7ffe51277a803fa49b18331cc27549f44..133cae3b5b541e443ee7ea344b824dc68b928194 100644
(file)
--- a/
lib/pleroma/web/mastodon_api/views/account_view.ex
+++ b/
lib/pleroma/web/mastodon_api/views/account_view.ex
@@
-28,7
+28,7
@@
defmodule Pleroma.Web.MastodonAPI.AccountView 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,
display_name: user.name || user.nickname,
locked: user_info.locked,
acct: user.nickname,
display_name: user.name || user.nickname,
locked: user_info.locked,
@@
-56,7
+56,7
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
%{
id: to_string(user.id),
acct: user.nickname,
%{
id: to_string(user.id),
acct: user.nickname,
- username:
hd(String.split(user.nickname, "@")
),
+ username:
username_from_nickname(user.nickname
),
url: user.ap_id
}
end
url: user.ap_id
}
end
@@
-76,4
+76,10
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
def render("relationships.json", %{user: user, targets: targets}) do
render_many(targets, AccountView, "relationship.json", user: user, as: :target)
end
def render("relationships.json", %{user: user, targets: targets}) do
render_many(targets, AccountView, "relationship.json", user: user, as: :target)
end
+
+ defp username_from_nickname(string) when is_binary(string) do
+ hd(String.split(string, "@"))
+ end
+
+ defp username_from_nickname(_), do: nil
end
end