MastoAPI: Add list of blocked users.

This commit is contained in:
Roger Braun 2017-11-03 08:51:17 +01:00
commit c6b9b777da
3 changed files with 25 additions and 1 deletions

View file

@ -335,6 +335,15 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
end
end
# TODO: Use proper query
def blocks(%{assigns: %{user: user}} = conn, _) do
with blocked_users <- user.info["blocks"] || [],
accounts <- Enum.map(blocked_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 search(%{assigns: %{user: user}} = conn, %{"q" => query} = params) do
accounts = User.search(query, params["resolve"] == "true")

View file

@ -65,7 +65,8 @@ defmodule Pleroma.Web.Router do
post "/follows", MastodonAPIController, :follow
get "/blocks", MastodonAPIController, :empty_array
get "/blocks", MastodonAPIController, :blocks
get "/domain_blocks", MastodonAPIController, :empty_array
get "/follow_requests", MastodonAPIController, :empty_array
get "/mutes", MastodonAPIController, :empty_array