feat: CSAT for all channels (#2749)

This commit is contained in:
Muhsin Keloth
2021-08-23 22:00:47 +05:30
committed by GitHub
parent 5debe9e8ee
commit 6515b69560
23 changed files with 382 additions and 68 deletions

View File

@@ -0,0 +1,19 @@
module MessageFilterHelpers
extend ActiveSupport::Concern
def reportable?
incoming? || outgoing?
end
def webhook_sendable?
incoming? || outgoing?
end
def conversation_transcriptable?
incoming? || outgoing?
end
def email_reply_summarizable?
incoming? || outgoing? || input_csat?
end
end

View File

@@ -142,6 +142,10 @@ class Conversation < ApplicationRecord
true
end
def tweet?
inbox.inbox_type == 'Twitter' && additional_attributes['type'] == 'tweet'
end
private
def ensure_snooze_until_reset

View File

@@ -29,6 +29,7 @@
#
class Message < ApplicationRecord
include MessageFilterHelpers
NUMBER_OF_PERMITTED_ATTACHMENTS = 15
validates :account_id, presence: true
@@ -81,9 +82,6 @@ class Message < ApplicationRecord
has_many :attachments, dependent: :destroy, autosave: true, before_add: :validate_attachments_limit
has_one :csat_survey_response, dependent: :destroy
after_create :reopen_conversation,
:notify_via_mail
after_create_commit :execute_after_create_commit_callbacks
after_update_commit :dispatch_update_event
@@ -109,10 +107,6 @@ class Message < ApplicationRecord
data
end
def reportable?
incoming? || outgoing?
end
def webhook_data
{
id: id,
@@ -130,10 +124,19 @@ class Message < ApplicationRecord
}
end
def content
# move this to a presenter
return self[:content] if !input_csat? || inbox.web_widget?
I18n.t('conversations.survey.response', link: "#{ENV['FRONTEND_URL']}/survey/responses/#{conversation.uuid}")
end
private
def execute_after_create_commit_callbacks
# rails issue with order of active record callbacks being executed https://github.com/rails/rails/issues/20911
reopen_conversation
notify_via_mail
set_conversation_activity
dispatch_create_events
send_reply
@@ -175,7 +178,7 @@ class Message < ApplicationRecord
end
def email_notifiable_message?
return false unless outgoing?
return false unless outgoing? || input_csat?
return false if private?
true