Add specs for ActorType and VisibilityScope
This commit is contained in:
parent
260cbddc94
commit
ab400b2ddb
@ -6,6 +6,8 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
|
|||||||
alias OpenApiSpex.Schema
|
alias OpenApiSpex.Schema
|
||||||
alias Pleroma.Web.ApiSpec.Schemas.AccountEmoji
|
alias Pleroma.Web.ApiSpec.Schemas.AccountEmoji
|
||||||
alias Pleroma.Web.ApiSpec.Schemas.AccountField
|
alias Pleroma.Web.ApiSpec.Schemas.AccountField
|
||||||
|
alias Pleroma.Web.ApiSpec.Schemas.ActorType
|
||||||
|
alias Pleroma.Web.ApiSpec.Schemas.VisibilityScope
|
||||||
|
|
||||||
require OpenApiSpex
|
require OpenApiSpex
|
||||||
|
|
||||||
@ -87,12 +89,12 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
|
|||||||
properties: %{
|
properties: %{
|
||||||
fields: %Schema{type: :array, items: AccountField},
|
fields: %Schema{type: :array, items: AccountField},
|
||||||
note: %Schema{type: :string},
|
note: %Schema{type: :string},
|
||||||
privacy: %Schema{type: :string},
|
privacy: VisibilityScope,
|
||||||
sensitive: %Schema{type: :boolean},
|
sensitive: %Schema{type: :boolean},
|
||||||
pleroma: %Schema{
|
pleroma: %Schema{
|
||||||
type: :object,
|
type: :object,
|
||||||
properties: %{
|
properties: %{
|
||||||
actor_type: %Schema{type: :string},
|
actor_type: ActorType,
|
||||||
discoverable: %Schema{type: :boolean},
|
discoverable: %Schema{type: :boolean},
|
||||||
no_rich_text: %Schema{type: :boolean},
|
no_rich_text: %Schema{type: :boolean},
|
||||||
show_role: %Schema{type: :boolean}
|
show_role: %Schema{type: :boolean}
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
defmodule Pleroma.Web.ApiSpec.Schemas.AccountUpdateCredentialsRequest do
|
defmodule Pleroma.Web.ApiSpec.Schemas.AccountUpdateCredentialsRequest do
|
||||||
alias OpenApiSpex.Schema
|
alias OpenApiSpex.Schema
|
||||||
alias Pleroma.Web.ApiSpec.Schemas.AccountAttributeField
|
alias Pleroma.Web.ApiSpec.Schemas.AccountAttributeField
|
||||||
|
alias Pleroma.Web.ApiSpec.Schemas.ActorType
|
||||||
|
alias Pleroma.Web.ApiSpec.Schemas.VisibilityScope
|
||||||
require OpenApiSpex
|
require OpenApiSpex
|
||||||
|
|
||||||
OpenApiSpex.schema(%{
|
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
|
description: "user's role (e.g admin, moderator) will be exposed to anyone in the
|
||||||
API"
|
API"
|
||||||
},
|
},
|
||||||
default_scope: %Schema{
|
default_scope: VisibilityScope,
|
||||||
type: :string,
|
|
||||||
description: "The scope returned under privacy key in Source subentity"
|
|
||||||
},
|
|
||||||
pleroma_settings_store: %Schema{
|
pleroma_settings_store: %Schema{
|
||||||
type: :object,
|
type: :object,
|
||||||
description: "Opaque user settings to be saved on the backend."
|
description: "Opaque user settings to be saved on the backend."
|
||||||
@ -98,7 +97,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.AccountUpdateCredentialsRequest do
|
|||||||
type: :boolean,
|
type: :boolean,
|
||||||
description: "Discovery of this account in search results and other services is allowed."
|
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: %{
|
example: %{
|
||||||
bot: false,
|
bot: false,
|
||||||
|
13
lib/pleroma/web/api_spec/schemas/actor_type.ex
Normal file
13
lib/pleroma/web/api_spec/schemas/actor_type.ex
Normal 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
|
14
lib/pleroma/web/api_spec/schemas/visibility_scope.ex
Normal file
14
lib/pleroma/web/api_spec/schemas/visibility_scope.ex
Normal 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
|
@ -106,10 +106,10 @@ test "updates the user's allow_following_move", %{user: user, conn: conn} do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "updates the user's default scope", %{conn: conn} do
|
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 = json_response(conn, 200)
|
||||||
assert user_data["source"]["privacy"] == "cofe"
|
assert user_data["source"]["privacy"] == "unlisted"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "updates the user's hide_followers status", %{conn: conn} do
|
test "updates the user's hide_followers status", %{conn: conn} do
|
||||||
|
Loading…
Reference in New Issue
Block a user