Implement mastodon mutes endpoint

Aparently i forgot to add it, it gets a list of muted users
This commit is contained in:
Ekaterina Vaartis 2018-09-02 00:33:13 +03:00
parent f41f017bbc
commit da64ea4a55
2 changed files with 10 additions and 1 deletions

View file

@ -780,6 +780,15 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
end end
end end
# TODO: Use proper query
def mutes(%{assigns: %{user: user}} = conn, _) do
with muted_users <- user.info["mutes"] || [],
accounts <- Enum.map(muted_users, fn ap_id -> User.get_cached_by_ap_id(ap_id) end) do
res = AccountView.render("accounts.json", users: accounts, for: user, as: :user)
json(conn, res)
end
end
def block(%{assigns: %{user: blocker}} = conn, %{"id" => id}) do def block(%{assigns: %{user: blocker}} = conn, %{"id" => id}) do
with %User{} = blocked <- Repo.get(User, id), with %User{} = blocked <- Repo.get(User, id),
{:ok, blocker} <- User.block(blocker, blocked), {:ok, blocker} <- User.block(blocker, blocked),

View file

@ -178,7 +178,7 @@ defmodule Pleroma.Web.Router do
get("/blocks", MastodonAPIController, :blocks) get("/blocks", MastodonAPIController, :blocks)
get("/mutes", MastodonAPIController, :empty_array) get("/mutes", MastodonAPIController, :mutes)
get("/timelines/home", MastodonAPIController, :home_timeline) get("/timelines/home", MastodonAPIController, :home_timeline)