mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-23 06:58:58 +00:00
ListController: DRY up stuff.
This commit is contained in:
parent
d872858046
commit
581f382e71
|
@ -73,19 +73,6 @@ defmodule Pleroma.Web.MastodonAPI.ListController do
|
||||||
end
|
end
|
||||||
|
|
||||||
# DELETE /api/v1/lists/:id/accounts
|
# DELETE /api/v1/lists/:id/accounts
|
||||||
def remove_from_list(
|
|
||||||
%{assigns: %{list: list}, body_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
|
|
||||||
|
|
||||||
def remove_from_list(
|
def remove_from_list(
|
||||||
%{assigns: %{list: list}, params: %{account_ids: account_ids}} = conn,
|
%{assigns: %{list: list}, params: %{account_ids: account_ids}} = conn,
|
||||||
_
|
_
|
||||||
|
@ -99,6 +86,10 @@ defmodule Pleroma.Web.MastodonAPI.ListController do
|
||||||
json(conn, %{})
|
json(conn, %{})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remove_from_list(%{body_params: params} = conn, _) do
|
||||||
|
remove_from_list(%{conn | params: params}, %{})
|
||||||
|
end
|
||||||
|
|
||||||
defp list_by_id_and_user(%{assigns: %{user: user}, params: %{id: id}} = conn, _) do
|
defp list_by_id_and_user(%{assigns: %{user: user}, params: %{id: id}} = conn, _) do
|
||||||
case Pleroma.List.get(id, user) do
|
case Pleroma.List.get(id, user) do
|
||||||
%Pleroma.List{} = list -> assign(conn, :list, list)
|
%Pleroma.List{} = list -> assign(conn, :list, list)
|
||||||
|
|
Loading…
Reference in a new issue