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