Undo API breaking changes

This commit is contained in:
Mark Felder 2020-10-14 11:03:17 -05:00
parent 8b20c4d275
commit ed61002815
8 changed files with 21 additions and 21 deletions

View file

@ -519,7 +519,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
description: "Header image encoded using multipart/form-data", description: "Header image encoded using multipart/form-data",
format: :binary format: :binary
}, },
is_locked: %Schema{ locked: %Schema{
allOf: [BooleanLike], allOf: [BooleanLike],
nullable: true, nullable: true,
description: "Whether manual approval of follow requests is required." description: "Whether manual approval of follow requests is required."

View file

@ -259,7 +259,7 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
"fields" => [] "fields" => []
}, },
"statuses_count" => 1, "statuses_count" => 1,
"is_locked" => false, "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

@ -32,7 +32,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
header_static: %Schema{type: :string, format: :uri}, header_static: %Schema{type: :string, format: :uri},
header: %Schema{type: :string, format: :uri}, header: %Schema{type: :string, format: :uri},
id: FlakeID, id: FlakeID,
is_locked: %Schema{type: :boolean}, locked: %Schema{type: :boolean},
note: %Schema{type: :string, format: :html}, note: %Schema{type: :string, format: :html},
statuses_count: %Schema{type: :integer}, statuses_count: %Schema{type: :integer},
url: %Schema{type: :string, format: :uri}, 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" => "https://mypleroma.com/images/banner.png",
"header_static" => "https://mypleroma.com/images/banner.png", "header_static" => "https://mypleroma.com/images/banner.png",
"id" => "9tKi3esbG7OQgZ2920", "id" => "9tKi3esbG7OQgZ2920",
"is_locked" => false, "locked" => false,
"note" => "cofe", "note" => "cofe",
"pleroma" => %{ "pleroma" => %{
"allow_following_move" => true, "allow_following_move" => true,

View file

@ -177,7 +177,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
user_params = user_params =
[ [
:no_rich_text, :no_rich_text,
:is_locked,
:hide_followers_count, :hide_followers_count,
:hide_follows_count, :hide_follows_count,
:hide_followers, :hide_followers,
@ -210,6 +209,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
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 @@ defmodule Pleroma.Web.MastodonAPI.AccountView 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,
is_locked: user.is_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

@ -1271,7 +1271,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
"follow_requests_count" => 0, "follow_requests_count" => 0,
"followers_count" => 0, "followers_count" => 0,
"following_count" => 0, "following_count" => 0,
"is_locked" => false, "locked" => false,
"note" => "", "note" => "",
"source" => %{ "source" => %{
"fields" => [], "fields" => [],

View file

@ -102,10 +102,10 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
end end
test "updates the user's locking status", %{conn: conn} do test "updates the user's locking status", %{conn: conn} do
conn = patch(conn, "/api/v1/accounts/update_credentials", %{is_locked: "true"}) conn = patch(conn, "/api/v1/accounts/update_credentials", %{locked: "true"})
assert user_data = json_response_and_validate_schema(conn, 200) assert user_data = json_response_and_validate_schema(conn, 200)
assert user_data["is_locked"] == true assert user_data["locked"] == true
end end
test "updates the user's chat acceptance status", %{conn: conn} do test "updates the user's chat acceptance status", %{conn: conn} do

View file

@ -43,7 +43,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
username: "shp", username: "shp",
acct: user.nickname, acct: user.nickname,
display_name: user.name, display_name: user.name,
is_locked: false, locked: false,
created_at: "2017-08-15T15:47:06.000Z", created_at: "2017-08-15T15:47:06.000Z",
followers_count: 3, followers_count: 3,
following_count: 0, following_count: 0,
@ -148,7 +148,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
username: "shp", username: "shp",
acct: user.nickname, acct: user.nickname,
display_name: user.name, display_name: user.name,
is_locked: false, locked: false,
created_at: "2017-08-15T15:47:06.000Z", created_at: "2017-08-15T15:47:06.000Z",
followers_count: 3, followers_count: 3,
following_count: 0, following_count: 0,
@ -483,60 +483,60 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
test "shows non-zero when follow requests are pending" do test "shows non-zero when follow requests are pending" do
user = insert(:user, is_locked: true) user = insert(:user, is_locked: true)
assert %{is_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)
assert %{is_locked: true, follow_requests_count: 1} = assert %{locked: true, follow_requests_count: 1} =
AccountView.render("show.json", %{user: user, for: user}) AccountView.render("show.json", %{user: user, for: user})
end end
test "decreases when accepting a follow request" do test "decreases when accepting a follow request" do
user = insert(:user, is_locked: true) user = insert(:user, is_locked: true)
assert %{is_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)
assert %{is_locked: true, follow_requests_count: 1} = assert %{locked: true, follow_requests_count: 1} =
AccountView.render("show.json", %{user: user, for: user}) AccountView.render("show.json", %{user: user, for: user})
{:ok, _other_user} = CommonAPI.accept_follow_request(other_user, user) {:ok, _other_user} = CommonAPI.accept_follow_request(other_user, user)
assert %{is_locked: true, follow_requests_count: 0} = assert %{locked: true, follow_requests_count: 0} =
AccountView.render("show.json", %{user: user, for: user}) AccountView.render("show.json", %{user: user, for: user})
end end
test "decreases when rejecting a follow request" do test "decreases when rejecting a follow request" do
user = insert(:user, is_locked: true) user = insert(:user, is_locked: true)
assert %{is_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)
assert %{is_locked: true, follow_requests_count: 1} = assert %{locked: true, follow_requests_count: 1} =
AccountView.render("show.json", %{user: user, for: user}) AccountView.render("show.json", %{user: user, for: user})
{:ok, _other_user} = CommonAPI.reject_follow_request(other_user, user) {:ok, _other_user} = CommonAPI.reject_follow_request(other_user, user)
assert %{is_locked: true, follow_requests_count: 0} = assert %{locked: true, follow_requests_count: 0} =
AccountView.render("show.json", %{user: user, for: user}) AccountView.render("show.json", %{user: user, for: user})
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, is_locked: true) user = insert(:user, is_locked: true)
assert %{is_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, %{is_locked: false}) {:ok, user} = User.update_and_set_cache(user, %{is_locked: false})
assert %{is_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})
end end
end end