fix: Respect messaging window constraints for auto-resolve messages (#11757)
This commit is contained in:
@@ -4,8 +4,10 @@ class MessageTemplates::Template::AutoResolve
|
|||||||
def perform
|
def perform
|
||||||
return if conversation.account.auto_resolve_message.blank?
|
return if conversation.account.auto_resolve_message.blank?
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
if within_messaging_window?
|
||||||
conversation.messages.create!(auto_resolve_message_params)
|
conversation.messages.create!(auto_resolve_message_params)
|
||||||
|
else
|
||||||
|
create_auto_resolve_not_sent_activity_message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -14,6 +16,21 @@ class MessageTemplates::Template::AutoResolve
|
|||||||
delegate :contact, :account, to: :conversation
|
delegate :contact, :account, to: :conversation
|
||||||
delegate :inbox, to: :message
|
delegate :inbox, to: :message
|
||||||
|
|
||||||
|
def within_messaging_window?
|
||||||
|
conversation.can_reply?
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_auto_resolve_not_sent_activity_message
|
||||||
|
content = I18n.t('conversations.activity.auto_resolve.not_sent_due_to_messaging_window')
|
||||||
|
activity_message_params = {
|
||||||
|
account_id: conversation.account_id,
|
||||||
|
inbox_id: conversation.inbox_id,
|
||||||
|
message_type: :activity,
|
||||||
|
content: content
|
||||||
|
}
|
||||||
|
::Conversations::ActivityMessageJob.perform_later(conversation, activity_message_params) if content
|
||||||
|
end
|
||||||
|
|
||||||
def auto_resolve_message_params
|
def auto_resolve_message_params
|
||||||
{
|
{
|
||||||
account_id: @conversation.account_id,
|
account_id: @conversation.account_id,
|
||||||
|
|||||||
@@ -196,6 +196,8 @@ en:
|
|||||||
issue_unlinked: 'Linear issue %{issue_id} was unlinked by %{user_name}'
|
issue_unlinked: 'Linear issue %{issue_id} was unlinked by %{user_name}'
|
||||||
csat:
|
csat:
|
||||||
not_sent_due_to_messaging_window: 'CSAT survey not sent due to outgoing message restrictions'
|
not_sent_due_to_messaging_window: 'CSAT survey not sent due to outgoing message restrictions'
|
||||||
|
auto_resolve:
|
||||||
|
not_sent_due_to_messaging_window: 'Auto-resolve message not sent due to outgoing message restrictions'
|
||||||
muted: '%{user_name} has muted the conversation'
|
muted: '%{user_name} has muted the conversation'
|
||||||
unmuted: '%{user_name} has unmuted the conversation'
|
unmuted: '%{user_name} has unmuted the conversation'
|
||||||
auto_resolution_message: 'Resolving the conversation as it has been inactive for a while. Please start a new conversation if you need further assistance.'
|
auto_resolution_message: 'Resolving the conversation as it has been inactive for a while. Please start a new conversation if you need further assistance.'
|
||||||
|
|||||||
Reference in New Issue
Block a user