aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/user.ex8
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex14
-rw-r--r--lib/pleroma/web/router.ex5
3 files changed, 23 insertions, 4 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index c8e61f8a9..aecf96c36 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -481,9 +481,11 @@ defmodule Pleroma.User do
blocks = user.info["blocks"] || []
domain_blocks = user.info["domain_blocks"] || []
%{host: host} = URI.parse(ap_id)
- Enum.member?(blocks, ap_id) || Enum.any?(domain_blocks, fn domain ->
- host == domain
- end)
+
+ Enum.member?(blocks, ap_id) ||
+ Enum.any?(domain_blocks, fn domain ->
+ host == domain
+ end)
end
def block_domain(user, domain) do
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index 5fb51e8fa..12f9b5f7c 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -533,6 +533,20 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
end
end
+ def domain_blocks(%{assigns: %{user: %{info: info}}} = conn, _) do
+ json(conn, info["domain_blocks"] || [])
+ end
+
+ def block_domain(%{assigns: %{user: blocker}} = conn, %{"domain" => domain}) do
+ User.block_domain(blocker, domain)
+ json(conn, %{})
+ end
+
+ def unblock_domain(%{assigns: %{user: blocker}} = conn, %{"domain" => domain}) do
+ User.unblock_domain(blocker, domain)
+ json(conn, %{})
+ end
+
def search(%{assigns: %{user: user}} = conn, %{"q" => query} = params) do
accounts = User.search(query, params["resolve"] == "true")
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index 924254895..57b10bff1 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -101,7 +101,6 @@ defmodule Pleroma.Web.Router do
get("/blocks", MastodonAPIController, :blocks)
- get("/domain_blocks", MastodonAPIController, :empty_array)
get("/follow_requests", MastodonAPIController, :empty_array)
get("/mutes", MastodonAPIController, :empty_array)
@@ -134,6 +133,10 @@ defmodule Pleroma.Web.Router do
get("/lists/:id/accounts", MastodonAPIController, :list_accounts)
post("/lists/:id/accounts", MastodonAPIController, :add_to_list)
delete("/lists/:id/accounts", MastodonAPIController, :remove_from_list)
+
+ get("/domain_blocks", MastodonAPIController, :domain_blocks)
+ post("/domain_blocks", MastodonAPIController, :block_domain)
+ delete("/domain_blocks", MastodonAPIController, :unblock_domain)
end
scope "/api/web", Pleroma.Web.MastodonAPI do