mastodon api: properly track if an account is locked or not
authorWilliam Pitcock <nenolod@dereferenced.org>
Fri, 25 May 2018 04:15:42 +0000 (04:15 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Fri, 25 May 2018 06:14:09 +0000 (06:14 +0000)
lib/pleroma/user.ex
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/views/user_view.ex
lib/pleroma/web/mastodon_api/views/account_view.ex

index 690cc7cf36db0c7c234c350a6353f3c96b27b3de..2e57f2b43052558c471e6515c88b72af5cb085e7 100644 (file)
@@ -67,7 +67,8 @@ defmodule Pleroma.User do
     %{
       following_count: length(user.following) - oneself,
       note_count: user.info["note_count"] || 0,
-      follower_count: user.info["follower_count"] || 0
+      follower_count: user.info["follower_count"] || 0,
+      locked: user.info["locked"] || false
     }
   end
 
index 8485a800982fe8b9433026fe099a89aceddc2345..30211072bdc355921faf9b44ca9aeb85056b366a 100644 (file)
@@ -464,6 +464,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
           "url" => [%{"href" => data["image"]["url"]}]
         }
 
+    locked = data["manuallyApprovesFollowers"] || false
     data = Transmogrifier.maybe_fix_user_object(data)
 
     user_data = %{
@@ -471,7 +472,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
       info: %{
         "ap_enabled" => true,
         "source_data" => data,
-        "banner" => banner
+        "banner" => banner,
+        "locked" => locked
       },
       avatar: avatar,
       nickname: "#{data["preferredUsername"]}@#{URI.parse(data["id"]).host}",
index ffd76b5294ecaf501e056f6f451e10fc280d785b..f4b2e0610ccd608d53b8d533192a7b63b6cc23a4 100644 (file)
@@ -26,7 +26,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
       "name" => user.name,
       "summary" => user.bio,
       "url" => user.ap_id,
-      "manuallyApprovesFollowers" => false,
+      "manuallyApprovesFollowers" => user.info["locked"] || false,
       "publicKey" => %{
         "id" => "#{user.ap_id}#main-key",
         "owner" => user.ap_id,
index f378bb36eac264e96415bb84683715e138a84365..9db683f44b7662b86af344cccc8027a3f570bb50 100644 (file)
@@ -19,7 +19,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
       username: hd(String.split(user.nickname, "@")),
       acct: user.nickname,
       display_name: user.name || user.nickname,
-      locked: false,
+      locked: user_info.locked,
       created_at: Utils.to_masto_date(user.inserted_at),
       followers_count: user_info.follower_count,
       following_count: user_info.following_count,