FEATURE: Add 'New users only' option to user_updated trigger (#26648)

This commit adds a new option to the `user_updated` trigger of the automation plugin to only trigger an automation for new users that join after the automation is enabled.

Internal topic: t/125829/9.
This commit is contained in:
Osama Sayegh
2024-04-16 21:13:11 +03:00
committed by GitHub
parent 57d29b6f3b
commit 4733369f71
7 changed files with 190 additions and 2 deletions

View File

@ -20,6 +20,10 @@ module DiscourseAutomation
validates :script, presence: true
validate :validate_trigger_fields
after_destroy do |automation|
UserCustomField.where(name: automation.new_user_custom_field_name).destroy_all
end
attr_accessor :running_in_background
def running_in_background!
@ -163,6 +167,10 @@ module DiscourseAutomation
scriptable&.on_reset&.call(self)
end
def new_user_custom_field_name
"automation_#{self.id}_new_user"
end
private
def validate_trigger_fields