flags: fix flagger:<name> not returning self-flagged uploads

Fix the search `flagger:evazion user:evazion` not returning the user's own self-flagged uploads.

Followup to a6e0872ce.

Fixes #4690: user profile 'flags' count links to /post_flags with different search criteria
This commit is contained in:
evazion
2022-09-22 22:31:33 -05:00
parent dff27e3a3a
commit e5edd79180
5 changed files with 14 additions and 29 deletions

View File

@@ -31,18 +31,6 @@ class PostFlag < ApplicationRecord
scope :active, -> { pending.or(rejected.in_cooldown) }
module SearchMethods
def creator_matches(creator, searcher)
return none if creator.nil?
policy = Pundit.policy!(searcher, PostFlag.unscoped.new(creator: creator))
if policy.can_view_flagger?
where(creator: creator).where.not(post: searcher.posts)
else
none
end
end
def category_matches(category)
case category
when "normal"