AccountController: Make setting accepts_chat_messages possible.
This commit is contained in:
parent
4a7b89e372
commit
e3b5559780
@ -483,7 +483,8 @@ defmodule Pleroma.User do
|
|||||||
:pleroma_settings_store,
|
:pleroma_settings_store,
|
||||||
:discoverable,
|
:discoverable,
|
||||||
:actor_type,
|
:actor_type,
|
||||||
:also_known_as
|
:also_known_as,
|
||||||
|
:accepts_chat_messages
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|> unique_constraint(:nickname)
|
|> unique_constraint(:nickname)
|
||||||
|
@ -61,7 +61,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
|
|||||||
description: "Update the user's display and preferences.",
|
description: "Update the user's display and preferences.",
|
||||||
operationId: "AccountController.update_credentials",
|
operationId: "AccountController.update_credentials",
|
||||||
security: [%{"oAuth" => ["write:accounts"]}],
|
security: [%{"oAuth" => ["write:accounts"]}],
|
||||||
requestBody: request_body("Parameters", update_creadentials_request(), required: true),
|
requestBody: request_body("Parameters", update_credentials_request(), required: true),
|
||||||
responses: %{
|
responses: %{
|
||||||
200 => Operation.response("Account", "application/json", Account),
|
200 => Operation.response("Account", "application/json", Account),
|
||||||
403 => Operation.response("Error", "application/json", ApiError)
|
403 => Operation.response("Error", "application/json", ApiError)
|
||||||
@ -458,7 +458,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp update_creadentials_request do
|
defp update_credentials_request do
|
||||||
%Schema{
|
%Schema{
|
||||||
title: "AccountUpdateCredentialsRequest",
|
title: "AccountUpdateCredentialsRequest",
|
||||||
description: "POST body for creating an account",
|
description: "POST body for creating an account",
|
||||||
@ -492,6 +492,11 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
|
|||||||
nullable: true,
|
nullable: true,
|
||||||
description: "Whether manual approval of follow requests is required."
|
description: "Whether manual approval of follow requests is required."
|
||||||
},
|
},
|
||||||
|
accepts_chat_messages: %Schema{
|
||||||
|
allOf: [BooleanLike],
|
||||||
|
nullable: true,
|
||||||
|
description: "Whether the user accepts receiving chat messages."
|
||||||
|
},
|
||||||
fields_attributes: %Schema{
|
fields_attributes: %Schema{
|
||||||
nullable: true,
|
nullable: true,
|
||||||
oneOf: [
|
oneOf: [
|
||||||
|
@ -160,7 +160,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
|||||||
:show_role,
|
:show_role,
|
||||||
:skip_thread_containment,
|
:skip_thread_containment,
|
||||||
:allow_following_move,
|
:allow_following_move,
|
||||||
:discoverable
|
:discoverable,
|
||||||
|
:accepts_chat_messages
|
||||||
]
|
]
|
||||||
|> Enum.reduce(%{}, fn key, acc ->
|
|> Enum.reduce(%{}, fn key, acc ->
|
||||||
Maps.put_if_present(acc, key, params[key], &{:ok, truthy_param?(&1)})
|
Maps.put_if_present(acc, key, params[key], &{:ok, truthy_param?(&1)})
|
||||||
|
@ -108,6 +108,13 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
|
|||||||
assert user_data["locked"] == true
|
assert user_data["locked"] == true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "updates the user's chat acceptance status", %{conn: conn} do
|
||||||
|
conn = patch(conn, "/api/v1/accounts/update_credentials", %{accepts_chat_messages: "false"})
|
||||||
|
|
||||||
|
assert user_data = json_response_and_validate_schema(conn, 200)
|
||||||
|
assert user_data["pleroma"]["accepts_chat_messages"] == false
|
||||||
|
end
|
||||||
|
|
||||||
test "updates the user's allow_following_move", %{user: user, conn: conn} do
|
test "updates the user's allow_following_move", %{user: user, conn: conn} do
|
||||||
assert user.allow_following_move == true
|
assert user.allow_following_move == true
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user