FEATURE: Merge discourse-automation (#26432)

Automation (previously known as discourse-automation) is now a core plugin.
This commit is contained in:
Osama Sayegh
2024-04-03 18:20:43 +03:00
committed by GitHub
parent 2190c9b957
commit 3d4faf3272
314 changed files with 21182 additions and 10 deletions

View File

@ -0,0 +1,21 @@
# frozen_string_literal: true
module ::DiscourseAutomation
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseAutomation
end
def self.filter_by_trigger(items, trigger)
trigger = trigger&.to_sym
indexed_items =
items.each_with_object({}) do |item, acc|
if item[:triggerable] == trigger || item[:triggerable].nil?
acc[item[:name]] = item if acc[item[:name]].nil? || item[:triggerable] == trigger
end
end
indexed_items.values
end
end