FIX: Prevent infinite loop of automations triggering each other (#26814)

It's currently possible to setup multiple automation rules that trigger each other resulting in an infinite loop. To prevent that, this commit adds a global "circuit breaker" that prevents all automations from triggering while an automation rule is executing.

Internal topic: t/124365.
This commit is contained in:
Osama Sayegh
2024-04-30 20:13:29 +03:00
committed by GitHub
parent ff8e1f4ed6
commit 0e44072b2b
4 changed files with 72 additions and 15 deletions

View File

@ -46,16 +46,6 @@ describe DiscourseAutomation::Automation do
Jobs::DiscourseAutomationTrigger.jobs.size
}.by(1)
end
it "also runs the script properly" do
Jobs.run_immediately!
post = Fabricate(:post)
user = post.user
list = capture_contexts { automation.trigger!({ post: post, user: user, test: :test }) }
expect(list[0]["post"].id).to eq(post.id)
expect(list[0]["user"].id).to eq(user.id)
expect(list[0]["test"]).to eq(:test)
end
end
describe "#detach_custom_field" do