From eb80324eaafc9451fd4b2a24cbdefb3ac5c065d8 Mon Sep 17 00:00:00 2001 From: Tejaswini Chile Date: Wed, 18 Aug 2021 15:28:45 +0530 Subject: [PATCH 01/72] feat: Add message content to mention email template (#2838) --- app/drops/message_drop.rb | 12 +++++++++++ .../conversation_notifications_mailer.rb | 4 +++- app/models/application_record.rb | 2 +- .../conversation_mention.liquid | 20 ++++++++++++++----- .../conversation_notifications_mailer_spec.rb | 7 ++++++- 5 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 app/drops/message_drop.rb diff --git a/app/drops/message_drop.rb b/app/drops/message_drop.rb new file mode 100644 index 000000000..dac2eeff0 --- /dev/null +++ b/app/drops/message_drop.rb @@ -0,0 +1,12 @@ +class MessageDrop < BaseDrop + include MessageFormatHelper + + def sender_display_name + @obj.sender.try(:display_name) + end + + def text_content + content = @obj.try(:content) + transform_user_mention_content content + end +end diff --git a/app/mailers/agent_notifications/conversation_notifications_mailer.rb b/app/mailers/agent_notifications/conversation_notifications_mailer.rb index 877c68ab5..c0f1f8630 100644 --- a/app/mailers/agent_notifications/conversation_notifications_mailer.rb +++ b/app/mailers/agent_notifications/conversation_notifications_mailer.rb @@ -24,6 +24,7 @@ class AgentNotifications::ConversationNotificationsMailer < ApplicationMailer @agent = agent @conversation = message.conversation + @message = message subject = "#{@agent.available_name}, You have been mentioned in conversation [ID - #{@conversation.display_id}]" @action_url = app_account_conversation_url(account_id: @conversation.account_id, id: @conversation.display_id) send_mail_with_liquid(to: @agent.email, subject: subject) and return @@ -47,7 +48,8 @@ class AgentNotifications::ConversationNotificationsMailer < ApplicationMailer super.merge({ user: @agent, conversation: @conversation, - inbox: @conversation.inbox + inbox: @conversation.inbox, + message: @message }) end end diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 69f6efc5d..37b839992 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -3,7 +3,7 @@ class ApplicationRecord < ActiveRecord::Base self.abstract_class = true # the models that exposed in email templates through liquid - DROPPABLES = %w[Account Channel Conversation Inbox User].freeze + DROPPABLES = %w[Account Channel Conversation Inbox User Message].freeze # ModelDrop class should exist in app/drops def to_drop diff --git a/app/views/mailers/agent_notifications/conversation_notifications_mailer/conversation_mention.liquid b/app/views/mailers/agent_notifications/conversation_notifications_mailer/conversation_mention.liquid index 7bddf270d..9e385d5d6 100644 --- a/app/views/mailers/agent_notifications/conversation_notifications_mailer/conversation_mention.liquid +++ b/app/views/mailers/agent_notifications/conversation_notifications_mailer/conversation_mention.liquid @@ -1,8 +1,18 @@ -

Hi {{user.available_name}}

+ +

Hi {{user.available_name}},

-

Time to save the world. You have been mentioned in a conversation

+

You've been mentioned in a conversation. {{message.sender_display_name}} wrote:

+
+ {{message.text_content}} +
-

-Click here to get cracking. -

+

View Message

diff --git a/spec/mailers/agent_notifications/conversation_notifications_mailer_spec.rb b/spec/mailers/agent_notifications/conversation_notifications_mailer_spec.rb index 54dd9dae3..4263b6796 100644 --- a/spec/mailers/agent_notifications/conversation_notifications_mailer_spec.rb +++ b/spec/mailers/agent_notifications/conversation_notifications_mailer_spec.rb @@ -39,7 +39,8 @@ RSpec.describe AgentNotifications::ConversationNotificationsMailer, type: :maile end describe 'conversation_mention' do - let(:message) { create(:message, conversation: conversation, account: account) } + let(:another_agent) { create(:user, email: 'agent2@example.com', account: account) } + let(:message) { create(:message, conversation: conversation, account: account, sender: another_agent) } let(:mail) { described_class.with(account: account).conversation_mention(message, agent).deliver_now } it 'renders the subject' do @@ -49,6 +50,10 @@ RSpec.describe AgentNotifications::ConversationNotificationsMailer, type: :maile it 'renders the receiver email' do expect(mail.to).to eq([agent.email]) end + + it 'renders the senders name' do + expect(mail.body.encoded).to match("You've been mentioned in a conversation. #{another_agent.display_name} wrote:") + end end describe 'assigned_conversation_new_message' do From 7cd3cef0a234b4d0c691f1986b655eb596cc339a Mon Sep 17 00:00:00 2001 From: Vishnu Narayanan Date: Fri, 20 Aug 2021 21:28:16 +0530 Subject: [PATCH 02/72] chore: add uptime and response time badges (#2842) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2720de61e..41f15553d 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ ___ Discord Huntr + uptime + response time

Chat dashboard From 5debe9e8ee2499079ca81648d2185db320162b81 Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Mon, 23 Aug 2021 21:34:23 +0530 Subject: [PATCH 03/72] fix: Add agent typing notification on all channels (#2855) Fixes CVE-2021-22881 Co-authored-by: Pranav Raj S --- .circleci/config.yml | 10 +- Gemfile.lock | 118 +++++++++--------- .../widgets/conversation/ReplyBox.vue | 12 +- 3 files changed, 69 insertions(+), 71 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f8ffdf076..c5a6430a3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ defaults: &defaults working_directory: ~/build docker: # specify the version you desire here - - image: circleci/ruby:3.0.2-node-browsers + - image: cimg/ruby:3.0.2-node # Specify service dependencies here if necessary # CircleCI maintains a library of pre-built images @@ -40,20 +40,20 @@ jobs: - restore_cache: keys: - - chatwoot-bundle-{{ checksum "Gemfile.lock" }} + - chatwoot-bundle-{{ .Environment.CACHE_VERSION }}-{{ checksum "Gemfile.lock" }} - chatwoot-bundle - run: bundle install --frozen --path ~/.bundle - save_cache: paths: - ~/.bundle - key: chatwoot-bundle-{{ checksum "Gemfile.lock" }} + key: chatwoot-bundle-{{ .Environment.CACHE_VERSION }}-{{ checksum "Gemfile.lock" }} # Only necessary if app uses webpacker or yarn in some other way - restore_cache: keys: - - chatwoot-yarn-{{ checksum "yarn.lock" }} + - chatwoot-yarn-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} - chatwoot-yarn- - run: @@ -62,7 +62,7 @@ jobs: # Store yarn / webpacker cache - save_cache: - key: chatwoot-yarn-{{ checksum "yarn.lock" }} + key: chatwoot-yarn-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} paths: - ~/.cache/yarn diff --git a/Gemfile.lock b/Gemfile.lock index 30c6c022a..c849b2b20 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,63 +1,63 @@ GEM remote: https://rubygems.org/ specs: - actioncable (6.1.4) - actionpack (= 6.1.4) - activesupport (= 6.1.4) + actioncable (6.1.4.1) + actionpack (= 6.1.4.1) + activesupport (= 6.1.4.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.4) - actionpack (= 6.1.4) - activejob (= 6.1.4) - activerecord (= 6.1.4) - activestorage (= 6.1.4) - activesupport (= 6.1.4) + actionmailbox (6.1.4.1) + actionpack (= 6.1.4.1) + activejob (= 6.1.4.1) + activerecord (= 6.1.4.1) + activestorage (= 6.1.4.1) + activesupport (= 6.1.4.1) mail (>= 2.7.1) - actionmailer (6.1.4) - actionpack (= 6.1.4) - actionview (= 6.1.4) - activejob (= 6.1.4) - activesupport (= 6.1.4) + actionmailer (6.1.4.1) + actionpack (= 6.1.4.1) + actionview (= 6.1.4.1) + activejob (= 6.1.4.1) + activesupport (= 6.1.4.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.4) - actionview (= 6.1.4) - activesupport (= 6.1.4) + actionpack (6.1.4.1) + actionview (= 6.1.4.1) + activesupport (= 6.1.4.1) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.4) - actionpack (= 6.1.4) - activerecord (= 6.1.4) - activestorage (= 6.1.4) - activesupport (= 6.1.4) + actiontext (6.1.4.1) + actionpack (= 6.1.4.1) + activerecord (= 6.1.4.1) + activestorage (= 6.1.4.1) + activesupport (= 6.1.4.1) nokogiri (>= 1.8.5) - actionview (6.1.4) - activesupport (= 6.1.4) + actionview (6.1.4.1) + activesupport (= 6.1.4.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) active_record_query_trace (1.8) - activejob (6.1.4) - activesupport (= 6.1.4) + activejob (6.1.4.1) + activesupport (= 6.1.4.1) globalid (>= 0.3.6) - activemodel (6.1.4) - activesupport (= 6.1.4) - activerecord (6.1.4) - activemodel (= 6.1.4) - activesupport (= 6.1.4) + activemodel (6.1.4.1) + activesupport (= 6.1.4.1) + activerecord (6.1.4.1) + activemodel (= 6.1.4.1) + activesupport (= 6.1.4.1) activerecord-import (1.2.0) activerecord (>= 3.2) - activestorage (6.1.4) - actionpack (= 6.1.4) - activejob (= 6.1.4) - activerecord (= 6.1.4) - activesupport (= 6.1.4) + activestorage (6.1.4.1) + actionpack (= 6.1.4.1) + activejob (= 6.1.4.1) + activerecord (= 6.1.4.1) + activesupport (= 6.1.4.1) marcel (~> 1.0.0) mini_mime (>= 1.1.0) - activesupport (6.1.4) + activesupport (6.1.4.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -115,7 +115,7 @@ GEM statsd-ruby (~> 1.1) bcrypt (3.1.16) bindex (0.8.1) - bootsnap (1.7.6) + bootsnap (1.7.7) msgpack (~> 1.0) brakeman (5.1.1) browser (5.3.1) @@ -216,7 +216,7 @@ GEM grpc (~> 1.25) geocoder (1.6.7) gli (2.20.1) - globalid (0.5.1) + globalid (0.5.2) activesupport (>= 5.0) google-apis-core (0.4.1) addressable (~> 2.5, >= 2.5.1) @@ -336,7 +336,7 @@ GEM listen (3.6.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.11.0) + loofah (2.12.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -349,7 +349,7 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2021.0704) mini_magick (4.11.0) - mini_mime (1.1.0) + mini_mime (1.1.1) minitest (5.14.4) mock_redis (0.28.0) ruby2_keywords @@ -362,7 +362,7 @@ GEM net-http-persistent (4.0.1) connection_pool (~> 2.2) netrc (0.11.0) - nio4r (2.5.7) + nio4r (2.5.8) nokogiri (1.11.7-arm64-darwin) racc (~> 1.4) nokogiri (1.11.7-x86_64-darwin) @@ -400,29 +400,29 @@ GEM rack-test (1.1.0) rack (>= 1.0, < 3) rack-timeout (0.6.0) - rails (6.1.4) - actioncable (= 6.1.4) - actionmailbox (= 6.1.4) - actionmailer (= 6.1.4) - actionpack (= 6.1.4) - actiontext (= 6.1.4) - actionview (= 6.1.4) - activejob (= 6.1.4) - activemodel (= 6.1.4) - activerecord (= 6.1.4) - activestorage (= 6.1.4) - activesupport (= 6.1.4) + rails (6.1.4.1) + actioncable (= 6.1.4.1) + actionmailbox (= 6.1.4.1) + actionmailer (= 6.1.4.1) + actionpack (= 6.1.4.1) + actiontext (= 6.1.4.1) + actionview (= 6.1.4.1) + activejob (= 6.1.4.1) + activemodel (= 6.1.4.1) + activerecord (= 6.1.4.1) + activestorage (= 6.1.4.1) + activesupport (= 6.1.4.1) bundler (>= 1.15.0) - railties (= 6.1.4) + railties (= 6.1.4.1) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.3.0) + rails-html-sanitizer (1.4.1) loofah (~> 2.3) - railties (6.1.4) - actionpack (= 6.1.4) - activesupport (= 6.1.4) + railties (6.1.4.1) + actionpack (= 6.1.4.1) + activesupport (= 6.1.4.1) method_source rake (>= 0.13) thor (~> 1.0) diff --git a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue index 6e7a039af..acb417876 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue @@ -390,13 +390,11 @@ export default { this.isFocused = true; }, toggleTyping(status) { - if (this.isAWebWidgetInbox && !this.isPrivate) { - const conversationId = this.currentChat.id; - this.$store.dispatch('conversationTypingStatus/toggleTyping', { - status, - conversationId, - }); - } + const conversationId = this.currentChat.id; + this.$store.dispatch('conversationTypingStatus/toggleTyping', { + status, + conversationId, + }); }, onFileUpload(file) { if (!file) { From 6515b6956010de35602c5087e59732c7a25fa69b Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Mon, 23 Aug 2021 22:00:47 +0530 Subject: [PATCH 04/72] feat: CSAT for all channels (#2749) --- .../dashboard/settings/inbox/Settings.vue | 4 +- app/javascript/survey/api/endPoints.js | 13 ++ .../survey/api/specs/endPoints.spec.js | 38 ++++ app/javascript/survey/api/survey.js | 15 ++ app/javascript/survey/assets/scss/woot.scss | 1 + app/javascript/survey/components/Banner.vue | 31 ++++ app/javascript/survey/components/Feedback.vue | 54 ++++++ app/javascript/survey/components/Rating.vue | 23 +-- app/javascript/survey/helpers/axios.js | 6 + app/javascript/survey/i18n/locale/en.json | 4 + app/javascript/survey/views/Response.vue | 174 +++++++++++++++--- app/listeners/agent_bot_listener.rb | 4 +- app/listeners/hook_listener.rb | 4 +- app/listeners/webhook_listener.rb | 4 +- app/mailers/conversation_reply_mailer.rb | 7 +- app/models/concerns/message_filter_helpers.rb | 19 ++ app/models/conversation.rb | 4 + app/models/message.rb | 19 +- .../hook_execution_service.rb | 13 +- config/locales/en.yml | 2 + .../dialogflow/processor_service.rb | 1 + package.json | 3 +- .../hook_execution_service_spec.rb | 7 +- 23 files changed, 382 insertions(+), 68 deletions(-) create mode 100644 app/javascript/survey/api/endPoints.js create mode 100644 app/javascript/survey/api/specs/endPoints.spec.js create mode 100644 app/javascript/survey/api/survey.js create mode 100644 app/javascript/survey/components/Banner.vue create mode 100644 app/javascript/survey/components/Feedback.vue create mode 100644 app/javascript/survey/helpers/axios.js create mode 100644 app/models/concerns/message_filter_helpers.rb diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue index 86ce81978..7cddf006b 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue @@ -170,7 +170,7 @@

-