Skip to content

Commit

Permalink
https://github.com/bonfire-networks/bonfire-app/issues/900
Browse files Browse the repository at this point in the history
  • Loading branch information
mayel committed Jan 8, 2025
1 parent 5ccafcd commit 8a2e191
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/activities.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ defmodule Bonfire.Social.Activities do
end
end

def maybe_filter(query, {:circles, circle_ids}, opts) do
def maybe_filter(query, {:subject_circles, circle_ids}, opts) do
case Types.uids(circle_ids, nil) do
nil ->
warn(circle_ids, "unrecognized circle_ids")
Expand All @@ -1315,7 +1315,7 @@ defmodule Bonfire.Social.Activities do
end
end

def maybe_filter(query, {:exclude_circles, circle_ids}, opts) do
def maybe_filter(query, {:exclude_subject_circles, circle_ids}, opts) do
case Types.uids(circle_ids, nil) do
nil ->
warn(circle_ids, "unrecognized circle_ids")
Expand Down
1 change: 1 addition & 0 deletions lib/feed_filters.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ defmodule Bonfire.Social.FeedFilters do
field :subjects, StringList
field :exclude_subjects, StringList
field :subject_circles, StringList
field :exclude_subject_circles, StringList
field :subject_types, AtomOrStringList
field :exclude_subject_types, AtomOrStringList
field :objects, StringList
Expand Down
8 changes: 4 additions & 4 deletions test/social/feeds_filter_circles_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ defmodule Bonfire.Social.FeedsCirclesFilterTest do
refute FeedLoader.feed_contains?(feed, post_by_carl, current_user: user)
end

test "`exclude_circles` filters out posts from members of a circle", %{
test "`exclude_subject_circles` filters out posts from members of a circle", %{
user: user,
circle: circle,
post_by_alice: post_by_alice,
# post_by_bob: post_by_bob,
post_by_carl: post_by_carl
} do
# Load a feed excluding posts by members of the "friends" circle
feed = FeedLoader.feed(:custom, %{exclude_circles: [circle]}, current_user: user)
feed = FeedLoader.feed(:custom, %{exclude_subject_circles: [circle]}, current_user: user)

# Assert posts by Alice (member of the circle) are excluded
refute FeedLoader.feed_contains?(feed, post_by_alice, current_user: user)
Expand All @@ -90,7 +90,7 @@ defmodule Bonfire.Social.FeedsCirclesFilterTest do
end

# TODO: optimise query with a special case that uses the same join for both?
test "`exclude_circles` and `circles` together prioritize exclusions", %{
test "`exclude_subject_circles` and `circles` together prioritize exclusions", %{
user: user,
carl: carl,
circle: circle,
Expand All @@ -106,7 +106,7 @@ defmodule Bonfire.Social.FeedsCirclesFilterTest do

# Load a feed that includes "friends" circle but excludes "coworkers" circle
feed =
FeedLoader.feed(:custom, %{circles: [circle], exclude_circles: [second_circle]},
FeedLoader.feed(:custom, %{circles: [circle], exclude_subject_circles: [second_circle]},
current_user: user
)

Expand Down

0 comments on commit 8a2e191

Please sign in to comment.