Repo.all(query)
end
+ # Get lists to which the account belongs.
+ def get_lists_account_belongs(%User{} = owner, account_id) do
+ user = Repo.get(User, account_id)
+ query =
+ from(
+ l in Pleroma.List,
+ where: l.user_id == ^owner.id and fragment("? = ANY(?)", ^user.follower_address, l.following)
+ )
+ Repo.all(query)
+ end
+
def rename(%Pleroma.List{} = list, title) do
list
|> title_changeset(%{title: title})
end
end
+ def account_lists(%{assigns: %{user: user}} = conn, %{"id" => account_id}) do
+ lists = Pleroma.List.get_lists_account_belongs(user, account_id)
+ res = ListView.render("lists.json", lists: lists)
+ json(conn, res)
+ end
+
def delete_list(%{assigns: %{user: user}} = conn, %{"id" => id}) do
with %Pleroma.List{} = list <- Pleroma.List.get(id, user),
{:ok, _list} <- Pleroma.List.delete(list) do
post("/accounts/:id/unblock", MastodonAPIController, :unblock)
post("/accounts/:id/mute", MastodonAPIController, :relationship_noop)
post("/accounts/:id/unmute", MastodonAPIController, :relationship_noop)
+ get("/accounts/:id/lists", MastodonAPIController, :account_lists)
get("/follow_requests", MastodonAPIController, :follow_requests)
post("/follow_requests/:id/authorize", MastodonAPIController, :authorize_follow_request)