aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHaelwenn <git.pleroma.social@hacktivis.me>2018-08-29 14:43:45 +0000
committerHaelwenn <git.pleroma.social@hacktivis.me>2018-08-29 14:43:45 +0000
commitb11746726e048c40fea758e665667757d455be5e (patch)
tree370ba1006cca15744c88bcb1124e81e5e1c72b2f /lib
parentcce9d008f984475a8f9180ac4fcbef1d7cb8f88a (diff)
parentddc6f32b757c3d99cf1d1cf40c15d126f40145db (diff)
downloadpleroma-b11746726e048c40fea758e665667757d455be5e.tar.gz
Merge branch 'fix-mastodon-notifications-without-nickname' into 'develop'
Fix Mastodon API when actor's nickname is null See merge request pleroma/pleroma!308
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/mastodon_api/views/account_view.ex10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex
index d9edcae7f..133cae3b5 100644
--- 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),
- 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,
@@ -56,7 +56,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
%{
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
@@ -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
+
+ defp username_from_nickname(string) when is_binary(string) do
+ hd(String.split(string, "@"))
+ end
+
+ defp username_from_nickname(_), do: nil
end