Change user.locked field to user.is_locked
authorMark Felder <feld@FreeBSD.org>
Tue, 13 Oct 2020 14:31:13 +0000 (09:31 -0500)
committerMark Felder <feld@FreeBSD.org>
Tue, 13 Oct 2020 14:31:13 +0000 (09:31 -0500)
28 files changed:
lib/mix/tasks/pleroma/user.ex
lib/pleroma/user.ex
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/side_effects.ex
lib/pleroma/web/activity_pub/views/user_view.ex
lib/pleroma/web/admin_api/views/account_view.ex
lib/pleroma/web/api_spec/operations/account_operation.ex
lib/pleroma/web/api_spec/operations/chat_operation.ex
lib/pleroma/web/api_spec/schemas/account.ex
lib/pleroma/web/api_spec/schemas/chat.ex
lib/pleroma/web/api_spec/schemas/status.ex
lib/pleroma/web/mastodon_api/controllers/account_controller.ex
lib/pleroma/web/mastodon_api/views/account_view.ex
priv/repo/migrations/20201013141127_refactor_locked_user_field.exs [new file with mode: 0644]
test/notification_test.exs
test/tasks/user_test.exs
test/user_test.exs
test/web/activity_pub/activity_pub_test.exs
test/web/activity_pub/transmogrifier/accept_handling_test.exs
test/web/activity_pub/transmogrifier/follow_handling_test.exs
test/web/activity_pub/transmogrifier/reject_handling_test.exs
test/web/activity_pub/transmogrifier/user_update_handling_test.exs
test/web/activity_pub/utils_test.exs
test/web/common_api/common_api_test.exs
test/web/mastodon_api/controllers/account_controller/update_credentials_test.exs
test/web/mastodon_api/controllers/account_controller_test.exs
test/web/mastodon_api/controllers/follow_request_controller_test.exs
test/web/mastodon_api/views/account_view_test.exs

index e062628047b402d192a0a4be3cd41e1f5020c7ae..a8d2514118992eea0850b713d2471733b4ed5960 100644 (file)
@@ -419,7 +419,7 @@ defmodule Mix.Tasks.Pleroma.User do
       |> Enum.each(fn user ->
         shell_info(
           "#{user.nickname} moderator: #{user.is_moderator}, admin: #{user.is_admin}, locked: #{
-            user.locked
+            user.is_locked
           }, deactivated: #{user.deactivated}"
         )
       end)
@@ -447,10 +447,10 @@ defmodule Mix.Tasks.Pleroma.User do
   defp set_locked(user, value) do
     {:ok, user} =
       user
-      |> Changeset.change(%{locked: value})
+      |> Changeset.change(%{is_locked: value})
       |> User.update_and_set_cache()
 
-    shell_info("Locked status of #{user.nickname}: #{user.locked}")
+    shell_info("Locked status of #{user.nickname}: #{user.is_locked}")
     user
   end
 
index 09ea8079391b6b8c7c882ee7d19778e58c1bce42..87c8bfbd11d7f50f83295cb6cde45ad3e7aea8be 100644 (file)
@@ -107,7 +107,7 @@ defmodule Pleroma.User do
     field(:note_count, :integer, default: 0)
     field(:follower_count, :integer, default: 0)
     field(:following_count, :integer, default: 0)
-    field(:locked, :boolean, default: false)
+    field(:is_locked, :boolean, default: false)
     field(:confirmation_pending, :boolean, default: false)
     field(:password_reset_pending, :boolean, default: false)
     field(:approval_pending, :boolean, default: false)
@@ -436,7 +436,7 @@ defmodule Pleroma.User do
         :avatar,
         :ap_enabled,
         :banner,
-        :locked,
+        :is_locked,
         :last_refreshed_at,
         :uri,
         :follower_address,
@@ -479,7 +479,7 @@ defmodule Pleroma.User do
         :public_key,
         :inbox,
         :shared_inbox,
-        :locked,
+        :is_locked,
         :no_rich_text,
         :default_scope,
         :banner,
@@ -847,7 +847,7 @@ defmodule Pleroma.User do
   @spec maybe_direct_follow(User.t(), User.t()) :: {:ok, User.t()} | {:error, String.t()}
 
   # "Locked" (self-locked) users demand explicit authorization of follow requests
-  def maybe_direct_follow(%User{} = follower, %User{local: true, locked: true} = followed) do
+  def maybe_direct_follow(%User{} = follower, %User{local: true, is_locked: true} = followed) do
     follow(follower, followed, :follow_pending)
   end
 
@@ -954,7 +954,7 @@ defmodule Pleroma.User do
   end
 
   def locked?(%User{} = user) do
-    user.locked || false
+    user.is_locked || false
   end
 
   def get_by_id(id) do
@@ -1601,7 +1601,7 @@ defmodule Pleroma.User do
       note_count: 0,
       follower_count: 0,
       following_count: 0,
-      locked: false,
+      is_locked: false,
       confirmation_pending: false,
       password_reset_pending: false,
       approval_pending: false,
index eb44cffec14eddb5634a3973a1f6625fbcd14acb..8022f0402be73bcdb4f87ba5a1cffe9bcb4ddd90 100644 (file)
@@ -1228,7 +1228,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
         {String.trim(name, ":"), url}
       end)
 
-    locked = data["manuallyApprovesFollowers"] || false
+    is_locked = data["manuallyApprovesFollowers"] || false
     capabilities = data["capabilities"] || %{}
     accepts_chat_messages = capabilities["acceptsChatMessages"]
     data = Transmogrifier.maybe_fix_user_object(data)
@@ -1257,7 +1257,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
       banner: banner,
       fields: fields,
       emoji: emojis,
-      locked: locked,
+      is_locked: is_locked,
       discoverable: discoverable,
       invisible: invisible,
       avatar: avatar,
index 2eec0ce86c4dfd7f2b1b10ded560e704d0f17906..d421ca7af59c713f6cba366bbecfbbd273f91d27 100644 (file)
@@ -102,7 +102,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
          %User{} = followed <- User.get_cached_by_ap_id(followed_user),
          {_, {:ok, _}, _, _} <-
            {:following, User.follow(follower, followed, :follow_pending), follower, followed} do
-      if followed.local && !followed.locked do
+      if followed.local && !followed.is_locked do
         {:ok, accept_data, _} = Builder.accept(followed, object)
         {:ok, _activity, _} = Pipeline.common_pipeline(accept_data, local: true)
       end
index 3a4564912c2d1508bac155bc79b23f857c528a1d..c6dee61db195b7ef5d47b994c5c524c9b3b072d7 100644 (file)
@@ -101,7 +101,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
       "name" => user.name,
       "summary" => user.bio,
       "url" => user.ap_id,
-      "manuallyApprovesFollowers" => user.locked,
+      "manuallyApprovesFollowers" => user.is_locked,
       "publicKey" => %{
         "id" => "#{user.ap_id}#main-key",
         "owner" => user.ap_id,
index 9c477feabb49812c96dcade416a9f65b52431015..bda7ea19ce710b2d4e666e59b35779b1cba63513 100644 (file)
@@ -39,7 +39,7 @@ defmodule Pleroma.Web.AdminAPI.AccountView do
       :fields,
       :name,
       :nickname,
-      :locked,
+      :is_locked,
       :no_rich_text,
       :default_scope,
       :hide_follows,
index d90ddb78714151d513b798bc99e11e1db275dca0..57f25e1d8269cc367ac25a41af30b47d9816f877 100644 (file)
@@ -519,7 +519,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
           description: "Header image encoded using multipart/form-data",
           format: :binary
         },
-        locked: %Schema{
+        is_locked: %Schema{
           allOf: [BooleanLike],
           nullable: true,
           description: "Whether manual approval of follow requests is required."
index 0dcfdb35467ef2e04f5493ef04546bb124bffd9b..df786e480b77e2671a832479ed8e042aafd822db 100644 (file)
@@ -259,7 +259,7 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
               "fields" => []
             },
             "statuses_count" => 1,
-            "locked" => false,
+            "is_locked" => false,
             "created_at" => "2020-04-16T13:40:15.000Z",
             "display_name" => "lain",
             "fields" => [],
index ca79f0747861b93bb63e5d40022878369ffad247..b8ddf4ab8c3ed1d7017f5fc79d3acf22c58f2c21 100644 (file)
@@ -32,7 +32,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
       header_static: %Schema{type: :string, format: :uri},
       header: %Schema{type: :string, format: :uri},
       id: FlakeID,
-      locked: %Schema{type: :boolean},
+      is_locked: %Schema{type: :boolean},
       note: %Schema{type: :string, format: :html},
       statuses_count: %Schema{type: :integer},
       url: %Schema{type: :string, format: :uri},
@@ -159,7 +159,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
       "header" => "https://mypleroma.com/images/banner.png",
       "header_static" => "https://mypleroma.com/images/banner.png",
       "id" => "9tKi3esbG7OQgZ2920",
-      "locked" => false,
+      "is_locked" => false,
       "note" => "cofe",
       "pleroma" => %{
         "allow_following_move" => true,
index b4986b734e9b7613504aa299a7b4b4cd0c226a95..65f908e33f47552b6bbfa7d587d6c3adb730d67b 100644 (file)
@@ -50,7 +50,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Chat do
           "fields" => []
         },
         "statuses_count" => 1,
-        "locked" => false,
+        "is_locked" => false,
         "created_at" => "2020-04-16T13:40:15.000Z",
         "display_name" => "lain",
         "fields" => [],
index 947e42890744d80117615417361bd881f1e9c709..e6890df2dd67dd6196bcc186588e93deadb44e82 100644 (file)
@@ -252,7 +252,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
         "header" => "http://localhost:4001/images/banner.png",
         "header_static" => "http://localhost:4001/images/banner.png",
         "id" => "9toJCsKN7SmSf3aj5c",
-        "locked" => false,
+        "is_locked" => false,
         "note" => "Tester Number 6",
         "pleroma" => %{
           "background_image" => nil,
index 95d8452df0447f08c540d2b5a8cbbb0a7b81958c..145b46ea19211a9caf20c5fcfac006de8abf721e 100644 (file)
@@ -177,7 +177,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
     user_params =
       [
         :no_rich_text,
-        :locked,
+        :is_locked,
         :hide_followers_count,
         :hide_follows_count,
         :hide_followers,
index 121ba1693155adf30f4c17b9be4d0c9b111bf001..f382c05a3bcd5083f60d1fd3e47999e553939782 100644 (file)
@@ -242,7 +242,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
       username: username_from_nickname(user.nickname),
       acct: user.nickname,
       display_name: display_name,
-      locked: user.locked,
+      is_locked: user.is_locked,
       created_at: Utils.to_masto_date(user.inserted_at),
       followers_count: followers_count,
       following_count: following_count,
diff --git a/priv/repo/migrations/20201013141127_refactor_locked_user_field.exs b/priv/repo/migrations/20201013141127_refactor_locked_user_field.exs
new file mode 100644 (file)
index 0000000..6cd23db
--- /dev/null
@@ -0,0 +1,15 @@
+# Pleroma: A lightweight social networking server
+# Copyright Â© 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Repo.Migrations.RefactorLockedUserField do
+  use Ecto.Migration
+
+  def up do
+    execute("ALTER TABLE users RENAME COLUMN locked TO is_locked;")
+  end
+
+  def down do
+    execute("ALTER TABLE users RENAME COLUMN is_locked TO locked;")
+  end
+end
index f2e0f0b0d8ccfa26ae7b6cc5c3f4cc33893e07c1..0e9630f28518297f7a9be155d169a007debd0362 100644 (file)
@@ -346,7 +346,7 @@ defmodule Pleroma.NotificationTest do
   describe "follow / follow_request notifications" do
     test "it creates `follow` notification for approved Follow activity" do
       user = insert(:user)
-      followed_user = insert(:user, locked: false)
+      followed_user = insert(:user, is_locked: false)
 
       {:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
       assert FollowingRelationship.following?(user, followed_user)
@@ -361,7 +361,7 @@ defmodule Pleroma.NotificationTest do
 
     test "it creates `follow_request` notification for pending Follow activity" do
       user = insert(:user)
-      followed_user = insert(:user, locked: true)
+      followed_user = insert(:user, is_locked: true)
 
       {:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
       refute FollowingRelationship.following?(user, followed_user)
@@ -383,7 +383,7 @@ defmodule Pleroma.NotificationTest do
 
     test "it doesn't create a notification for follow-unfollow-follow chains" do
       user = insert(:user)
-      followed_user = insert(:user, locked: false)
+      followed_user = insert(:user, is_locked: false)
 
       {:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
       assert FollowingRelationship.following?(user, followed_user)
@@ -397,7 +397,7 @@ defmodule Pleroma.NotificationTest do
     end
 
     test "dismisses the notification on follow request rejection" do
-      user = insert(:user, locked: true)
+      user = insert(:user, is_locked: true)
       follower = insert(:user)
       {:ok, _, _, _follow_activity} = CommonAPI.follow(follower, user)
       assert [notification] = Notification.for_user(user)
index b8c423c48455590765345bbc15faac0d68c441f7..09e1f472e305e97f1294da5c5309b3d1203ca7a3 100644 (file)
@@ -248,14 +248,14 @@ defmodule Mix.Tasks.Pleroma.UserTest do
 
       user = User.get_cached_by_nickname(user.nickname)
       assert user.is_moderator
-      assert user.locked
+      assert user.is_locked
       assert user.is_admin
       refute user.confirmation_pending
     end
 
     test "All statuses unset" do
       user =
-        insert(:user, locked: true, is_moderator: true, is_admin: true, confirmation_pending: true)
+        insert(:user, is_locked: true, is_moderator: true, is_admin: true, confirmation_pending: true)
 
       Mix.Tasks.Pleroma.User.run([
         "set",
@@ -280,7 +280,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
 
       user = User.get_cached_by_nickname(user.nickname)
       refute user.is_moderator
-      refute user.locked
+      refute user.is_locked
       refute user.is_admin
       assert user.confirmation_pending
     end
index d506f704708a6c7f501bf51db735b8f5cd301b21..d8ac652af59fb562fc40a326de307139a17433a8 100644 (file)
@@ -174,7 +174,7 @@ defmodule Pleroma.UserTest do
 
   test "returns all pending follow requests" do
     unlocked = insert(:user)
-    locked = insert(:user, locked: true)
+    locked = insert(:user, is_locked: true)
     follower = insert(:user)
 
     CommonAPI.follow(follower, unlocked)
@@ -187,7 +187,7 @@ defmodule Pleroma.UserTest do
   end
 
   test "doesn't return already accepted or duplicate follow requests" do
-    locked = insert(:user, locked: true)
+    locked = insert(:user, is_locked: true)
     pending_follower = insert(:user)
     accepted_follower = insert(:user)
 
@@ -201,7 +201,7 @@ defmodule Pleroma.UserTest do
   end
 
   test "doesn't return follow requests for deactivated accounts" do
-    locked = insert(:user, locked: true)
+    locked = insert(:user, is_locked: true)
     pending_follower = insert(:user, %{deactivated: true})
 
     CommonAPI.follow(pending_follower, locked)
@@ -211,7 +211,7 @@ defmodule Pleroma.UserTest do
   end
 
   test "clears follow requests when requester is blocked" do
-    followed = insert(:user, locked: true)
+    followed = insert(:user, is_locked: true)
     follower = insert(:user)
 
     CommonAPI.follow(follower, followed)
@@ -299,8 +299,8 @@ defmodule Pleroma.UserTest do
   end
 
   test "local users do not automatically follow local locked accounts" do
-    follower = insert(:user, locked: true)
-    followed = insert(:user, locked: true)
+    follower = insert(:user, is_locked: true)
+    followed = insert(:user, is_locked: true)
 
     {:ok, follower} = User.maybe_direct_follow(follower, followed)
 
@@ -1360,7 +1360,7 @@ defmodule Pleroma.UserTest do
       follower = insert(:user)
       {:ok, follower} = User.follow(follower, user)
 
-      locked_user = insert(:user, name: "locked", locked: true)
+      locked_user = insert(:user, name: "locked", is_locked: true)
       {:ok, _} = User.follow(user, locked_user, :follow_pending)
 
       object = insert(:note, user: user)
@@ -1450,7 +1450,7 @@ defmodule Pleroma.UserTest do
         note_count: 9,
         follower_count: 9,
         following_count: 9001,
-        locked: true,
+        is_locked: true,
         confirmation_pending: true,
         password_reset_pending: true,
         approval_pending: true,
@@ -1492,7 +1492,7 @@ defmodule Pleroma.UserTest do
              note_count: 0,
              follower_count: 0,
              following_count: 0,
-             locked: false,
+             is_locked: false,
              confirmation_pending: false,
              password_reset_pending: false,
              approval_pending: false,
index 804305a1381321e35c4ae38dcc8d67febcecf5de..3efc0d1b410307f2ade56a9c47b21b130b538917 100644 (file)
@@ -1120,7 +1120,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
 
     test "creates an undo activity for a pending follow request" do
       follower = insert(:user)
-      followed = insert(:user, %{locked: true})
+      followed = insert(:user, %{is_locked: true})
 
       {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
       {:ok, activity} = ActivityPub.unfollow(follower, followed)
index 77d468f5c98351b00a58ebc4dc9f8532d7aa8d12..c6ff96f08926b507e5377171005b28d7f0ba325e 100644 (file)
@@ -46,7 +46,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do
 
   test "it works for incoming accepts which are referenced by IRI only" do
     follower = insert(:user)
-    followed = insert(:user, locked: true)
+    followed = insert(:user, is_locked: true)
 
     {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
 
@@ -72,7 +72,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do
 
   test "it fails for incoming accepts which cannot be correlated" do
     follower = insert(:user)
-    followed = insert(:user, locked: true)
+    followed = insert(:user, is_locked: true)
 
     accept_data =
       File.read!("test/fixtures/mastodon-accept-activity.json")
index 757d90941f85fd93c16d9af7696774cb63f70916..4ef8210ad8a946a5724fcb08328ccaf7c021aef3 100644 (file)
@@ -65,7 +65,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
     end
 
     test "with locked accounts, it does create a Follow, but not an Accept" do
-      user = insert(:user, locked: true)
+      user = insert(:user, is_locked: true)
 
       data =
         File.read!("test/fixtures/mastodon-follow-activity.json")
@@ -188,7 +188,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
 
     test "it works for incoming follows to locked account" do
       pending_follower = insert(:user, ap_id: "http://mastodon.example.org/users/admin")
-      user = insert(:user, locked: true)
+      user = insert(:user, is_locked: true)
 
       data =
         File.read!("test/fixtures/mastodon-follow-activity.json")
index 7592fbe1c6c23126e7fddb6fca76f34d2e1648dd..5c1451defa070129aa7a7f05f035455bbf606275 100644 (file)
@@ -14,7 +14,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.RejectHandlingTest do
 
   test "it fails for incoming rejects which cannot be correlated" do
     follower = insert(:user)
-    followed = insert(:user, locked: true)
+    followed = insert(:user, is_locked: true)
 
     accept_data =
       File.read!("test/fixtures/mastodon-reject-activity.json")
@@ -33,7 +33,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.RejectHandlingTest do
 
   test "it works for incoming rejects which are referenced by IRI only" do
     follower = insert(:user)
-    followed = insert(:user, locked: true)
+    followed = insert(:user, is_locked: true)
 
     {:ok, follower} = User.follow(follower, followed)
     {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
index 64636656cab11a0ffe6610a7478ed47e427c6d92..7c4d16db723cc0f7c2537a99a28ea8c773ee2951 100644 (file)
@@ -154,6 +154,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UserUpdateHandlingTest do
     {:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(update_data)
 
     user = User.get_cached_by_ap_id(user.ap_id)
-    assert user.locked == true
+    assert user.is_locked == true
   end
 end
index d5021354595756eeb7d4f20b546db953d622857a..be9cd7d13eb45f6f5a3bd0326a9f7f9be2b4b512 100644 (file)
@@ -193,7 +193,7 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
 
   describe "update_follow_state_for_all/2" do
     test "updates the state of all Follow activities with the same actor and object" do
-      user = insert(:user, locked: true)
+      user = insert(:user, is_locked: true)
       follower = insert(:user)
 
       {:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)
@@ -217,7 +217,7 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
 
   describe "update_follow_state/2" do
     test "updates the state of the given follow activity" do
-      user = insert(:user, locked: true)
+      user = insert(:user, is_locked: true)
       follower = insert(:user)
 
       {:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)
index e34f5a49b39b8ae7f29ba6c03ac66cb503497b80..a8e22d44f4da4a971e41386a63486f043fdbb1fc 100644 (file)
@@ -1071,7 +1071,7 @@ defmodule Pleroma.Web.CommonAPITest do
 
     test "cancels a pending follow for a local user" do
       follower = insert(:user)
-      followed = insert(:user, locked: true)
+      followed = insert(:user, is_locked: true)
 
       assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
                CommonAPI.follow(follower, followed)
@@ -1093,7 +1093,7 @@ defmodule Pleroma.Web.CommonAPITest do
 
     test "cancels a pending follow for a remote user" do
       follower = insert(:user)
-      followed = insert(:user, locked: true, local: false, ap_enabled: true)
+      followed = insert(:user, is_locked: true, local: false, ap_enabled: true)
 
       assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
                CommonAPI.follow(follower, followed)
@@ -1116,7 +1116,7 @@ defmodule Pleroma.Web.CommonAPITest do
 
   describe "accept_follow_request/2" do
     test "after acceptance, it sets all existing pending follow request states to 'accept'" do
-      user = insert(:user, locked: true)
+      user = insert(:user, is_locked: true)
       follower = insert(:user)
       follower_two = insert(:user)
 
@@ -1136,7 +1136,7 @@ defmodule Pleroma.Web.CommonAPITest do
     end
 
     test "after rejection, it sets all existing pending follow request states to 'reject'" do
-      user = insert(:user, locked: true)
+      user = insert(:user, is_locked: true)
       follower = insert(:user)
       follower_two = insert(:user)
 
@@ -1156,7 +1156,7 @@ defmodule Pleroma.Web.CommonAPITest do
     end
 
     test "doesn't create a following relationship if the corresponding follow request doesn't exist" do
-      user = insert(:user, locked: true)
+      user = insert(:user, is_locked: true)
       not_follower = insert(:user)
       CommonAPI.accept_follow_request(not_follower, user)
 
index 2e67047266089c1d30989fbfffc6be72c4448bbf..f49dbdf4d5c5295e24d03676ae7e2efcbbd6baf0 100644 (file)
@@ -102,7 +102,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
     end
 
     test "updates the user's locking status", %{conn: conn} do
-      conn = patch(conn, "/api/v1/accounts/update_credentials", %{locked: "true"})
+      conn = patch(conn, "/api/v1/accounts/update_credentials", %{is_locked: "true"})
 
       assert user_data = json_response_and_validate_schema(conn, 200)
       assert user_data["locked"] == true
index f7f1369e48e35d70a19d925a2a3c2d2f66a05b00..0b803b7ab11c14d227e1b7a00dcdd447fe7c504e 100644 (file)
@@ -706,7 +706,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
     end
 
     test "cancelling follow request", %{conn: conn} do
-      %{id: other_user_id} = insert(:user, %{locked: true})
+      %{id: other_user_id} = insert(:user, %{is_locked: true})
 
       assert %{"id" => ^other_user_id, "following" => false, "requested" => true} =
                conn
index 6749e0e83a480dcf843b2348735cc2b3bc9e6a4c..a9dd7cd30aaeee4e516223909b127d9be9112aa3 100644 (file)
@@ -12,7 +12,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do
 
   describe "locked accounts" do
     setup do
-      user = insert(:user, locked: true)
+      user = insert(:user, is_locked: true)
       %{conn: conn} = oauth_access(["follow"], user: user)
       %{user: user, conn: conn}
     end
index a5f39b215dd6e5ad92ba2962b49506ed21abaa60..90b436376063ca178c4c02a0238e60bb03186486 100644 (file)
@@ -43,7 +43,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
       username: "shp",
       acct: user.nickname,
       display_name: user.name,
-      locked: false,
+      is_locked: false,
       created_at: "2017-08-15T15:47:06.000Z",
       followers_count: 3,
       following_count: 0,
@@ -148,7 +148,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
       username: "shp",
       acct: user.nickname,
       display_name: user.name,
-      locked: false,
+      is_locked: false,
       created_at: "2017-08-15T15:47:06.000Z",
       followers_count: 3,
       following_count: 0,
@@ -332,7 +332,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
 
     test "represent a relationship for the user with a pending follow request" do
       user = insert(:user)
-      other_user = insert(:user, locked: true)
+      other_user = insert(:user, is_locked: true)
 
       {:ok, user, other_user, _} = CommonAPI.follow(user, other_user)
       user = User.get_cached_by_id(user.id)
@@ -481,62 +481,62 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
     end
 
     test "shows non-zero when follow requests are pending" do
-      user = insert(:user, locked: true)
+      user = insert(:user, is_locked: true)
 
-      assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
+      assert %{is_locked: true} = AccountView.render("show.json", %{user: user, for: user})
 
       other_user = insert(:user)
       {:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user)
 
-      assert %{locked: true, follow_requests_count: 1} =
+      assert %{is_locked: true, follow_requests_count: 1} =
                AccountView.render("show.json", %{user: user, for: user})
     end
 
     test "decreases when accepting a follow request" do
-      user = insert(:user, locked: true)
+      user = insert(:user, is_locked: true)
 
-      assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
+      assert %{is_locked: true} = AccountView.render("show.json", %{user: user, for: user})
 
       other_user = insert(:user)
       {:ok, other_user, user, _activity} = CommonAPI.follow(other_user, user)
 
-      assert %{locked: true, follow_requests_count: 1} =
+      assert %{is_locked: true, follow_requests_count: 1} =
                AccountView.render("show.json", %{user: user, for: user})
 
       {:ok, _other_user} = CommonAPI.accept_follow_request(other_user, user)
 
-      assert %{locked: true, follow_requests_count: 0} =
+      assert %{is_locked: true, follow_requests_count: 0} =
                AccountView.render("show.json", %{user: user, for: user})
     end
 
     test "decreases when rejecting a follow request" do
-      user = insert(:user, locked: true)
+      user = insert(:user, is_locked: true)
 
-      assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
+      assert %{is_locked: true} = AccountView.render("show.json", %{user: user, for: user})
 
       other_user = insert(:user)
       {:ok, other_user, user, _activity} = CommonAPI.follow(other_user, user)
 
-      assert %{locked: true, follow_requests_count: 1} =
+      assert %{is_locked: true, follow_requests_count: 1} =
                AccountView.render("show.json", %{user: user, for: user})
 
       {:ok, _other_user} = CommonAPI.reject_follow_request(other_user, user)
 
-      assert %{locked: true, follow_requests_count: 0} =
+      assert %{is_locked: true, follow_requests_count: 0} =
                AccountView.render("show.json", %{user: user, for: user})
     end
 
     test "shows non-zero when historical unapproved requests are present" do
-      user = insert(:user, locked: true)
+      user = insert(:user, is_locked: true)
 
-      assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
+      assert %{is_locked: true} = AccountView.render("show.json", %{user: user, for: user})
 
       other_user = insert(:user)
       {:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user)
 
-      {:ok, user} = User.update_and_set_cache(user, %{locked: false})
+      {:ok, user} = User.update_and_set_cache(user, %{is_locked: false})
 
-      assert %{locked: false, follow_requests_count: 1} =
+      assert %{is_locked: false, follow_requests_count: 1} =
                AccountView.render("show.json", %{user: user, for: user})
     end
   end