summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/pleroma/following_relationship.ex24
-rw-r--r--lib/pleroma/notification.ex19
-rw-r--r--test/pleroma/notification_test.exs12
4 files changed, 19 insertions, 37 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 889a3ebfe..99d267599 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- **Breaking**: `/api/v1/pleroma/backups` endpoints now requires `read:backups` scope instead of `read:accounts`
- Updated the recommended pleroma.vcl configuration for Varnish to target Varnish 7.0+
- Set timeout values for Oban queues. The default is infinity and some operations may not time out on their own.
+- Follows no longer override domain blocks, a domain block is final
### Added
- `activeMonth` and `activeHalfyear` fields in NodeInfo usage.users object
diff --git a/lib/pleroma/following_relationship.ex b/lib/pleroma/following_relationship.ex
index 15664c876..2b81eb526 100644
--- a/lib/pleroma/following_relationship.ex
+++ b/lib/pleroma/following_relationship.ex
@@ -240,30 +240,6 @@ defmodule Pleroma.FollowingRelationship do
end)
end
- @doc """
- For a query with joined activity,
- keeps rows where activity's actor is followed by user -or- is NOT domain-blocked by user.
- """
- def keep_following_or_not_domain_blocked(query, user) do
- where(
- query,
- [_, activity],
- fragment(
- # "(actor's domain NOT in domain_blocks) OR (actor IS in followed AP IDs)"
- """
- NOT (substring(? from '.*://([^/]*)') = ANY(?)) OR
- ? = ANY(SELECT ap_id FROM users AS u INNER JOIN following_relationships AS fr
- ON u.id = fr.following_id WHERE fr.follower_id = ? AND fr.state = ?)
- """,
- activity.actor,
- ^user.domain_blocks,
- activity.actor,
- ^User.binary_id(user.id),
- ^accept_state_code()
- )
- )
- end
-
defp validate_not_self_relationship(%Changeset{} = changeset) do
changeset
|> validate_follower_id_following_id_inequality()
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex
index c2d4d86a3..8f2b54496 100644
--- a/lib/pleroma/notification.ex
+++ b/lib/pleroma/notification.ex
@@ -138,7 +138,24 @@ defmodule Pleroma.Notification do
query
|> where([n, a], a.actor not in ^blocked_ap_ids)
- |> FollowingRelationship.keep_following_or_not_domain_blocked(user)
+ |> restrict_domain_blocked(user)
+ end
+
+ defp restrict_domain_blocked(query, user) do
+ where(
+ query,
+ [_, activity],
+ fragment(
+ # "(actor's domain NOT in domain_blocks)"
+ """
+ NOT (
+ substring(? from '.*://([^/]*)') = ANY(?)
+ )
+ """,
+ activity.actor,
+ ^user.domain_blocks
+ )
+ )
end
defp exclude_blockers(query, user) do
diff --git a/test/pleroma/notification_test.exs b/test/pleroma/notification_test.exs
index a000c0efd..d966b2b49 100644
--- a/test/pleroma/notification_test.exs
+++ b/test/pleroma/notification_test.exs
@@ -1150,18 +1150,6 @@ defmodule Pleroma.NotificationTest do
assert Notification.for_user(user) == []
end
- test "it returns notifications for domain-blocked but followed user" do
- user = insert(:user)
- blocked = insert(:user, ap_id: "http://some-domain.com")
-
- {:ok, user} = User.block_domain(user, "some-domain.com")
- {:ok, _, _} = User.follow(user, blocked)
-
- {:ok, _activity} = CommonAPI.post(blocked, %{status: "hey @#{user.nickname}"})
-
- assert length(Notification.for_user(user)) == 1
- end
-
test "it doesn't return notifications for muted thread", %{user: user} do
another_user = insert(:user)