feat: sla-2 add automation backend support for SLA (#8775)

* feat: add automation support for SLA

* feat: add sla action in automtion UI

* chore: revert frontend changes

* chore: refactor to ee namespace

* chore: refactor automation rule to ee namespace

* feat: create applied_sla table entry

* chore: add applied_sla spec

* chore: rubocop fixes

---------

Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
Vishnu Narayanan
2024-02-01 15:42:12 +05:30
committed by GitHub
parent de98e434d6
commit b8047f0912
6 changed files with 68 additions and 6 deletions

View File

@@ -30,10 +30,15 @@ class AutomationRule < ApplicationRecord
scope :active, -> { where(active: true) }
CONDITIONS_ATTRS = %w[content email country_code status message_type browser_language assignee_id team_id referer city company inbox_id
mail_subject phone_number priority conversation_language].freeze
ACTIONS_ATTRS = %w[send_message add_label remove_label send_email_to_team assign_team assign_agent send_webhook_event mute_conversation
send_attachment change_status resolve_conversation snooze_conversation change_priority send_email_transcript].freeze
def conditions_attributes
%w[content email country_code status message_type browser_language assignee_id team_id referer city company inbox_id
mail_subject phone_number priority conversation_language]
end
def actions_attributes
%w[send_message add_label remove_label send_email_to_team assign_team assign_agent send_webhook_event mute_conversation
send_attachment change_status resolve_conversation snooze_conversation change_priority send_email_transcript].freeze
end
def file_base_data
files.map do |file|
@@ -55,7 +60,7 @@ class AutomationRule < ApplicationRecord
return if conditions.blank?
attributes = conditions.map { |obj, _| obj['attribute_key'] }
conditions = attributes - CONDITIONS_ATTRS
conditions = attributes - conditions_attributes
conditions -= account.custom_attribute_definitions.pluck(:attribute_key)
errors.add(:conditions, "Automation conditions #{conditions.join(',')} not supported.") if conditions.any?
end
@@ -64,7 +69,7 @@ class AutomationRule < ApplicationRecord
return if actions.blank?
attributes = actions.map { |obj, _| obj['action_name'] }
actions = attributes - ACTIONS_ATTRS
actions = attributes - actions_attributes
errors.add(:actions, "Automation actions #{actions.join(',')} not supported.") if actions.any?
end
@@ -78,3 +83,4 @@ class AutomationRule < ApplicationRecord
end
AutomationRule.include_mod_with('Audit::AutomationRule')
AutomationRule.prepend_mod_with('AutomationRule')

View File

@@ -89,3 +89,5 @@ class ActionService
@conversation.additional_attributes['type'] == 'tweet'
end
end
ActionService.include_mod_with('ActionService')