mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FEATURE: Merge discourse-automation (#26432)
Automation (previously known as discourse-automation) is now a core plugin.
This commit is contained in:
@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
DiscourseAutomation::Scriptable.add(DiscourseAutomation::Scripts::PIN_TOPIC) do
|
||||
field :pinnable_topic, component: :text, required: true
|
||||
field :pinned_until, component: :date_time
|
||||
field :pinned_globally, component: :boolean
|
||||
|
||||
version 1
|
||||
|
||||
triggerables [:point_in_time]
|
||||
|
||||
script do |_context, fields|
|
||||
next unless topic_id = fields.dig("pinnable_topic", "value")
|
||||
next unless topic = Topic.find_by(id: topic_id)
|
||||
|
||||
pinned_globally = fields.dig("pinned_globally", "value") || false
|
||||
pinned_until = fields.dig("pinned_until", "value") || nil
|
||||
|
||||
topic.update_pinned(true, pinned_globally, pinned_until)
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user