mirror of
https://github.com/discourse/discourse.git
synced 2025-03-05 02:39:26 +00:00
14 lines
481 B
Ruby
14 lines
481 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
DiscourseAutomation::Triggerable.add(DiscourseAutomation::Triggers::POINT_IN_TIME) do
|
||
|
field :execute_at, component: :date_time, required: true
|
||
|
|
||
|
on_update do |automation, metadata|
|
||
|
# prevents creating a new pending automation on save when date is expired
|
||
|
execute_at = metadata.dig("execute_at", "value")
|
||
|
if execute_at && execute_at > Time.zone.now
|
||
|
automation.pending_automations.create!(execute_at: execute_at)
|
||
|
end
|
||
|
end
|
||
|
end
|