Twitter API: Fall back to user.nickname if user has no name
authorscarlett <nia@netbsd.org>
Mon, 12 Nov 2018 15:38:39 +0000 (15:38 +0000)
committerscarlett <nia@netbsd.org>
Mon, 12 Nov 2018 15:52:13 +0000 (15:52 +0000)
lib/pleroma/web/twitter_api/views/user_view.ex

index a662f83b66cc0fee7605b3d73e3d9f78d68e0866..a100a1127814fea4541ecd0ec7e20a581c297e21 100644 (file)
@@ -55,8 +55,12 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
       "statusnet_blocking" => statusnet_blocking,
       "friends_count" => user_info[:following_count],
       "id" => user.id,
-      "name" => user.name,
-      "name_html" => HTML.strip_tags(user.name) |> Formatter.emojify(emoji),
+      "name" => user.name || user.nickname,
+      "name_html" =>
+        if(user.name,
+          do: HTML.strip_tags(user.name) |> Formatter.emojify(emoji),
+          else: user.nickname
+        ),
       "profile_image_url" => image,
       "profile_image_url_https" => image,
       "profile_image_url_profile_size" => image,