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:
Haelwenn 2020-10-14 16:17:32 +00:00
commit 9a85ec0da0
24 changed files with 77 additions and 57 deletions

View file

@ -419,7 +419,7 @@ def run(["list"]) do
|> Enum.each(fn user -> |> Enum.each(fn user ->
shell_info( shell_info(
"#{user.nickname} moderator: #{user.is_moderator}, admin: #{user.is_admin}, locked: #{ "#{user.nickname} moderator: #{user.is_moderator}, admin: #{user.is_admin}, locked: #{
user.locked user.is_locked
}, deactivated: #{user.deactivated}" }, deactivated: #{user.deactivated}"
) )
end) end)
@ -447,10 +447,10 @@ defp set_admin(user, value) do
defp set_locked(user, value) do defp set_locked(user, value) do
{:ok, user} = {:ok, user} =
user user
|> Changeset.change(%{locked: value}) |> Changeset.change(%{is_locked: value})
|> User.update_and_set_cache() |> 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 user
end end

View file

@ -107,7 +107,7 @@ defmodule Pleroma.User do
field(:note_count, :integer, default: 0) field(:note_count, :integer, default: 0)
field(:follower_count, :integer, default: 0) field(:follower_count, :integer, default: 0)
field(:following_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(:confirmation_pending, :boolean, default: false)
field(:password_reset_pending, :boolean, default: false) field(:password_reset_pending, :boolean, default: false)
field(:approval_pending, :boolean, default: false) field(:approval_pending, :boolean, default: false)
@ -436,7 +436,7 @@ def remote_user_changeset(struct \\ %User{local: false}, params) do
:avatar, :avatar,
:ap_enabled, :ap_enabled,
:banner, :banner,
:locked, :is_locked,
:last_refreshed_at, :last_refreshed_at,
:uri, :uri,
:follower_address, :follower_address,
@ -479,7 +479,7 @@ def update_changeset(struct, params \\ %{}) do
:public_key, :public_key,
:inbox, :inbox,
:shared_inbox, :shared_inbox,
:locked, :is_locked,
:no_rich_text, :no_rich_text,
:default_scope, :default_scope,
:banner, :banner,
@ -847,7 +847,7 @@ def needs_update?(_), do: true
@spec maybe_direct_follow(User.t(), User.t()) :: {:ok, User.t()} | {:error, String.t()} @spec maybe_direct_follow(User.t(), User.t()) :: {:ok, User.t()} | {:error, String.t()}
# "Locked" (self-locked) users demand explicit authorization of follow requests # "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) follow(follower, followed, :follow_pending)
end end
@ -954,7 +954,7 @@ def get_follow_state(
end end
def locked?(%User{} = user) do def locked?(%User{} = user) do
user.locked || false user.is_locked || false
end end
def get_by_id(id) do def get_by_id(id) do
@ -1601,7 +1601,7 @@ def purge_user_changeset(user) do
note_count: 0, note_count: 0,
follower_count: 0, follower_count: 0,
following_count: 0, following_count: 0,
locked: false, is_locked: false,
confirmation_pending: false, confirmation_pending: false,
password_reset_pending: false, password_reset_pending: false,
approval_pending: false, approval_pending: false,

View file

@ -1228,7 +1228,7 @@ defp object_to_user_data(data) do
{String.trim(name, ":"), url} {String.trim(name, ":"), url}
end) end)
locked = data["manuallyApprovesFollowers"] || false is_locked = data["manuallyApprovesFollowers"] || false
capabilities = data["capabilities"] || %{} capabilities = data["capabilities"] || %{}
accepts_chat_messages = capabilities["acceptsChatMessages"] accepts_chat_messages = capabilities["acceptsChatMessages"]
data = Transmogrifier.maybe_fix_user_object(data) data = Transmogrifier.maybe_fix_user_object(data)
@ -1257,7 +1257,7 @@ defp object_to_user_data(data) do
banner: banner, banner: banner,
fields: fields, fields: fields,
emoji: emojis, emoji: emojis,
locked: locked, is_locked: is_locked,
discoverable: discoverable, discoverable: discoverable,
invisible: invisible, invisible: invisible,
avatar: avatar, avatar: avatar,

View file

@ -102,7 +102,7 @@ def handle(
%User{} = followed <- User.get_cached_by_ap_id(followed_user), %User{} = followed <- User.get_cached_by_ap_id(followed_user),
{_, {:ok, _}, _, _} <- {_, {:ok, _}, _, _} <-
{:following, User.follow(follower, followed, :follow_pending), follower, followed} do {: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, accept_data, _} = Builder.accept(followed, object)
{:ok, _activity, _} = Pipeline.common_pipeline(accept_data, local: true) {:ok, _activity, _} = Pipeline.common_pipeline(accept_data, local: true)
end end

View file

@ -101,7 +101,7 @@ def render("user.json", %{user: user}) do
"name" => user.name, "name" => user.name,
"summary" => user.bio, "summary" => user.bio,
"url" => user.ap_id, "url" => user.ap_id,
"manuallyApprovesFollowers" => user.locked, "manuallyApprovesFollowers" => user.is_locked,
"publicKey" => %{ "publicKey" => %{
"id" => "#{user.ap_id}#main-key", "id" => "#{user.ap_id}#main-key",
"owner" => user.ap_id, "owner" => user.ap_id,

View file

@ -39,7 +39,7 @@ def render("credentials.json", %{user: user, for: for_user}) do
:fields, :fields,
:name, :name,
:nickname, :nickname,
:locked, :is_locked,
:no_rich_text, :no_rich_text,
:default_scope, :default_scope,
:hide_follows, :hide_follows,

View file

@ -50,7 +50,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Chat do
"fields" => [] "fields" => []
}, },
"statuses_count" => 1, "statuses_count" => 1,
"locked" => false, "is_locked" => false,
"created_at" => "2020-04-16T13:40:15.000Z", "created_at" => "2020-04-16T13:40:15.000Z",
"display_name" => "lain", "display_name" => "lain",
"fields" => [], "fields" => [],

View file

@ -252,7 +252,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
"header" => "http://localhost:4001/images/banner.png", "header" => "http://localhost:4001/images/banner.png",
"header_static" => "http://localhost:4001/images/banner.png", "header_static" => "http://localhost:4001/images/banner.png",
"id" => "9toJCsKN7SmSf3aj5c", "id" => "9toJCsKN7SmSf3aj5c",
"locked" => false, "is_locked" => false,
"note" => "Tester Number 6", "note" => "Tester Number 6",
"pleroma" => %{ "pleroma" => %{
"background_image" => nil, "background_image" => nil,

View file

@ -177,7 +177,6 @@ def update_credentials(%{assigns: %{user: user}, body_params: params} = conn, _p
user_params = user_params =
[ [
:no_rich_text, :no_rich_text,
:locked,
:hide_followers_count, :hide_followers_count,
:hide_follows_count, :hide_follows_count,
:hide_followers, :hide_followers,
@ -210,6 +209,7 @@ def update_credentials(%{assigns: %{user: user}, body_params: params} = conn, _p
if bot, do: {:ok, "Service"}, else: {:ok, "Person"} if bot, do: {:ok, "Service"}, else: {:ok, "Person"}
end) end)
|> Maps.put_if_present(:actor_type, params[:actor_type]) |> Maps.put_if_present(:actor_type, params[:actor_type])
|> Maps.put_if_present(:is_locked, params[:locked])
# What happens here: # What happens here:
# #

View file

@ -242,7 +242,7 @@ defp do_render("show.json", %{user: user} = opts) do
username: username_from_nickname(user.nickname), username: username_from_nickname(user.nickname),
acct: user.nickname, acct: user.nickname,
display_name: display_name, display_name: display_name,
locked: user.locked, locked: user.is_locked,
created_at: Utils.to_masto_date(user.inserted_at), created_at: Utils.to_masto_date(user.inserted_at),
followers_count: followers_count, followers_count: followers_count,
following_count: following_count, following_count: following_count,

View file

@ -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

View file

@ -248,14 +248,19 @@ test "All statuses set" do
user = User.get_cached_by_nickname(user.nickname) user = User.get_cached_by_nickname(user.nickname)
assert user.is_moderator assert user.is_moderator
assert user.locked assert user.is_locked
assert user.is_admin assert user.is_admin
refute user.confirmation_pending refute user.confirmation_pending
end end
test "All statuses unset" do test "All statuses unset" do
user = 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([ Mix.Tasks.Pleroma.User.run([
"set", "set",
@ -280,7 +285,7 @@ test "All statuses unset" do
user = User.get_cached_by_nickname(user.nickname) user = User.get_cached_by_nickname(user.nickname)
refute user.is_moderator refute user.is_moderator
refute user.locked refute user.is_locked
refute user.is_admin refute user.is_admin
assert user.confirmation_pending assert user.confirmation_pending
end end

View file

@ -346,7 +346,7 @@ test "it creates notifications when someone likes user's status with a filtered
describe "follow / follow_request notifications" do describe "follow / follow_request notifications" do
test "it creates `follow` notification for approved Follow activity" do test "it creates `follow` notification for approved Follow activity" do
user = insert(:user) user = insert(:user)
followed_user = insert(:user, locked: false) followed_user = insert(:user, is_locked: false)
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user) {:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
assert FollowingRelationship.following?(user, followed_user) assert FollowingRelationship.following?(user, followed_user)
@ -361,7 +361,7 @@ test "it creates `follow` notification for approved Follow activity" do
test "it creates `follow_request` notification for pending Follow activity" do test "it creates `follow_request` notification for pending Follow activity" do
user = insert(:user) user = insert(:user)
followed_user = insert(:user, locked: true) followed_user = insert(:user, is_locked: true)
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user) {:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
refute FollowingRelationship.following?(user, followed_user) refute FollowingRelationship.following?(user, followed_user)
@ -383,7 +383,7 @@ test "it creates `follow_request` notification for pending Follow activity" do
test "it doesn't create a notification for follow-unfollow-follow chains" do test "it doesn't create a notification for follow-unfollow-follow chains" do
user = insert(:user) user = insert(:user)
followed_user = insert(:user, locked: false) followed_user = insert(:user, is_locked: false)
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user) {:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
assert FollowingRelationship.following?(user, followed_user) assert FollowingRelationship.following?(user, followed_user)
@ -397,7 +397,7 @@ test "it doesn't create a notification for follow-unfollow-follow chains" do
end end
test "dismisses the notification on follow request rejection" do test "dismisses the notification on follow request rejection" do
user = insert(:user, locked: true) user = insert(:user, is_locked: true)
follower = insert(:user) follower = insert(:user)
{:ok, _, _, _follow_activity} = CommonAPI.follow(follower, user) {:ok, _, _, _follow_activity} = CommonAPI.follow(follower, user)
assert [notification] = Notification.for_user(user) assert [notification] = Notification.for_user(user)

View file

@ -174,7 +174,7 @@ test "ap_following returns the following collection for the user" do
test "returns all pending follow requests" do test "returns all pending follow requests" do
unlocked = insert(:user) unlocked = insert(:user)
locked = insert(:user, locked: true) locked = insert(:user, is_locked: true)
follower = insert(:user) follower = insert(:user)
CommonAPI.follow(follower, unlocked) CommonAPI.follow(follower, unlocked)
@ -187,7 +187,7 @@ test "returns all pending follow requests" do
end end
test "doesn't return already accepted or duplicate follow requests" do 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) pending_follower = insert(:user)
accepted_follower = insert(:user) accepted_follower = insert(:user)
@ -201,7 +201,7 @@ test "doesn't return already accepted or duplicate follow requests" do
end end
test "doesn't return follow requests for deactivated accounts" do 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}) pending_follower = insert(:user, %{deactivated: true})
CommonAPI.follow(pending_follower, locked) CommonAPI.follow(pending_follower, locked)
@ -211,7 +211,7 @@ test "doesn't return follow requests for deactivated accounts" do
end end
test "clears follow requests when requester is blocked" do test "clears follow requests when requester is blocked" do
followed = insert(:user, locked: true) followed = insert(:user, is_locked: true)
follower = insert(:user) follower = insert(:user)
CommonAPI.follow(follower, followed) CommonAPI.follow(follower, followed)
@ -299,8 +299,8 @@ test "can't subscribe to a user who blocked us" do
end end
test "local users do not automatically follow local locked accounts" do test "local users do not automatically follow local locked accounts" do
follower = insert(:user, locked: true) follower = insert(:user, is_locked: true)
followed = insert(:user, locked: true) followed = insert(:user, is_locked: true)
{:ok, follower} = User.maybe_direct_follow(follower, followed) {:ok, follower} = User.maybe_direct_follow(follower, followed)
@ -1360,7 +1360,7 @@ test "it deactivates a user, all follow relationships and all activities", %{use
follower = insert(:user) follower = insert(:user)
{:ok, follower} = User.follow(follower, 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) {:ok, _} = User.follow(user, locked_user, :follow_pending)
object = insert(:note, user: user) object = insert(:note, user: user)
@ -1450,7 +1450,7 @@ test "delete/1 purges a user when they wouldn't be fully deleted" do
note_count: 9, note_count: 9,
follower_count: 9, follower_count: 9,
following_count: 9001, following_count: 9001,
locked: true, is_locked: true,
confirmation_pending: true, confirmation_pending: true,
password_reset_pending: true, password_reset_pending: true,
approval_pending: true, approval_pending: true,
@ -1492,7 +1492,7 @@ test "delete/1 purges a user when they wouldn't be fully deleted" do
note_count: 0, note_count: 0,
follower_count: 0, follower_count: 0,
following_count: 0, following_count: 0,
locked: false, is_locked: false,
confirmation_pending: false, confirmation_pending: false,
password_reset_pending: false, password_reset_pending: false,
approval_pending: false, approval_pending: false,

View file

@ -1120,7 +1120,7 @@ test "creates an undo activity for the last follow" do
test "creates an undo activity for a pending follow request" do test "creates an undo activity for a pending follow request" do
follower = insert(:user) follower = insert(:user)
followed = insert(:user, %{locked: true}) followed = insert(:user, %{is_locked: true})
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed) {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
{:ok, activity} = ActivityPub.unfollow(follower, followed) {:ok, activity} = ActivityPub.unfollow(follower, followed)

View file

@ -46,7 +46,7 @@ test "it works for incoming accepts which were pre-accepted" do
test "it works for incoming accepts which are referenced by IRI only" do test "it works for incoming accepts which are referenced by IRI only" do
follower = insert(:user) follower = insert(:user)
followed = insert(:user, locked: true) followed = insert(:user, is_locked: true)
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed) {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
@ -72,7 +72,7 @@ test "it works for incoming accepts which are referenced by IRI only" do
test "it fails for incoming accepts which cannot be correlated" do test "it fails for incoming accepts which cannot be correlated" do
follower = insert(:user) follower = insert(:user)
followed = insert(:user, locked: true) followed = insert(:user, is_locked: true)
accept_data = accept_data =
File.read!("test/fixtures/mastodon-accept-activity.json") File.read!("test/fixtures/mastodon-accept-activity.json")

View file

@ -65,7 +65,7 @@ test "it works for incoming follow requests" do
end end
test "with locked accounts, it does create a Follow, but not an Accept" do 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 = data =
File.read!("test/fixtures/mastodon-follow-activity.json") File.read!("test/fixtures/mastodon-follow-activity.json")
@ -188,7 +188,7 @@ test "it works for incoming follow requests from hubzilla" do
test "it works for incoming follows to locked account" do test "it works for incoming follows to locked account" do
pending_follower = insert(:user, ap_id: "http://mastodon.example.org/users/admin") pending_follower = insert(:user, ap_id: "http://mastodon.example.org/users/admin")
user = insert(:user, locked: true) user = insert(:user, is_locked: true)
data = data =
File.read!("test/fixtures/mastodon-follow-activity.json") File.read!("test/fixtures/mastodon-follow-activity.json")

View file

@ -14,7 +14,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.RejectHandlingTest do
test "it fails for incoming rejects which cannot be correlated" do test "it fails for incoming rejects which cannot be correlated" do
follower = insert(:user) follower = insert(:user)
followed = insert(:user, locked: true) followed = insert(:user, is_locked: true)
accept_data = accept_data =
File.read!("test/fixtures/mastodon-reject-activity.json") File.read!("test/fixtures/mastodon-reject-activity.json")
@ -33,7 +33,7 @@ test "it fails for incoming rejects which cannot be correlated" do
test "it works for incoming rejects which are referenced by IRI only" do test "it works for incoming rejects which are referenced by IRI only" do
follower = insert(:user) follower = insert(:user)
followed = insert(:user, locked: true) followed = insert(:user, is_locked: true)
{:ok, follower} = User.follow(follower, followed) {:ok, follower} = User.follow(follower, followed)
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed) {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)

View file

@ -154,6 +154,6 @@ test "it works for incoming update activities which lock the account" do
{:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(update_data) {:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(update_data)
user = User.get_cached_by_ap_id(user.ap_id) user = User.get_cached_by_ap_id(user.ap_id)
assert user.locked == true assert user.is_locked == true
end end
end end

View file

@ -193,7 +193,7 @@ test "fetches only Create activities" do
describe "update_follow_state_for_all/2" do describe "update_follow_state_for_all/2" do
test "updates the state of all Follow activities with the same actor and object" 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) follower = insert(:user)
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, user) {:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)
@ -217,7 +217,7 @@ test "updates the state of all Follow activities with the same actor and object"
describe "update_follow_state/2" do describe "update_follow_state/2" do
test "updates the state of the given follow activity" 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) follower = insert(:user)
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, user) {:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)

View file

@ -1071,7 +1071,7 @@ test "also unsubscribes a user" do
test "cancels a pending follow for a local user" do test "cancels a pending follow for a local user" do
follower = insert(:user) follower = insert(:user)
followed = insert(:user, locked: true) followed = insert(:user, is_locked: true)
assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} = assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
CommonAPI.follow(follower, followed) CommonAPI.follow(follower, followed)
@ -1093,7 +1093,7 @@ test "cancels a pending follow for a local user" do
test "cancels a pending follow for a remote user" do test "cancels a pending follow for a remote user" do
follower = insert(:user) 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"}}} = assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
CommonAPI.follow(follower, followed) CommonAPI.follow(follower, followed)
@ -1116,7 +1116,7 @@ test "cancels a pending follow for a remote user" do
describe "accept_follow_request/2" do describe "accept_follow_request/2" do
test "after acceptance, it sets all existing pending follow request states to 'accept'" 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 = insert(:user)
follower_two = insert(:user) follower_two = insert(:user)
@ -1136,7 +1136,7 @@ test "after acceptance, it sets all existing pending follow request states to 'a
end end
test "after rejection, it sets all existing pending follow request states to 'reject'" do 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 = insert(:user)
follower_two = insert(:user) follower_two = insert(:user)
@ -1156,7 +1156,7 @@ test "after rejection, it sets all existing pending follow request states to 're
end end
test "doesn't create a following relationship if the corresponding follow request doesn't exist" do 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) not_follower = insert(:user)
CommonAPI.accept_follow_request(not_follower, user) CommonAPI.accept_follow_request(not_follower, user)

View file

@ -706,7 +706,7 @@ test "following / unfollowing a user", %{conn: conn} do
end end
test "cancelling follow request", %{conn: conn} do 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} = assert %{"id" => ^other_user_id, "following" => false, "requested" => true} =
conn conn

View file

@ -12,7 +12,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do
describe "locked accounts" do describe "locked accounts" do
setup do setup do
user = insert(:user, locked: true) user = insert(:user, is_locked: true)
%{conn: conn} = oauth_access(["follow"], user: user) %{conn: conn} = oauth_access(["follow"], user: user)
%{user: user, conn: conn} %{user: user, conn: conn}
end end

View file

@ -332,7 +332,7 @@ test "represent a relationship for the user blocking a domain" do
test "represent a relationship for the user with a pending follow request" do test "represent a relationship for the user with a pending follow request" do
user = insert(:user) 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) {:ok, user, other_user, _} = CommonAPI.follow(user, other_user)
user = User.get_cached_by_id(user.id) user = User.get_cached_by_id(user.id)
@ -481,7 +481,7 @@ test "shows zero when no follow requests are pending" do
end end
test "shows non-zero when follow requests are pending" do 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 %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
@ -493,7 +493,7 @@ test "shows non-zero when follow requests are pending" do
end end
test "decreases when accepting a follow request" do 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 %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
@ -510,7 +510,7 @@ test "decreases when accepting a follow request" do
end end
test "decreases when rejecting a follow request" do 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 %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
@ -527,14 +527,14 @@ test "decreases when rejecting a follow request" do
end end
test "shows non-zero when historical unapproved requests are present" do 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 %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
other_user = insert(:user) other_user = insert(:user)
{:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, 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 %{locked: false, follow_requests_count: 1} =
AccountView.render("show.json", %{user: user, for: user}) AccountView.render("show.json", %{user: user, for: user})