Refactor
authorThibaut Girka <thib.pleroma-6b5f@sitedethib.com>
Sat, 3 Aug 2019 18:37:20 +0000 (18:37 +0000)
committerThibaut Girka <thib.pleroma-6b5f@sitedethib.com>
Sat, 3 Aug 2019 18:37:20 +0000 (18:37 +0000)
lib/pleroma/web/activity_pub/views/user_view.ex

index 8fe38927f33eb3600035b6c6d4a6b8db8cd86e03..06c9e1c7117af988ddcb86fc243c4b25cbb7f3eb 100644 (file)
@@ -57,7 +57,6 @@ defmodule Pleroma.Web.ActivityPub.UserView do
       },
       "endpoints" => endpoints
     }
-    |> Map.merge(if user.nickname == nil do %{} else %{ "preferredUsername" => user.nickname})
     |> Map.merge(Utils.make_json_ld_header())
   end
 
@@ -66,7 +65,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
     do: render("service.json", %{user: user})
 
   def render("user.json", %{user: %User{nickname: "internal." <> _} = user}),
-    do: render("service.json", %{user: user})
+    do: render("service.json", %{user: user}) |> Map.put("preferredUsername", user.nickname)
 
   def render("user.json", %{user: user}) do
     {:ok, user} = User.ensure_keys_present(user)