mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user