FEATURE: Add in:polls filter to search (#19885)

Allows users to filter search results to posts with polls (if the plugin is enabled).
This commit is contained in:
Penar Musaraj
2023-01-18 14:55:20 -05:00
committed by GitHub
parent 60ebbfd7e7
commit 3e197deec9
3 changed files with 55 additions and 0 deletions

View File

@ -231,4 +231,12 @@ after_initialize do
SiteSetting.poll_enabled && scope.user&.id.present? && preloaded_polls.present? &&
preloaded_polls.any? { |p| p.has_voted?(scope.user) }
end
register_search_advanced_filter(/in:polls/) do |posts, match|
if SiteSetting.poll_enabled
posts.joins(:polls)
else
posts
end
end
end