From 0a910c3763e1456c244b8ad4fc44ace0651fa656 Mon Sep 17 00:00:00 2001 From: Vishnu Narayanan Date: Sat, 7 Feb 2026 23:32:40 +0530 Subject: [PATCH] fix: Add email rate limiting to automation rule actions (#13474) --- app/services/action_service.rb | 3 +++ app/services/automation_rules/action_service.rb | 3 +++ 2 files changed, 6 insertions(+) diff --git a/app/services/action_service.rb b/app/services/action_service.rb index 80caac392..b4900aad8 100644 --- a/app/services/action_service.rb +++ b/app/services/action_service.rb @@ -78,8 +78,11 @@ class ActionService emails = emails[0].gsub(/\s+/, '').split(',') emails.each do |email| + break unless @account.within_email_rate_limit? + email = parse_email_variables(@conversation, email) ConversationReplyMailer.with(account: @conversation.account).conversation_transcript(@conversation, email)&.deliver_later + @account.increment_email_sent_count end end diff --git a/app/services/automation_rules/action_service.rb b/app/services/automation_rules/action_service.rb index e409faba2..01833ba57 100644 --- a/app/services/automation_rules/action_service.rb +++ b/app/services/automation_rules/action_service.rb @@ -58,7 +58,10 @@ class AutomationRules::ActionService < ActionService teams = Team.where(id: params[0][:team_ids]) teams.each do |team| + break unless @account.within_email_rate_limit? + TeamNotifications::AutomationNotificationMailer.conversation_creation(@conversation, team, params[0][:message])&.deliver_now + @account.increment_email_sent_count end end end