Merge branch 'feature/admin-api-render-whole-status' into 'develop'
[akkoma] / lib / pleroma / web / mastodon_api / views / account_view.ex
index 7f50f3aa692efc38a666c8f19f874aa8e4ff67b2..ec720e472e20bd368c80cf79fa82922239bf5a50 100644 (file)
@@ -74,14 +74,14 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
 
     following_count =
       if !user.hide_follows_count or !user.hide_follows or opts[:for] == user do
-        user.following_count
+        user.following_count || 0
       else
         0
       end
 
     followers_count =
       if !user.hide_followers_count or !user.hide_followers or opts[:for] == user do
-        user.follower_count
+        user.follower_count || 0
       else
         0
       end
@@ -162,6 +162,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
     |> maybe_put_chat_token(user, opts[:for], opts)
     |> maybe_put_activation_status(user, opts[:for])
     |> maybe_put_follow_requests_count(user, opts[:for])
+    |> maybe_put_allow_following_move(user, opts[:for])
     |> maybe_put_unread_conversation_count(user, opts[:for])
   end
 
@@ -238,6 +239,12 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
 
   defp maybe_put_notification_settings(data, _, _), do: data
 
+  defp maybe_put_allow_following_move(data, %User{id: user_id} = user, %User{id: user_id}) do
+    Kernel.put_in(data, [:pleroma, :allow_following_move], user.allow_following_move)
+  end
+
+  defp maybe_put_allow_following_move(data, _, _), do: data
+
   defp maybe_put_activation_status(data, user, %User{is_admin: true}) do
     Kernel.put_in(data, [:pleroma, :deactivated], user.deactivated)
   end