Skip to content

A platform for community discussion. Free, open, simple.

FIX: likes are not visible when rejecting PMs (#35753)

Sam3485ef243feb
diff --git a/app/controllers/post_action_users_controller.rb b/app/controllers/post_action_users_controller.rb
index 9da3155a911..a9adac60c43 100644
--- a/app/controllers/post_action_users_controller.rb
+++ b/app/controllers/post_action_users_controller.rb
@@ -56,6 +56,6 @@ class PostActionUsersController < ApplicationController
UserCommScreener.new(
acting_user: current_user,
target_user_ids: user_ids,
- ).actor_preventing_communication
+ ).actor_ignoring_or_muting_users
end
end
diff --git a/lib/user_comm_screener.rb b/lib/user_comm_screener.rb
index fee8c29ff62..4a4a59dcfde 100644
--- a/lib/user_comm_screener.rb
+++ b/lib/user_comm_screener.rb
@@ -154,6 +154,10 @@ class UserCommScreener
).uniq
end
+ def actor_ignoring_or_muting_users
+ (actor_preferences[:ignoring] + actor_preferences[:muting]).uniq
+ end
+
##
# The actor methods below are more fine-grained than the user ones,
# since we may want to display more detailed messages to the actor about
diff --git a/spec/lib/user_comm_screener_spec.rb b/spec/lib/user_comm_screener_spec.rb
index 627de6d53b0..37de4096fda 100644
--- a/spec/lib/user_comm_screener_spec.rb
+++ b/spec/lib/user_comm_screener_spec.rb
@@ -275,6 +275,32 @@ RSpec.describe UserCommScreener do
end
end
+ describe "#actor_ignoring_or_muting_users" do
+ it "returns only the user_ids that the actor is ignoring or muting, excluding PM allowlist" do
+ acting_user.user_option.update!(enable_allowed_pm_users: true)
+ expect(screener.actor_ignoring_or_muting_users).to match_array(
+ [target_user1.id, target_user2.id],
+ )
+ end
+
+ it "does not include users filtered by PM allowlist" do
+ acting_user.user_option.update!(enable_allowed_pm_users: true)
+ expect(screener.actor_ignoring_or_muting_users).not_to include(target_user3.id)
+ expect(screener.actor_ignoring_or_muting_users).not_to include(target_user5.id)
+ end
+
+ describe "when the actor has no preferences" do
+ before do
+ muted_user.destroy
+ ignored_user.destroy
+ end
+
+ it "returns an empty array and does not error" do
+ expect(screener.actor_ignoring_or_muting_users).to match_array([])
+ end
+ end
+ end
+
describe "#actor_ignoring?" do
it "returns true for user ids that the actor is ignoring" do
expect(screener.actor_ignoring?(target_user2.id)).to eq(true)
diff --git a/spec/requests/post_action_users_controller_spec.rb b/spec/requests/post_action_users_controller_spec.rb
index 72454fab2c3..36f425ab9e2 100644
--- a/spec/requests/post_action_users_controller_spec.rb
+++ b/spec/requests/post_action_users_controller_spec.rb
@@ -98,6 +98,28 @@ RSpec.describe PostActionUsersController do
expect(json_users.find { |u| u["id"] == ignored_user.id }["unknown"]).to eq(true)
end
+ it "does not hide users from the like list when they are not in the actor's PM allowlist" do
+ user_not_in_allowlist = Fabricate(:user)
+ user_in_allowlist = Fabricate(:user)
+ PostActionCreator.like(user_not_in_allowlist, post)
+ PostActionCreator.like(user_in_allowlist, post)
+
+ user.user_option.update!(enable_allowed_pm_users: true)
+ AllowedPmUser.create!(user: user, allowed_pm_user: user_in_allowlist)
+
+ get "/post_action_users.json",
+ params: {
+ id: post.id,
+ post_action_type_id: PostActionType.types[:like],
+ }
+ expect(response.status).to eq(200)
+ json_users = response.parsed_body["post_action_users"]
+ expect(json_users.find { |u| u["id"] == user_not_in_allowlist.id }).to be_present
+ expect(json_users.find { |u| u["id"] == user_in_allowlist.id }).to be_present
+ expect(json_users.find { |u| u["id"] == user_not_in_allowlist.id }["unknown"]).to be_blank
+ expect(json_users.find { |u| u["id"] == user_in_allowlist.id }["unknown"]).to be_blank
+ end
+
it "paginates post actions" do
user_ids = []
5.times do