From e34e975776f52068c797221b0e4bb935f06dd21a Mon Sep 17 00:00:00 2001 From: smartdev58 <30475578+smartdev58@users.noreply.github.com> Date: Tue, 18 Oct 2022 10:05:28 +0200 Subject: [PATCH 01/10] chore: ability to delete user in super admin console fixes: #4164 --- app/models/user.rb | 2 +- config/routes.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 6ed95ddb3..743471049 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -96,7 +96,7 @@ class User < ApplicationRecord class_name: :PortalMember, dependent: :destroy_async has_many :portals, - through: :portals_members, + through: :portal_members, class_name: :Portal, dependent: :nullify, source: :portal diff --git a/config/routes.rb b/config/routes.rb index 8b9b43863..b5a5cbdc7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -346,7 +346,7 @@ Rails.application.routes.draw do resources :accounts, only: [:index, :new, :create, :show, :edit, :update] do post :seed, on: :member end - resources :users, only: [:index, :new, :create, :show, :edit, :update] + resources :users, only: [:index, :new, :create, :show, :edit, :update, :destroy] resources :access_tokens, only: [:index, :show] resources :installation_configs, only: [:index, :new, :create, :show, :edit, :update] resources :agent_bots, only: [:index, :new, :create, :show, :edit, :update] From 2e7ab484bd9d28c1f37b0d77cb92f8ff6bf947ad Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Wed, 19 Oct 2022 01:46:29 +0530 Subject: [PATCH 02/10] fix: Discard invalid contact attributes in widget conversation end point (#5664) Fixes: chatwoot/product#601 --- .../api/v1/widget/conversations_controller.rb | 3 ++- .../widget/conversations_controller_spec.rb | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/widget/conversations_controller.rb b/app/controllers/api/v1/widget/conversations_controller.rb index 83206de90..9b8c4da81 100644 --- a/app/controllers/api/v1/widget/conversations_controller.rb +++ b/app/controllers/api/v1/widget/conversations_controller.rb @@ -17,7 +17,8 @@ class Api::V1::Widget::ConversationsController < Api::V1::Widget::BaseController @contact = ContactIdentifyAction.new( contact: @contact, params: { email: contact_email, phone_number: contact_phone_number, name: contact_name }, - retain_original_contact_name: true + retain_original_contact_name: true, + discard_invalid_attrs: true ).perform end diff --git a/spec/controllers/api/v1/widget/conversations_controller_spec.rb b/spec/controllers/api/v1/widget/conversations_controller_spec.rb index 6f6f30e8e..cf386a65e 100644 --- a/spec/controllers/api/v1/widget/conversations_controller_spec.rb +++ b/spec/controllers/api/v1/widget/conversations_controller_spec.rb @@ -102,6 +102,29 @@ RSpec.describe '/api/v1/widget/conversations/toggle_typing', type: :request do expect(json_response['custom_attributes']['order_id']).to eq '12345' expect(json_response['messages'][0]['content']).to eq 'This is a test message' end + + it 'doesnt not add phone number if the invalid phone number is provided' do + existing_contact = create(:contact, account: account) + + post '/api/v1/widget/conversations', + headers: { 'X-Auth-Token' => token }, + params: { + website_token: web_widget.website_token, + contact: { + name: 'contact-name-1', + email: existing_contact.email, + phone_number: '13456' + }, + message: { + content: 'This is a test message' + } + }, + as: :json + + expect(response).to have_http_status(:success) + json_response = JSON.parse(response.body) + expect(json_response['contact']['phone_number']).to be_nil + end end describe 'POST /api/v1/widget/conversations/toggle_typing' do From 3de8f256cb0affd03a78279f4720b6cfc01ad87f Mon Sep 17 00:00:00 2001 From: Fayaz Ahmed <15716057+fayazara@users.noreply.github.com> Date: Thu, 20 Oct 2022 00:53:53 +0530 Subject: [PATCH 03/10] fix: Avoid overflowing submenus in conversation context menu (#5113) * Scroll overflowing content inside submenus * Disable submenus if options are not available --- .../conversation/contextMenu/Index.vue | 15 ++++++++++--- .../conversation/contextMenu/menuItem.vue | 3 +-- .../contextMenu/menuItemWithSubmenu.vue | 21 +++++++++++++++++-- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/app/javascript/dashboard/components/widgets/conversation/contextMenu/Index.vue b/app/javascript/dashboard/components/widgets/conversation/contextMenu/Index.vue index 4a1713165..a8a5f3cb3 100644 --- a/app/javascript/dashboard/components/widgets/conversation/contextMenu/Index.vue +++ b/app/javascript/dashboard/components/widgets/conversation/contextMenu/Index.vue @@ -17,7 +17,10 @@ @click="snoozeConversation(option.snoozedUntil)" /> - + - + - + - + @@ -50,7 +50,6 @@ export default { padding: var(--space-smaller); border-radius: var(--border-radius-small); overflow: hidden; - .menu-label { margin: 0; font-size: var(--font-size-mini); diff --git a/app/javascript/dashboard/components/widgets/conversation/contextMenu/menuItemWithSubmenu.vue b/app/javascript/dashboard/components/widgets/conversation/contextMenu/menuItemWithSubmenu.vue index 08922bc37..04870ccc1 100644 --- a/app/javascript/dashboard/components/widgets/conversation/contextMenu/menuItemWithSubmenu.vue +++ b/app/javascript/dashboard/components/widgets/conversation/contextMenu/menuItemWithSubmenu.vue @@ -1,11 +1,14 @@