Fix removing an account from a list
Mastodon (Frontend) changed a different method for deletes, keeping old format as mastodon documentation is too loose
This commit is contained in:
parent
d48755791d
commit
d872858046
3 changed files with 46 additions and 7 deletions
|
|
@ -114,7 +114,7 @@ defmodule Pleroma.Web.ApiSpec.ListOperation do
|
|||
description: "Add accounts to the given list.",
|
||||
operationId: "ListController.add_to_list",
|
||||
parameters: [id_param()],
|
||||
requestBody: add_remove_accounts_request(),
|
||||
requestBody: add_remove_accounts_request(true),
|
||||
security: [%{"oAuth" => ["write:lists"]}],
|
||||
responses: %{
|
||||
200 => Operation.response("Empty object", "application/json", %Schema{type: :object})
|
||||
|
|
@ -127,8 +127,16 @@ defmodule Pleroma.Web.ApiSpec.ListOperation do
|
|||
tags: ["Lists"],
|
||||
summary: "Remove accounts from list",
|
||||
operationId: "ListController.remove_from_list",
|
||||
parameters: [id_param()],
|
||||
requestBody: add_remove_accounts_request(),
|
||||
parameters: [
|
||||
id_param(),
|
||||
Operation.parameter(
|
||||
:account_ids,
|
||||
:query,
|
||||
%Schema{type: :array, items: %Schema{type: :string}},
|
||||
"Array of account IDs"
|
||||
)
|
||||
],
|
||||
requestBody: add_remove_accounts_request(false),
|
||||
security: [%{"oAuth" => ["write:lists"]}],
|
||||
responses: %{
|
||||
200 => Operation.response("Empty object", "application/json", %Schema{type: :object})
|
||||
|
|
@ -171,7 +179,7 @@ defmodule Pleroma.Web.ApiSpec.ListOperation do
|
|||
)
|
||||
end
|
||||
|
||||
defp add_remove_accounts_request do
|
||||
defp add_remove_accounts_request(required) when is_boolean(required) do
|
||||
request_body(
|
||||
"Parameters",
|
||||
%Schema{
|
||||
|
|
@ -180,9 +188,9 @@ defmodule Pleroma.Web.ApiSpec.ListOperation do
|
|||
properties: %{
|
||||
account_ids: %Schema{type: :array, description: "Array of account IDs", items: FlakeID}
|
||||
},
|
||||
required: [:account_ids]
|
||||
required: required && [:account_ids]
|
||||
},
|
||||
required: true
|
||||
required: required
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -86,6 +86,19 @@ defmodule Pleroma.Web.MastodonAPI.ListController do
|
|||
json(conn, %{})
|
||||
end
|
||||
|
||||
def remove_from_list(
|
||||
%{assigns: %{list: list}, params: %{account_ids: account_ids}} = conn,
|
||||
_
|
||||
) do
|
||||
Enum.each(account_ids, fn account_id ->
|
||||
with %User{} = followed <- User.get_cached_by_id(account_id) do
|
||||
Pleroma.List.unfollow(list, followed)
|
||||
end
|
||||
end)
|
||||
|
||||
json(conn, %{})
|
||||
end
|
||||
|
||||
defp list_by_id_and_user(%{assigns: %{user: user}, params: %{id: id}} = conn, _) do
|
||||
case Pleroma.List.get(id, user) do
|
||||
%Pleroma.List{} = list -> assign(conn, :list, list)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue