mirror of
https://github.com/discourse/discourse.git
synced 2025-03-01 17:13:11 +08:00
FEATURE: support filter_auto_bump_topics event
Use this event to filter the list of auto bumped topics. EG: on(:filter_auto_bump_topics) do |_category, filters| filters.push(->(r) { r.where(<<~SQL) NOT EXISTS( SELECT 1 FROM topic_custom_fields WHERE topic_id = topics.id AND name = 'accepted_answer_post_id' ) SQL }) end
This commit is contained in:
parent
02628883d2
commit
5adf5b527d
@ -410,7 +410,18 @@ class Category < ActiveRecord::Base
|
|||||||
limiter = auto_bump_limiter
|
limiter = auto_bump_limiter
|
||||||
return false if !limiter.can_perform?
|
return false if !limiter.can_perform?
|
||||||
|
|
||||||
topic = Topic
|
filters = []
|
||||||
|
DiscourseEvent.trigger(:filter_auto_bump_topics, self, filters)
|
||||||
|
|
||||||
|
relation = Topic
|
||||||
|
|
||||||
|
if filters.length > 0
|
||||||
|
filters.each do |filter|
|
||||||
|
relation = filter.call(relation)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
topic = relation
|
||||||
.visible
|
.visible
|
||||||
.listable_topics
|
.listable_topics
|
||||||
.where(category_id: self.id)
|
.where(category_id: self.id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user