Add specs for ActorType and VisibilityScope

This commit is contained in:
Egor Kislitsyn 2020-04-07 16:18:23 +04:00
parent 260cbddc94
commit ab400b2ddb
No known key found for this signature in database
GPG key ID: 1B49CB15B71E7805
5 changed files with 37 additions and 9 deletions

View file

@ -6,6 +6,8 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
alias OpenApiSpex.Schema
alias Pleroma.Web.ApiSpec.Schemas.AccountEmoji
alias Pleroma.Web.ApiSpec.Schemas.AccountField
alias Pleroma.Web.ApiSpec.Schemas.ActorType
alias Pleroma.Web.ApiSpec.Schemas.VisibilityScope
require OpenApiSpex
@ -87,12 +89,12 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
properties: %{
fields: %Schema{type: :array, items: AccountField},
note: %Schema{type: :string},
privacy: %Schema{type: :string},
privacy: VisibilityScope,
sensitive: %Schema{type: :boolean},
pleroma: %Schema{
type: :object,
properties: %{
actor_type: %Schema{type: :string},
actor_type: ActorType,
discoverable: %Schema{type: :boolean},
no_rich_text: %Schema{type: :boolean},
show_role: %Schema{type: :boolean}

View file

@ -5,6 +5,8 @@
defmodule Pleroma.Web.ApiSpec.Schemas.AccountUpdateCredentialsRequest do
alias OpenApiSpex.Schema
alias Pleroma.Web.ApiSpec.Schemas.AccountAttributeField
alias Pleroma.Web.ApiSpec.Schemas.ActorType
alias Pleroma.Web.ApiSpec.Schemas.VisibilityScope
require OpenApiSpex
OpenApiSpex.schema(%{
@ -73,10 +75,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.AccountUpdateCredentialsRequest do
description: "user's role (e.g admin, moderator) will be exposed to anyone in the
API"
},
default_scope: %Schema{
type: :string,
description: "The scope returned under privacy key in Source subentity"
},
default_scope: VisibilityScope,
pleroma_settings_store: %Schema{
type: :object,
description: "Opaque user settings to be saved on the backend."
@ -98,7 +97,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.AccountUpdateCredentialsRequest do
type: :boolean,
description: "Discovery of this account in search results and other services is allowed."
},
actor_type: %Schema{type: :string, description: "the type of this account."}
actor_type: ActorType
},
example: %{
bot: false,

View file

@ -0,0 +1,13 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ApiSpec.Schemas.ActorType do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "ActorType",
type: :string,
enum: ["Application", "Group", "Organization", "Person", "Service"]
})
end

View file

@ -0,0 +1,14 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ApiSpec.Schemas.VisibilityScope do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "VisibilityScope",
description: "Status visibility",
type: :string,
enum: ["public", "unlisted", "private", "direct"]
})
end

View file

@ -106,10 +106,10 @@ test "updates the user's allow_following_move", %{user: user, conn: conn} do
end
test "updates the user's default scope", %{conn: conn} do
conn = patch(conn, "/api/v1/accounts/update_credentials", %{default_scope: "cofe"})
conn = patch(conn, "/api/v1/accounts/update_credentials", %{default_scope: "unlisted"})
assert user_data = json_response(conn, 200)
assert user_data["source"]["privacy"] == "cofe"
assert user_data["source"]["privacy"] == "unlisted"
end
test "updates the user's hide_followers status", %{conn: conn} do