Merge branch 'refactor/locked_user_field' into 'develop'
Change user.locked field to user.is_locked See merge request pleroma/pleroma!3077
This commit is contained in:
commit
9a85ec0da0
24 changed files with 77 additions and 57 deletions
|
|
@ -248,14 +248,19 @@ 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 +285,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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,7 +481,7 @@ 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})
|
||||
|
||||
|
|
@ -493,7 +493,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
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})
|
||||
|
||||
|
|
@ -510,7 +510,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
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})
|
||||
|
||||
|
|
@ -527,14 +527,14 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
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})
|
||||
|
||||
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} =
|
||||
AccountView.render("show.json", %{user: user, for: user})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue