From a2fca2edb8b3146f812a373caf18618cee107974 Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Fri, 16 Jul 2021 19:56:54 +0530 Subject: [PATCH 1/4] fix: Fix HTML only email rendering (#2644) --- .../components/widgets/conversation/Message.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/javascript/dashboard/components/widgets/conversation/Message.vue b/app/javascript/dashboard/components/widgets/conversation/Message.vue index 75460f289..58ef6e216 100644 --- a/app/javascript/dashboard/components/widgets/conversation/Message.vue +++ b/app/javascript/dashboard/components/widgets/conversation/Message.vue @@ -134,11 +134,17 @@ export default { const { email: { html_content: { full: fullHTMLContent, reply: replyHTMLContent } = {}, + text_content: { full: fullTextContent, reply: replyTextContent } = {}, } = {}, } = this.contentAttributes; - if ((replyHTMLContent || fullHTMLContent) && this.isIncoming) { - let contentToBeParsed = replyHTMLContent || fullHTMLContent || ''; + let contentToBeParsed = + replyHTMLContent || + replyTextContent || + fullHTMLContent || + fullTextContent || + ''; + if (contentToBeParsed && this.isIncoming) { const parsedContent = this.stripStyleCharacters(contentToBeParsed); if (parsedContent) { return parsedContent; From a235e82a021f9016fe480917dfe32eed90be9229 Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Mon, 19 Jul 2021 14:41:16 +0530 Subject: [PATCH 2/4] fix: Update attribute name to conversationsCount (#2662) --- .../routes/dashboard/contacts/components/ContactsTable.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/dashboard/routes/dashboard/contacts/components/ContactsTable.vue b/app/javascript/dashboard/routes/dashboard/contacts/components/ContactsTable.vue index 6f83cf0bd..0cc41d17e 100644 --- a/app/javascript/dashboard/routes/dashboard/contacts/components/ContactsTable.vue +++ b/app/javascript/dashboard/routes/dashboard/contacts/components/ContactsTable.vue @@ -98,7 +98,7 @@ export default { profiles: additional.social_profiles || {}, city: additional.city || '---', country: additional.country || '---', - conversations_count: item.conversations_count || '---', + conversationsCount: item.conversations_count || '---', last_activity_at: lastActivityAt ? this.dynamicTime(lastActivityAt) : '---', From 217dd8a6f0cc6c16701d69f28ae3522b537123d6 Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Mon, 19 Jul 2021 19:10:58 +0530 Subject: [PATCH 3/4] chore: Add assigned_count to conversation APIs (#2665) --- app/finders/conversation_finder.rb | 38 +++++++++++-------- app/models/conversation.rb | 1 + .../conversations/index.json.jbuilder | 1 + .../accounts/conversations/meta.json.jbuilder | 1 + config/schedule.yml | 2 +- .../accounts/conversations_controller_spec.rb | 5 ++- spec/finders/conversation_finder_spec.rb | 10 +++++ 7 files changed, 40 insertions(+), 18 deletions(-) diff --git a/app/finders/conversation_finder.rb b/app/finders/conversation_finder.rb index 06f219e27..66602988a 100644 --- a/app/finders/conversation_finder.rb +++ b/app/finders/conversation_finder.rb @@ -21,6 +21,27 @@ class ConversationFinder end def perform + set_up + + mine_count, unassigned_count, all_count, = set_count_for_all_conversations + assigned_count = all_count - unassigned_count + + filter_by_assignee_type + + { + conversations: conversations, + count: { + mine_count: mine_count, + assigned_count: assigned_count, + unassigned_count: unassigned_count, + all_count: all_count + } + } + end + + private + + def set_up set_inboxes set_team set_assignee_type @@ -30,23 +51,8 @@ class ConversationFinder filter_by_team if @team filter_by_labels if params[:labels] filter_by_query if params[:q] - - mine_count, unassigned_count, all_count = set_count_for_all_conversations - - filter_by_assignee_type - - { - conversations: conversations, - count: { - mine_count: mine_count, - unassigned_count: unassigned_count, - all_count: all_count - } - } end - private - def set_inboxes @inbox_ids = if params[:inbox_id] current_account.inboxes.where(id: params[:inbox_id]) @@ -74,7 +80,7 @@ class ConversationFinder when 'unassigned' @conversations = @conversations.unassigned when 'assigned' - @conversations = @conversations.where.not(assignee_id: nil) + @conversations = @conversations.assigned end @conversations end diff --git a/app/models/conversation.rb b/app/models/conversation.rb index 779c7668e..e0760deea 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -49,6 +49,7 @@ class Conversation < ApplicationRecord scope :latest, -> { order(last_activity_at: :desc) } scope :unassigned, -> { where(assignee_id: nil) } + scope :assigned, -> { where.not(assignee_id: nil) } scope :assigned_to, ->(agent) { where(assignee_id: agent.id) } belongs_to :account diff --git a/app/views/api/v1/accounts/conversations/index.json.jbuilder b/app/views/api/v1/accounts/conversations/index.json.jbuilder index 57c31ecc3..c54baab78 100644 --- a/app/views/api/v1/accounts/conversations/index.json.jbuilder +++ b/app/views/api/v1/accounts/conversations/index.json.jbuilder @@ -1,6 +1,7 @@ json.data do json.meta do json.mine_count @conversations_count[:mine_count] + json.assigned_count @conversations_count[:assigned_count] json.unassigned_count @conversations_count[:unassigned_count] json.all_count @conversations_count[:all_count] end diff --git a/app/views/api/v1/accounts/conversations/meta.json.jbuilder b/app/views/api/v1/accounts/conversations/meta.json.jbuilder index 24fbf10d5..0326ad52f 100644 --- a/app/views/api/v1/accounts/conversations/meta.json.jbuilder +++ b/app/views/api/v1/accounts/conversations/meta.json.jbuilder @@ -1,5 +1,6 @@ json.meta do json.mine_count @conversations_count[:mine_count] + json.assigned_count @conversations_count[:assigned_count] json.unassigned_count @conversations_count[:unassigned_count] json.all_count @conversations_count[:all_count] end diff --git a/config/schedule.yml b/config/schedule.yml index 5dd27afc3..4a01893a9 100644 --- a/config/schedule.yml +++ b/config/schedule.yml @@ -8,7 +8,7 @@ internal_check_new_versions_job: queue: scheduled_jobs # executed At every 5th minute.. -internal_check_new_versions_job: +trigger_scheduled_items_job: cron: "*/5 * * * *" class: "TriggerScheduledItemsJob" queue: scheduled_jobs diff --git a/spec/controllers/api/v1/accounts/conversations_controller_spec.rb b/spec/controllers/api/v1/accounts/conversations_controller_spec.rb index 6a0c419a2..82beb18cc 100644 --- a/spec/controllers/api/v1/accounts/conversations_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/conversations_controller_spec.rb @@ -29,6 +29,7 @@ RSpec.describe 'Conversations API', type: :request do expect(response).to have_http_status(:success) body = JSON.parse(response.body, symbolize_names: true) expect(body[:data][:meta][:all_count]).to eq(1) + expect(body[:data][:meta].keys).to include(:all_count, :mine_count, :assigned_count, :unassigned_count) expect(body[:data][:payload].first[:messages].first[:id]).to eq(message.id) end @@ -68,7 +69,9 @@ RSpec.describe 'Conversations API', type: :request do as: :json expect(response).to have_http_status(:success) - expect(JSON.parse(response.body, symbolize_names: true)[:meta][:all_count]).to eq(1) + body = JSON.parse(response.body, symbolize_names: true) + expect(body[:meta].keys).to include(:all_count, :mine_count, :assigned_count, :unassigned_count) + expect(body[:meta][:all_count]).to eq(1) end end end diff --git a/spec/finders/conversation_finder_spec.rb b/spec/finders/conversation_finder_spec.rb index d92b3b0a9..d739179bf 100644 --- a/spec/finders/conversation_finder_spec.rb +++ b/spec/finders/conversation_finder_spec.rb @@ -55,6 +55,16 @@ describe ::ConversationFinder do result = conversation_finder.perform expect(result[:conversations].count).to be 3 end + + it 'returns the correct meta' do + result = conversation_finder.perform + expect(result[:count]).to eq({ + mine_count: 2, + assigned_count: 3, + unassigned_count: 1, + all_count: 4 + }) + end end context 'with team' do From d1619bdc87965961976de692f149e983f4f42929 Mon Sep 17 00:00:00 2001 From: Sojan Date: Tue, 20 Jul 2021 00:50:38 +0530 Subject: [PATCH 4/4] Bump version to 1.18.1 --- config/app.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/app.yml b/config/app.yml index 618211b81..4e032529b 100644 --- a/config/app.yml +++ b/config/app.yml @@ -1,5 +1,5 @@ shared: &shared - version: '1.18.0' + version: '1.18.1' development: <<: *shared diff --git a/package.json b/package.json index a02f8d04c..0826ee538 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chatwoot/chatwoot", - "version": "1.18.0", + "version": "1.18.1", "license": "MIT", "scripts": { "eslint": "eslint app/javascript --fix",