From 9ea42ebff22149b4abf6e8f7b5021f310a71448f Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Tue, 16 Nov 2021 23:25:19 +0530 Subject: [PATCH 01/69] chore: Add the support for list and checkbox in custom attribute model (#3400) ref: #3399 --- app/models/custom_attribute_definition.rb | 5 +++-- ...11116131740_add_values_to_custom_attribute_definitions.rb | 5 +++++ db/schema.rb | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20211116131740_add_values_to_custom_attribute_definitions.rb diff --git a/app/models/custom_attribute_definition.rb b/app/models/custom_attribute_definition.rb index d3f40e0f4..a79b8ca95 100644 --- a/app/models/custom_attribute_definition.rb +++ b/app/models/custom_attribute_definition.rb @@ -3,12 +3,13 @@ # Table name: custom_attribute_definitions # # id :bigint not null, primary key +# attribute_description :text # attribute_display_name :string # attribute_display_type :integer default("text") -# attribute_description :text # attribute_key :string # attribute_model :integer default("conversation_attribute") # default_value :integer +# values :jsonb # created_at :datetime not null # updated_at :datetime not null # account_id :bigint @@ -30,7 +31,7 @@ class CustomAttributeDefinition < ApplicationRecord validates :attribute_model, presence: true enum attribute_model: { conversation_attribute: 0, contact_attribute: 1 } - enum attribute_display_type: { text: 0, number: 1, currency: 2, percent: 3, link: 4, date: 5 } + enum attribute_display_type: { text: 0, number: 1, currency: 2, percent: 3, link: 4, date: 5, list: 6, checkbox: 7 } belongs_to :account end diff --git a/db/migrate/20211116131740_add_values_to_custom_attribute_definitions.rb b/db/migrate/20211116131740_add_values_to_custom_attribute_definitions.rb new file mode 100644 index 000000000..2625fe30c --- /dev/null +++ b/db/migrate/20211116131740_add_values_to_custom_attribute_definitions.rb @@ -0,0 +1,5 @@ +class AddValuesToCustomAttributeDefinitions < ActiveRecord::Migration[6.1] + def change + add_column :custom_attribute_definitions, :values, :jsonb, default: [] + end +end diff --git a/db/schema.rb b/db/schema.rb index 9ad249a38..946f2829e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_09_29_150415) do +ActiveRecord::Schema.define(version: 2021_11_16_131740) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" @@ -355,6 +355,7 @@ ActiveRecord::Schema.define(version: 2021_09_29_150415) do t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.text "attribute_description" + t.jsonb "values", default: [] t.index ["account_id"], name: "index_custom_attribute_definitions_on_account_id" t.index ["attribute_key", "attribute_model"], name: "attribute_key_model_index", unique: true end From fec4a290817f9587f98fe520027420dae7861ffd Mon Sep 17 00:00:00 2001 From: Shivam Chahar Date: Wed, 17 Nov 2021 18:05:53 +0530 Subject: [PATCH 02/69] Feat: Include previous messages in mention/assign notifications email (#3385) --- app/drops/conversation_drop.rb | 12 ++++++++++ app/models/conversation.rb | 4 ++++ .../conversation_assignment.liquid | 24 +++++++++++++++++++ .../conversation_mention.liquid | 24 +++++++++++++++++++ spec/models/conversation_spec.rb | 24 +++++++++++++++++++ 5 files changed, 88 insertions(+) diff --git a/app/drops/conversation_drop.rb b/app/drops/conversation_drop.rb index 03bab2f58..1758c29c5 100644 --- a/app/drops/conversation_drop.rb +++ b/app/drops/conversation_drop.rb @@ -1,5 +1,17 @@ class ConversationDrop < BaseDrop + include MessageFormatHelper + def display_id @obj.try(:display_id) end + + def recent_messages + @obj.try(:recent_messages).map do |message| + { + 'sender' => message.sender&.available_name || message.sender&.name, + 'content' => transform_user_mention_content(message.content), + 'attachments' => message.attachments.map(&:file_url) + } + end + end end diff --git a/app/models/conversation.rb b/app/models/conversation.rb index fdfd5002a..a7a5b5b6d 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -147,6 +147,10 @@ class Conversation < ApplicationRecord inbox.inbox_type == 'Twitter' && additional_attributes['type'] == 'tweet' end + def recent_messages + messages.chat.last(5) + end + private def execute_after_update_commit_callbacks diff --git a/app/views/mailers/agent_notifications/conversation_notifications_mailer/conversation_assignment.liquid b/app/views/mailers/agent_notifications/conversation_notifications_mailer/conversation_assignment.liquid index 63e22f093..e138fd11a 100644 --- a/app/views/mailers/agent_notifications/conversation_notifications_mailer/conversation_assignment.liquid +++ b/app/views/mailers/agent_notifications/conversation_notifications_mailer/conversation_assignment.liquid @@ -2,6 +2,30 @@

Time to save the world. A new conversation has been assigned to you

+{% for chat_message in conversation.recent_messages %} +
+ {% if chat_message.sender == user.available_name %} +

You

+ {% else %} +

{{chat_message.sender}}

+ {% endif %} +
+ +
+

+ {% if chat_message.content %} + {{chat_message.content}} + {% endif %} + + {% if chat_message.attachments %} + {% for attachment in chat_message.attachments %} + Attachment [Click here to view] + {% endfor %} + {% endif %} +

+
+{% endfor %} +

Click here to get cracking.

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 4783b1dde..9a30e6e09 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 @@ -5,4 +5,28 @@ {{message.text_content}} +{% for chat_message in conversation.recent_messages %} +
+ {% if chat_message.sender == user.available_name %} +

You

+ {% else %} +

{{chat_message.sender}}

+ {% endif %} +
+ +
+

+ {% if chat_message.content %} + {{chat_message.content}} + {% endif %} + + {% if chat_message.attachments %} + {% for attachment in chat_message.attachments %} + Attachment [Click here to view] + {% endfor %} + {% endif %} +

+
+{% endfor %} +

View Message

diff --git a/spec/models/conversation_spec.rb b/spec/models/conversation_spec.rb index 9d7fa2c8c..71adf6970 100644 --- a/spec/models/conversation_spec.rb +++ b/spec/models/conversation_spec.rb @@ -340,6 +340,30 @@ RSpec.describe Conversation, type: :model do end end + describe 'recent_messages' do + subject(:recent_messages) { conversation.recent_messages } + + let(:conversation) { create(:conversation, agent_last_seen_at: 1.hour.ago) } + let(:message_params) do + { + conversation: conversation, + account: conversation.account, + inbox: conversation.inbox, + sender: conversation.assignee + } + end + let!(:messages) do + create_list(:message, 10, **message_params) do |message, i| + message.created_at = i.minute.ago + end + end + + it 'returns upto 5 recent messages' do + expect(recent_messages.length).to be < 6 + expect(recent_messages).to eq messages.last(5) + end + end + describe 'unread_incoming_messages' do subject(:unread_incoming_messages) { conversation.unread_incoming_messages } From d227a567475c9bf08485b29fc9c0e274d14ad0fd Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Wed, 17 Nov 2021 18:27:14 +0530 Subject: [PATCH 03/69] fix: Set default value of sortBy to empty string (#3406) --- .../dashboard/contacts/components/ContactsTable.vue | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/javascript/dashboard/routes/dashboard/contacts/components/ContactsTable.vue b/app/javascript/dashboard/routes/dashboard/contacts/components/ContactsTable.vue index f3d27032a..412b3f2fc 100644 --- a/app/javascript/dashboard/routes/dashboard/contacts/components/ContactsTable.vue +++ b/app/javascript/dashboard/routes/dashboard/contacts/components/ContactsTable.vue @@ -114,7 +114,7 @@ export default { title: this.$t('CONTACTS_PAGE.LIST.TABLE_HEADER.NAME'), fixed: 'left', align: 'left', - sortBy: this.sortConfig.name || undefined, + sortBy: this.sortConfig.name || '', width: 300, renderBodyCell: ({ row }) => ( { if (row.email) @@ -171,21 +171,21 @@ export default { { field: 'phone_number', key: 'phone_number', - sortBy: this.sortConfig.phone_number || undefined, + sortBy: this.sortConfig.phone_number || '', title: this.$t('CONTACTS_PAGE.LIST.TABLE_HEADER.PHONE_NUMBER'), align: 'left', }, { field: 'company', key: 'company', - sortBy: this.sortConfig.company_name || undefined, + sortBy: this.sortConfig.company_name || '', title: this.$t('CONTACTS_PAGE.LIST.TABLE_HEADER.COMPANY'), align: 'left', }, { field: 'city', key: 'city', - sortBy: this.sortConfig.city || undefined, + sortBy: this.sortConfig.city || '', title: this.$t('CONTACTS_PAGE.LIST.TABLE_HEADER.CITY'), align: 'left', }, @@ -194,7 +194,7 @@ export default { key: 'country', title: this.$t('CONTACTS_PAGE.LIST.TABLE_HEADER.COUNTRY'), align: 'left', - sortBy: this.sortConfig.country || undefined, + sortBy: this.sortConfig.country || '', renderBodyCell: ({ row }) => { if (row.country) { return ( From e500d1216b908a6211ff24f2491d790987eeb59b Mon Sep 17 00:00:00 2001 From: Jan-David Date: Wed, 17 Nov 2021 14:25:15 +0100 Subject: [PATCH 04/69] Fix: Make swagger doc compliant to OpenAPI (#3394) This fixes issues in the swagger.json file. The motivation to do so is to be able to generate API clients using https://openapi-generator.tech Doing so will require further changes to the api spec, but this seems like a good first step since it is now "valid" according to editor.swagger.io and openapi-generator validate. Fixes #2806 --- .circleci/config.yml | 14 +- .../definitions/request/contact/create.yml | 5 +- .../request/conversation/create_message.yml | 4 +- swagger/definitions/resource/conversation.yml | 4 +- .../definitions/resource/custom_filter.yml | 6 +- .../definitions/resource/integrations/app.yml | 2 + .../resource/public/conversation.yml | 6 +- .../definitions/resource/public/message.yml | 4 +- swagger/index.yml | 2 +- swagger/parameters/account_id.yml | 3 +- swagger/parameters/agent_bot_id.yml | 3 +- swagger/parameters/contact_sort.yml | 21 +- swagger/parameters/conversation_id.yml | 3 +- swagger/parameters/custom_filter_id.yml | 3 +- swagger/parameters/hook_id.yml | 3 +- swagger/parameters/inbox_id.yml | 3 +- swagger/parameters/message_id.yml | 3 +- swagger/parameters/page.yml | 5 +- swagger/parameters/platform_user_id.yml | 3 +- .../parameters/public/contact_identifier.yml | 3 +- .../parameters/public/inbox_identifier.yml | 3 +- swagger/parameters/report_metric.yml | 11 +- swagger/parameters/report_type.yml | 12 +- swagger/parameters/source_id.yml | 5 +- swagger/parameters/team_id.yml | 3 +- .../paths/application/agent_bots/index.yml | 2 +- swagger/paths/application/agents/create.yml | 13 +- swagger/paths/application/agents/delete.yml | 3 +- swagger/paths/application/agents/update.yml | 12 +- .../application/contact_inboxes/create.yml | 6 +- swagger/paths/application/contacts/crud.yml | 29 +- .../paths/application/conversation/create.yml | 41 -- .../paths/application/conversation/filter.yml | 85 ++- .../paths/application/conversation/index.yml | 24 +- .../conversation/labels/create.yml | 2 +- .../messages/create_attachment.yml | 3 +- .../conversation/messages/index.yml | 11 +- .../conversation/toggle_status.yml | 3 +- swagger/paths/application/inboxes/create.yml | 3 +- .../inboxes/inbox_members/create.yml | 9 +- .../inboxes/inbox_members/delete.yml | 9 +- .../inboxes/inbox_members/update.yml | 11 +- .../application/inboxes/set_agent_bot.yml | 3 +- swagger/paths/application/inboxes/update.yml | 7 +- swagger/paths/index.yml | 81 +-- .../paths/platform/account_users/create.yml | 5 +- .../paths/platform/account_users/delete.yml | 3 +- swagger/paths/platform/users/login.yml | 41 +- .../paths/public/inboxes/contacts/create.yml | 3 +- .../paths/public/inboxes/contacts/show.yml | 3 +- .../paths/public/inboxes/contacts/update.yml | 3 +- .../public/inboxes/conversations/create.yml | 3 +- .../paths/public/inboxes/messages/create.yml | 3 +- .../paths/public/inboxes/messages/update.yml | 3 +- swagger/swagger.json | 664 +++++++----------- 55 files changed, 527 insertions(+), 695 deletions(-) delete mode 100644 swagger/paths/application/conversation/create.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index c5a6430a3..5c9b27f03 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: cimg/ruby:3.0.2-node + - image: cimg/ruby:3.0.2-browsers # Specify service dependencies here if necessary # CircleCI maintains a library of pre-built images @@ -77,6 +77,18 @@ jobs: paths: - cc-test-reporter + # verify swagger specification + - run: + name: Verify swagger API specification + command: | + bundle exec rake swagger:build + if [[ `git status swagger/swagger.json --porcelain` ]] + then + echo "ERROR: The swagger.json file is not in sync with the yaml specification. Run 'rake swagger:build' and commit 'swagger/swagger.json'." + exit 1 + fi + curl -L https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.3.0/openapi-generator-cli-5.3.0.jar > ~/tmp/openapi-generator-cli-5.3.0.jar + java -jar ~/tmp/openapi-generator-cli-5.3.0.jar validate -i swagger/swagger.json # Database setup - run: yarn install --check-files - run: bundle exec rake db:create diff --git a/swagger/definitions/request/contact/create.yml b/swagger/definitions/request/contact/create.yml index c2b010892..068dda9ae 100644 --- a/swagger/definitions/request/contact/create.yml +++ b/swagger/definitions/request/contact/create.yml @@ -1,8 +1,9 @@ type: object +required: + - inbox_id properties: inbox_id: type: number - required: true name: type: string description: name of the contact @@ -12,7 +13,7 @@ properties: phone_number: type: string description: phone number of the contact - identifier: + identifier: type: string description: A unique identifier for the contact in external system custom_attributes: diff --git a/swagger/definitions/request/conversation/create_message.yml b/swagger/definitions/request/conversation/create_message.yml index da3b27a2d..9082f1318 100644 --- a/swagger/definitions/request/conversation/create_message.yml +++ b/swagger/definitions/request/conversation/create_message.yml @@ -1,9 +1,10 @@ type: object +required: + - content properties: content: type: string description: The content of the message - required: true message_type: type: string enum: ['outgoing', 'incoming'] @@ -18,4 +19,3 @@ properties: content_attributes: type: object description: attributes based on your content type - diff --git a/swagger/definitions/resource/conversation.yml b/swagger/definitions/resource/conversation.yml index 9de4dafb8..24c27f681 100644 --- a/swagger/definitions/resource/conversation.yml +++ b/swagger/definitions/resource/conversation.yml @@ -5,6 +5,8 @@ properties: description: ID of the conversation messages: type: array + items: + $ref: '#/definitions/message' account_id: type: number description: Account Id @@ -21,7 +23,7 @@ properties: contact_last_seen_at: type: string agent_last_seen_at: - type: agent_last_seen_at + type: string unread_count: type: number description: The number of unread messages diff --git a/swagger/definitions/resource/custom_filter.yml b/swagger/definitions/resource/custom_filter.yml index 130377d62..6d96c1e84 100644 --- a/swagger/definitions/resource/custom_filter.yml +++ b/swagger/definitions/resource/custom_filter.yml @@ -14,8 +14,10 @@ properties: type: object description: A query that needs to be saved as a custom filter created_at: - type: datetime + type: string + format: date-time description: The time at which the custom filter was created updated_at: - type: datetime + type: string + format: date-time description: The time at which the custom filter was updated diff --git a/swagger/definitions/resource/integrations/app.yml b/swagger/definitions/resource/integrations/app.yml index ce7fb1e75..1136f2aca 100644 --- a/swagger/definitions/resource/integrations/app.yml +++ b/swagger/definitions/resource/integrations/app.yml @@ -20,4 +20,6 @@ properties: description: Whether multiple hooks can be created for the integration hooks: type: array + items: + type: object description: If there are any hooks created for this integration diff --git a/swagger/definitions/resource/public/conversation.yml b/swagger/definitions/resource/public/conversation.yml index 97e4b48eb..a2f797e1b 100644 --- a/swagger/definitions/resource/public/conversation.yml +++ b/swagger/definitions/resource/public/conversation.yml @@ -1,5 +1,5 @@ type: object -properties: +properties: id: type: integer description: Id of the conversation @@ -8,7 +8,9 @@ properties: description: The inbox id of the conversation messages: type: array + items: + $ref: '#/definitions/message' description: Messages in the conversation contact: type: object - description: The contact information associated to the conversation \ No newline at end of file + description: The contact information associated to the conversation diff --git a/swagger/definitions/resource/public/message.yml b/swagger/definitions/resource/public/message.yml index fe2c80a0c..242a4fbf4 100644 --- a/swagger/definitions/resource/public/message.yml +++ b/swagger/definitions/resource/public/message.yml @@ -1,5 +1,5 @@ type: object -properties: +properties: id: type: string description: Id of the message @@ -23,6 +23,8 @@ properties: description: Conversation Id of the message attachments: type: array + items: + type: object description: Attachments if any sender: type: object diff --git a/swagger/index.yml b/swagger/index.yml index 908c27509..2420658e3 100644 --- a/swagger/index.yml +++ b/swagger/index.yml @@ -10,7 +10,7 @@ info: name: MIT License url: https://opensource.org/licenses/MIT host: app.chatwoot.com -basePath: +basePath: / schemes: - https produces: diff --git a/swagger/parameters/account_id.yml b/swagger/parameters/account_id.yml index 133155c21..aa3d48a8a 100644 --- a/swagger/parameters/account_id.yml +++ b/swagger/parameters/account_id.yml @@ -1,6 +1,5 @@ in: path name: account_id -schema: - type: integer +type: integer required: true description: The numeric ID of the account diff --git a/swagger/parameters/agent_bot_id.yml b/swagger/parameters/agent_bot_id.yml index 4d1479cb4..6c94ef5dc 100644 --- a/swagger/parameters/agent_bot_id.yml +++ b/swagger/parameters/agent_bot_id.yml @@ -1,6 +1,5 @@ in: path name: id -schema: - type: integer +type: integer required: true description: The ID of the agentbot to be updated diff --git a/swagger/parameters/contact_sort.yml b/swagger/parameters/contact_sort.yml index f25d07760..6f3da0b1b 100644 --- a/swagger/parameters/contact_sort.yml +++ b/swagger/parameters/contact_sort.yml @@ -1,15 +1,14 @@ in: query name: sort -schema: - type: string - enum: - - name - - email - - phone_number - - last_activity_at - - -name - - -email - - -phone_number - - -last_activity_at +type: string +enum: + - name + - email + - phone_number + - last_activity_at + - -name + - -email + - -phone_number + - -last_activity_at required: false description: The attribute by which list should be sorted diff --git a/swagger/parameters/conversation_id.yml b/swagger/parameters/conversation_id.yml index 4f4cb19ab..d8de755fe 100644 --- a/swagger/parameters/conversation_id.yml +++ b/swagger/parameters/conversation_id.yml @@ -1,6 +1,5 @@ in: path name: conversation_id -schema: - type: integer +type: integer required: true description: The numeric ID of the conversation diff --git a/swagger/parameters/custom_filter_id.yml b/swagger/parameters/custom_filter_id.yml index 46776511f..b19f52f8e 100644 --- a/swagger/parameters/custom_filter_id.yml +++ b/swagger/parameters/custom_filter_id.yml @@ -1,6 +1,5 @@ in: path name: custom_filter_id -schema: - type: integer +type: integer required: true description: The numeric ID of the custom filter diff --git a/swagger/parameters/hook_id.yml b/swagger/parameters/hook_id.yml index f1c50c3d4..c1600def4 100644 --- a/swagger/parameters/hook_id.yml +++ b/swagger/parameters/hook_id.yml @@ -1,6 +1,5 @@ in: path name: hook_id -schema: - type: integer +type: integer required: true description: The numeric ID of the integration hook diff --git a/swagger/parameters/inbox_id.yml b/swagger/parameters/inbox_id.yml index 58640fb08..716d34de6 100644 --- a/swagger/parameters/inbox_id.yml +++ b/swagger/parameters/inbox_id.yml @@ -1,6 +1,5 @@ in: path name: inbox_id -schema: - type: integer +type: integer required: true description: The ID of the Inbox diff --git a/swagger/parameters/message_id.yml b/swagger/parameters/message_id.yml index 3064a31e2..3fc6edfcf 100644 --- a/swagger/parameters/message_id.yml +++ b/swagger/parameters/message_id.yml @@ -1,6 +1,5 @@ in: path name: message_id -schema: - type: integer +type: integer required: true description: The numeric ID of the message diff --git a/swagger/parameters/page.yml b/swagger/parameters/page.yml index 3ef0f55b6..8cdc77b1e 100644 --- a/swagger/parameters/page.yml +++ b/swagger/parameters/page.yml @@ -1,7 +1,6 @@ in: query name: page -schema: - type: integer - default: 1 +type: integer +default: 1 required: false description: The page parameter diff --git a/swagger/parameters/platform_user_id.yml b/swagger/parameters/platform_user_id.yml index 708a0aad9..d31f71878 100644 --- a/swagger/parameters/platform_user_id.yml +++ b/swagger/parameters/platform_user_id.yml @@ -1,6 +1,5 @@ in: path name: id -schema: - type: integer +type: integer required: true description: The numeric ID of the user on the platform diff --git a/swagger/parameters/public/contact_identifier.yml b/swagger/parameters/public/contact_identifier.yml index 3dd2d28c2..6bb522c6b 100644 --- a/swagger/parameters/public/contact_identifier.yml +++ b/swagger/parameters/public/contact_identifier.yml @@ -1,6 +1,5 @@ in: path name: contact_identifier -schema: - type: string +type: string required: true description: The source id of contact obtained on contact create diff --git a/swagger/parameters/public/inbox_identifier.yml b/swagger/parameters/public/inbox_identifier.yml index 35e33e6c2..091c0d73e 100644 --- a/swagger/parameters/public/inbox_identifier.yml +++ b/swagger/parameters/public/inbox_identifier.yml @@ -1,6 +1,5 @@ in: path name: inbox_identifier -schema: - type: string +type: string required: true description: The identifier obtained from API inbox channel diff --git a/swagger/parameters/report_metric.yml b/swagger/parameters/report_metric.yml index d40cadc9c..552b0d310 100644 --- a/swagger/parameters/report_metric.yml +++ b/swagger/parameters/report_metric.yml @@ -1,7 +1,12 @@ in: query name: metric -schema: - type: string - enum: [conversations_count, incoming_messages_count, outgoing_messages_count, avg_first_response_time, avg_resolution_time, resolutions_count] +type: string +enum: + - conversations_count + - incoming_messages_count + - outgoing_messages_count + - avg_first_response_time + - avg_resolution_time + - resolutions_count required: true description: The type of metric diff --git a/swagger/parameters/report_type.yml b/swagger/parameters/report_type.yml index 407478d9d..5def952c6 100644 --- a/swagger/parameters/report_type.yml +++ b/swagger/parameters/report_type.yml @@ -1,7 +1,11 @@ in: query name: report_type -schema: - type: string - enum: [account,agent,inbox,label,team] +type: string +enum: + - account + - agent + - inbox + - label + - team required: true -description: Type of report +description: Type of report diff --git a/swagger/parameters/source_id.yml b/swagger/parameters/source_id.yml index 47536332f..408beed86 100644 --- a/swagger/parameters/source_id.yml +++ b/swagger/parameters/source_id.yml @@ -1,2 +1,5 @@ +in: path +name: source_id +required: true type: string -description: "Id of the session for which the conversation is created.\n\n\n\n Source Ids can be obtained through contactable inboxes API or via generated.

Website: Chatwoot generated string which can be obtained from webhook events.
Phone Channels(Twilio): Phone number in e164 format
Email Channels: Contact Email address
API Channel: Any Random String" \ No newline at end of file +description: "Id of the session for which the conversation is created.\n\n\n\n Source Ids can be obtained through contactable inboxes API or via generated.

Website: Chatwoot generated string which can be obtained from webhook events.
Phone Channels(Twilio): Phone number in e164 format
Email Channels: Contact Email address
API Channel: Any Random String" diff --git a/swagger/parameters/team_id.yml b/swagger/parameters/team_id.yml index e71d32d6e..805c32c2d 100644 --- a/swagger/parameters/team_id.yml +++ b/swagger/parameters/team_id.yml @@ -1,6 +1,5 @@ in: path name: id -schema: - type: integer +type: integer required: true description: The ID of the team to be updated diff --git a/swagger/paths/application/agent_bots/index.yml b/swagger/paths/application/agent_bots/index.yml index 26766f5c8..2c5fe289f 100644 --- a/swagger/paths/application/agent_bots/index.yml +++ b/swagger/paths/application/agent_bots/index.yml @@ -10,7 +10,7 @@ responses: type: array description: 'Array of agent bots' items: - - $ref: '#/definitions/agent_bot' + $ref: '#/definitions/agent_bot' 401: description: Unauthorized diff --git a/swagger/paths/application/agents/create.yml b/swagger/paths/application/agents/create.yml index 01ae1ed42..b206eb306 100644 --- a/swagger/paths/application/agents/create.yml +++ b/swagger/paths/application/agents/create.yml @@ -11,21 +11,22 @@ parameters: required: true schema: type: object + required: + - name + - email + - role properties: - name: + name: type: string description: Full Name of the agent - required: true email: type: string description: Email of the Agent - required: true - role: + role: type: string enum: ['agent', 'administrator'] description: Whether its administrator or agent - required: true - availability_status: + availability_status: type: string enum: ['available', 'busy', 'offline'] description: The availability setting of the agent. diff --git a/swagger/paths/application/agents/delete.yml b/swagger/paths/application/agents/delete.yml index 533d3f1ca..1872fd8ea 100644 --- a/swagger/paths/application/agents/delete.yml +++ b/swagger/paths/application/agents/delete.yml @@ -8,8 +8,7 @@ security: parameters: - in: path name: id - schema: - type: integer + type: integer required: true description: The ID of the agent to be deleted responses: diff --git a/swagger/paths/application/agents/update.yml b/swagger/paths/application/agents/update.yml index bd3b3f2cb..693bef5b2 100644 --- a/swagger/paths/application/agents/update.yml +++ b/swagger/paths/application/agents/update.yml @@ -8,8 +8,7 @@ security: parameters: - in: path name: id - schema: - type: integer + type: integer required: true description: The ID of the agent to be updated. - name: data @@ -17,13 +16,14 @@ parameters: required: true schema: type: object + required: + - role properties: - role: + role: type: string enum: ['agent', 'administrator'] description: Whether its administrator or agent - required: true - availability: + availability: type: string enum: ['available', 'busy', 'offline'] description: The availability setting of the agent. @@ -39,4 +39,4 @@ responses: 404: description: Agent not found 403: - description: Access denied \ No newline at end of file + description: Access denied diff --git a/swagger/paths/application/contact_inboxes/create.yml b/swagger/paths/application/contact_inboxes/create.yml index 210949ebf..2b784b5dd 100644 --- a/swagger/paths/application/contact_inboxes/create.yml +++ b/swagger/paths/application/contact_inboxes/create.yml @@ -16,13 +16,15 @@ post: required: true schema: type: object + required: + - inbox_id properties: inbox_id: type: number description: The ID of the inbox - required: true source_id: - $ref: '#/parameters/source_id' + type: string + description: Contact Inbox Source Id responses: 200: description: Success diff --git a/swagger/paths/application/contacts/crud.yml b/swagger/paths/application/contacts/crud.yml index 7f0089b4b..af9fecff7 100644 --- a/swagger/paths/application/contacts/crud.yml +++ b/swagger/paths/application/contacts/crud.yml @@ -1,16 +1,17 @@ +parameters: + - $ref: '#/parameters/account_id' + - name: id + in: path + type: number + description: ID of the contact + required: true + get: tags: - Contact operationId: contactDetails summary: Show Contact description: Get a contact belonging to the account using ID - parameters: - - $ref: '#/parameters/account_id' - - name: id - in: path - type: number - description: ID of the contact - required: true responses: 200: description: Success @@ -28,12 +29,6 @@ put: summary: Update Contact description: Update a contact belonging to the account using ID parameters: - - $ref: '#/parameters/account_id' - - name: id - in: path - type: number - description: ID of the contact - required: true - name: data in: body required: true @@ -54,16 +49,10 @@ delete: - Contact operationId: contactDelete summary: Delete Contact - parameters: - - name: id - in: path - type: number - description: ID of the contact - required: true responses: 200: description: Success 401: description: Unauthorized 404: - description: Contact not found \ No newline at end of file + description: Contact not found diff --git a/swagger/paths/application/conversation/create.yml b/swagger/paths/application/conversation/create.yml deleted file mode 100644 index 104460bae..000000000 --- a/swagger/paths/application/conversation/create.yml +++ /dev/null @@ -1,41 +0,0 @@ -get: - tags: - - Conversation - operationId: conversationList - description: List all the conversations with pagination - summary: Conversations List - parameters: - - $ref: '#/parameters/account_id' - - name: assignee_type - in: query - type: string - enum: ['me', 'unassigned', 'all', 'assigned'] - required: true - - name: status - in: query - type: string - enum: ['open', 'resolved', 'pending'] - required: true - - name: page - in: query - type: integer - required: true - - name: inbox_id - in: query - type: integer - - name: labels - in: query - type: array - items: - type: string - - responses: - 200: - description: Success - schema: - $ref: '#/definitions/conversation_list' - 400: - description: Bad Request Error - schema: - $ref: '#/definitions/bad_request_error' - description: Access denied \ No newline at end of file diff --git a/swagger/paths/application/conversation/filter.yml b/swagger/paths/application/conversation/filter.yml index 39d8259cf..ce14b7823 100644 --- a/swagger/paths/application/conversation/filter.yml +++ b/swagger/paths/application/conversation/filter.yml @@ -1,44 +1,43 @@ -post: - tags: - - Conversation - operationId: conversationFilter - description: Filter conversations with custom filter options and pagination - summary: Conversations Filter - security: - - userApiKey: [] - - agentBotApiKey: [] - parameters: - - name: page - in: query - type: integer - - name: payload - in: body - required: true - schema: - type: array - items: - type: object - properties: - attribute_key: +tags: + - Conversation +operationId: conversationFilter +description: Filter conversations with custom filter options and pagination +summary: Conversations Filter +security: + - userApiKey: [] + - agentBotApiKey: [] +parameters: + - name: page + in: query + type: integer + - name: payload + in: body + required: true + schema: + type: array + items: + type: object + properties: + attribute_key: + type: string + description: filter attribute name + filter_operator: + type: string + description: filter operator name + values: + type: array + items: type: string - description: filter attribute name - filter_operator: - type: string - description: filter operator name - values: - type: array - description: array of the attribute values to filter - query_operator: - type: string - description: query operator name - - $ref: '#/parameters/account_id' - responses: - 200: - description: Success - schema: - $ref: '#/definitions/conversation_list' - 400: - description: Bad Request Error - schema: - $ref: '#/definitions/bad_request_error' - description: Access denied + description: array of the attribute values to filter + query_operator: + type: string + description: query operator name +responses: + 200: + description: Success + schema: + $ref: '#/definitions/conversation_list' + 400: + description: Bad Request Error + schema: + $ref: '#/definitions/bad_request_error' diff --git a/swagger/paths/application/conversation/index.yml b/swagger/paths/application/conversation/index.yml index 022fe7911..d5f8f9c0c 100644 --- a/swagger/paths/application/conversation/index.yml +++ b/swagger/paths/application/conversation/index.yml @@ -1,24 +1,27 @@ +parameters: + - $ref: '#/parameters/account_id' + get: tags: - Conversation - operationId: conversationSearch - description: Search for conversations containing a messages with the query string - summary: Conversations Search + operationId: conversationList + description: List all the conversations with pagination + summary: Conversations List parameters: - - name: q - in: query - type: string - name: assignee_type in: query type: string enum: ['me', 'unassigned', 'all', 'assigned'] + required: true - name: status in: query type: string - enum: ['open', 'resolved', 'pending', 'all'] + enum: ['open', 'resolved', 'pending'] + required: true - name: page in: query type: integer + required: true - name: inbox_id in: query type: integer @@ -27,7 +30,6 @@ get: type: array items: type: string - - $ref: '#/parameters/account_id' responses: 200: @@ -38,8 +40,6 @@ get: description: Bad Request Error schema: $ref: '#/definitions/bad_request_error' - description: Access denied - post: tags: @@ -51,7 +51,6 @@ post: - userApiKey: [] - agentBotApiKey: [] parameters: - - $ref: '#/parameters/account_id' - name: data in: body required: true @@ -59,7 +58,8 @@ post: type: object properties: source_id: - $ref: '#/parameters/source_id' + type: string + description: Conversation source id inbox_id: type: string description: "Id of inbox in which the conversation is created
Allowed Inbox Types: Website, Phone, Api, Email " diff --git a/swagger/paths/application/conversation/labels/create.yml b/swagger/paths/application/conversation/labels/create.yml index 6082ccae4..0f686ee24 100644 --- a/swagger/paths/application/conversation/labels/create.yml +++ b/swagger/paths/application/conversation/labels/create.yml @@ -13,7 +13,7 @@ parameters: labels: type: array description: Array of labels (comma-separated strings) - properties: + items: type: string responses: 200: diff --git a/swagger/paths/application/conversation/messages/create_attachment.yml b/swagger/paths/application/conversation/messages/create_attachment.yml index 155876e13..594f9a819 100644 --- a/swagger/paths/application/conversation/messages/create_attachment.yml +++ b/swagger/paths/application/conversation/messages/create_attachment.yml @@ -31,7 +31,8 @@ post: type: array description: The files to be uploaded. items: - type: file + type: string + format: binary responses: diff --git a/swagger/paths/application/conversation/messages/index.yml b/swagger/paths/application/conversation/messages/index.yml index 8fe7558ae..d99e8393b 100644 --- a/swagger/paths/application/conversation/messages/index.yml +++ b/swagger/paths/application/conversation/messages/index.yml @@ -6,12 +6,13 @@ description: List all messages of a conversation responses: 200: description: Success - type: array - description: Array of messages schema: - allOf: - - $ref: '#/definitions/generic_id' - - $ref: '#/definitions/message' + type: array + description: Array of messages + items: + allOf: + - $ref: '#/definitions/generic_id' + - $ref: '#/definitions/message' 404: description: Conversation not found 401: diff --git a/swagger/paths/application/conversation/toggle_status.yml b/swagger/paths/application/conversation/toggle_status.yml index a737281a4..14172e27c 100644 --- a/swagger/paths/application/conversation/toggle_status.yml +++ b/swagger/paths/application/conversation/toggle_status.yml @@ -12,11 +12,12 @@ parameters: required: true schema: type: object + required: + - status properties: status: type: string enum: ["open", "resolved", "pending"] - required: true description: The status of the conversation responses: 200: diff --git a/swagger/paths/application/inboxes/create.yml b/swagger/paths/application/inboxes/create.yml index 3cb30689e..2a63775e7 100644 --- a/swagger/paths/application/inboxes/create.yml +++ b/swagger/paths/application/inboxes/create.yml @@ -16,7 +16,8 @@ post: type: string description: The name of the inbox avatar: - type: file + type: string + format: binary description: File for avatar image channel: type: object diff --git a/swagger/paths/application/inboxes/inbox_members/create.yml b/swagger/paths/application/inboxes/inbox_members/create.yml index 6ffd75af5..2cbbb4598 100644 --- a/swagger/paths/application/inboxes/inbox_members/create.yml +++ b/swagger/paths/application/inboxes/inbox_members/create.yml @@ -11,15 +11,18 @@ parameters: required: true schema: type: object + required: + - inbox_id + - user_ids properties: inbox_id: type: string description: The ID of the inbox - required: true - user_ids: + user_ids: type: array + items: + type: integer description: IDs of users to be added to the inbox - required: true responses: 200: description: Success diff --git a/swagger/paths/application/inboxes/inbox_members/delete.yml b/swagger/paths/application/inboxes/inbox_members/delete.yml index a19f1c179..3167b28c6 100644 --- a/swagger/paths/application/inboxes/inbox_members/delete.yml +++ b/swagger/paths/application/inboxes/inbox_members/delete.yml @@ -11,15 +11,18 @@ parameters: required: true schema: type: object + required: + - inbox_id + - user_ids properties: inbox_id: type: string description: The ID of the inbox - required: true - user_ids: + user_ids: type: array + items: + type: integer description: IDs of users to be deleted from the inbox - required: true responses: 200: description: Success diff --git a/swagger/paths/application/inboxes/inbox_members/update.yml b/swagger/paths/application/inboxes/inbox_members/update.yml index 0bcf81747..3a06cef27 100644 --- a/swagger/paths/application/inboxes/inbox_members/update.yml +++ b/swagger/paths/application/inboxes/inbox_members/update.yml @@ -2,7 +2,7 @@ tags: - Inbox operationId: update-agents-in-inbox summary: Update Agents in Inbox -description: All agents execept the one passed in params will be removed +description: All agents except the one passed in params will be removed security: - userApiKey: [] parameters: @@ -11,15 +11,18 @@ parameters: required: true schema: type: object + required: + - inbox_id + - user_ids properties: inbox_id: type: string description: The ID of the inbox - required: true - user_ids: + user_ids: type: array + items: + type: integer description: IDs of users to be added to the inbox - required: true responses: 200: description: Success diff --git a/swagger/paths/application/inboxes/set_agent_bot.yml b/swagger/paths/application/inboxes/set_agent_bot.yml index fbe0c03ab..b37b06915 100644 --- a/swagger/paths/application/inboxes/set_agent_bot.yml +++ b/swagger/paths/application/inboxes/set_agent_bot.yml @@ -16,10 +16,11 @@ post: required: true schema: type: object + required: + - agent_bot properties: agent_bot: type: number - required: true description: 'Agent bot ID' responses: 204: diff --git a/swagger/paths/application/inboxes/update.yml b/swagger/paths/application/inboxes/update.yml index 90a3d13ce..d44822114 100644 --- a/swagger/paths/application/inboxes/update.yml +++ b/swagger/paths/application/inboxes/update.yml @@ -16,17 +16,18 @@ patch: required: true schema: type: object + required: + - enable_auto_assignment properties: name: type: string description: The name of the inbox enable_auto_assignment: type: boolean - required: true description: 'Enable Auto Assignment' avatar: - type: file - required: false + type: string + format: binary description: 'Image file for avatar' channel: type: object diff --git a/swagger/paths/index.yml b/swagger/paths/index.yml index 7f25ec67e..b25d6ff68 100644 --- a/swagger/paths/index.yml +++ b/swagger/paths/index.yml @@ -2,10 +2,10 @@ # Accounts -platform/api/v1/accounts: +/platform/api/v1/accounts: post: $ref: ./platform/accounts/create.yml -platform/api/v1/accounts/{id}: +/platform/api/v1/accounts/{account_id}: parameters: - $ref: '#/parameters/account_id' get: @@ -18,7 +18,7 @@ platform/api/v1/accounts/{id}: # Account Users -platform/api/v1/accounts/{id}/account_users: +/platform/api/v1/accounts/{account_id}/account_users: parameters: - $ref: '#/parameters/account_id' get: @@ -30,12 +30,12 @@ platform/api/v1/accounts/{id}/account_users: # AgentBots -platform/api/v1/agent_bots: +/platform/api/v1/agent_bots: get: $ref: ./platform/agent_bots/index.yml post: $ref: ./platform/agent_bots/create.yml -platform/api/v1/agent_bots/{id}: +/platform/api/v1/agent_bots/{id}: parameters: - $ref: '#/parameters/agent_bot_id' get: @@ -47,10 +47,10 @@ platform/api/v1/agent_bots/{id}: # Users -platform/api/v1/users: +/platform/api/v1/users: post: $ref: ./platform/users/create.yml -platform/api/v1/users/{id}: +/platform/api/v1/users/{id}: parameters: - $ref: '#/parameters/platform_user_id' get: @@ -59,10 +59,11 @@ platform/api/v1/users/{id}: $ref: ./platform/users/update.yml delete: $ref: ./platform/users/delete.yml -platform/api/v1/users/{id}/login: +/platform/api/v1/users/{id}/login: parameters: - $ref: '#/parameters/platform_user_id' - $ref: './platform/users/login.yml' + get: + $ref: './platform/users/login.yml' # ---------------- end of platform path -----------# @@ -71,12 +72,12 @@ platform/api/v1/users/{id}/login: # Contacts -public/api/v1/inboxes/{inbox_identifier}/contacts: +/public/api/v1/inboxes/{inbox_identifier}/contacts: parameters: - $ref: '#/parameters/public_inbox_identifier' post: $ref: ./public/inboxes/contacts/create.yml -public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}: +/public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}: parameters: - $ref: '#/parameters/public_inbox_identifier' - $ref: '#/parameters/public_contact_identifier' @@ -86,7 +87,7 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}: $ref: ./public/inboxes/contacts/update.yml -public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations: +/public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations: parameters: - $ref: '#/parameters/public_inbox_identifier' - $ref: '#/parameters/public_contact_identifier' @@ -95,7 +96,7 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat get: $ref: ./public/inboxes/conversations/index.yml -public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages: +/public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages: parameters: - $ref: '#/parameters/public_inbox_identifier' - $ref: '#/parameters/public_contact_identifier' @@ -104,7 +105,7 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat $ref: ./public/inboxes/messages/create.yml get: $ref: ./public/inboxes/messages/index.yml -public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages/{message_id}: +/public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages/{message_id}: parameters: - $ref: '#/parameters/public_inbox_identifier' - $ref: '#/parameters/public_contact_identifier' @@ -139,11 +140,15 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat # Agents /api/v1/accounts/{account_id}/agents: + parameters: + - $ref: '#/parameters/account_id' get: $ref: ./application/agents/index.yml post: $ref: ./application/agents/create.yml /api/v1/accounts/{account_id}/agents/{id}: + parameters: + - $ref: '#/parameters/account_id' patch: $ref: ./application/agents/update.yml delete: @@ -167,18 +172,13 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat # Conversations /api/v1/accounts/{account_id}/conversations: - parameters: - - $ref: '#/parameters/account_id' $ref: ./application/conversation/index.yml -/api/v1/accounts/{account_id}/conversations/: - parameters: - - $ref: '#/parameters/account_id' - $ref: ./application/conversation/create.yml /api/v1/accounts/{account_id}/conversations/filter: parameters: - $ref: '#/parameters/account_id' - $ref: ./application/conversation/filter.yml -/api/v1/accounts/{account_id}/conversations/{converstion_id}: + post: + $ref: ./application/conversation/filter.yml +/api/v1/accounts/{account_id}/conversations/{conversation_id}: parameters: - $ref: '#/parameters/account_id' - $ref: '#/parameters/conversation_id' @@ -227,7 +227,10 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat $ref: ./application/inboxes/set_agent_bot.yml # Inbox Members -/api/v1/accounts/{account_id}/inbox_members: +/api/v1/accounts/{account_id}/inbox_members/{inbox_id}: + parameters: + - $ref: '#/parameters/account_id' + - $ref: '#/parameters/inbox_id' get: $ref: ./application/inboxes/inbox_members/show.yml post: @@ -240,9 +243,7 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat # Messages -/api/v1/accounts/{account_id}/conversations/{id}/messages: - $ref: ./application/conversation/messages/create_attachment.yml -/api/v1/accounts/{account_id}/conversations/{converstion_id}/messages: +/api/v1/accounts/{account_id}/conversations/{conversation_id}/messages: parameters: - $ref: '#/parameters/account_id' - $ref: '#/parameters/conversation_id' @@ -269,6 +270,7 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat /api/v1/accounts/{account_id}/integrations/hooks: post: $ref: './application/integrations/hooks/create.yml' +/api/v1/accounts/{account_id}/integrations/hooks/{hook_id}: patch: $ref: ./application/integrations/hooks/update.yml delete: @@ -308,9 +310,8 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat - $ref: '#/parameters/account_id' - in: query name: filter_type - schema: - type: string - enum: ['conversation', 'contact', 'report'] + type: string + enum: ['conversation', 'contact', 'report'] required: false description: The type of custom filter get: @@ -331,48 +332,42 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat ### Reports # List -/api/v2/accounts/{id}/reports: +/api/v2/accounts/{account_id}/reports: parameters: - $ref: '#/parameters/account_id' - $ref: '#/parameters/report_metric' - $ref: '#/parameters/report_type' - in: query name: id - schema: - type: string + type: string description: The Id of specific object in case of agent/inbox/label - in: query name: since - schema: - type: string + type: string description: The timestamp from where report should start. - in: query name: until - schema: - type: string + type: string description: The timestamp from where report should stop. get: $ref: './application/reports/index.yml' # Summary -/api/v2/accounts/{id}/reports/summary: +/api/v2/accounts/{account_id}/reports/summary: parameters: - $ref: '#/parameters/account_id' - $ref: '#/parameters/report_type' - in: query name: id - schema: - type: string + type: string description: The Id of specific object in case of agent/inbox/label - in: query name: since - schema: - type: string + type: string description: The timestamp from where report should start. - in: query name: until - schema: - type: string + type: string description: The timestamp from where report should stop. get: $ref: './application/reports/summary.yml' diff --git a/swagger/paths/platform/account_users/create.yml b/swagger/paths/platform/account_users/create.yml index 614efb7a8..97dc7127d 100644 --- a/swagger/paths/platform/account_users/create.yml +++ b/swagger/paths/platform/account_users/create.yml @@ -11,15 +11,16 @@ parameters: required: true schema: type: object + required: + - user_id + - role properties: user_id: type: integer description: The ID of the user - required: true role: type: string description: whether user is an administrator or agent - required: true responses: 200: diff --git a/swagger/paths/platform/account_users/delete.yml b/swagger/paths/platform/account_users/delete.yml index 1ff822a9e..d864619f7 100644 --- a/swagger/paths/platform/account_users/delete.yml +++ b/swagger/paths/platform/account_users/delete.yml @@ -11,11 +11,12 @@ parameters: required: true schema: type: object + required: + - user_id properties: user_id: type: integer description: The ID of the user - required: true responses: 200: diff --git a/swagger/paths/platform/users/login.yml b/swagger/paths/platform/users/login.yml index 3f0b8b4c1..be210c7aa 100644 --- a/swagger/paths/platform/users/login.yml +++ b/swagger/paths/platform/users/login.yml @@ -1,21 +1,20 @@ -get: - tags: - - Users - operationId: get-sso-url-of-a-user - summary: Get User SSO Link - description: Get the sso link of a user - security: - - platformAppApiKey: [] - responses: - 200: - description: Success - schema: - type: object - properties: - url: - type: string - description: SSO url to autenticate the user - 401: - description: Unauthorized - 404: - description: The given user does not exist +tags: + - Users +operationId: get-sso-url-of-a-user +summary: Get User SSO Link +description: Get the sso link of a user +security: + - platformAppApiKey: [] +responses: + 200: + description: Success + schema: + type: object + properties: + url: + type: string + description: SSO url to autenticate the user + 401: + description: Unauthorized + 404: + description: The given user does not exist diff --git a/swagger/paths/public/inboxes/contacts/create.yml b/swagger/paths/public/inboxes/contacts/create.yml index e504ee9e7..51d894f3e 100644 --- a/swagger/paths/public/inboxes/contacts/create.yml +++ b/swagger/paths/public/inboxes/contacts/create.yml @@ -3,8 +3,7 @@ tags: operationId: create-a-contact summary: Create a contact description: Create a contact -security: - - nil +security: [] parameters: - name: data in: body diff --git a/swagger/paths/public/inboxes/contacts/show.yml b/swagger/paths/public/inboxes/contacts/show.yml index a57d3e0b5..a5d8b8fdc 100644 --- a/swagger/paths/public/inboxes/contacts/show.yml +++ b/swagger/paths/public/inboxes/contacts/show.yml @@ -3,8 +3,7 @@ tags: operationId: get-details-of-a-contact summary: Get a contact description: Get the details of a contact -security: - - nil +security: [] responses: 200: description: Success diff --git a/swagger/paths/public/inboxes/contacts/update.yml b/swagger/paths/public/inboxes/contacts/update.yml index 084926134..a413c76b3 100644 --- a/swagger/paths/public/inboxes/contacts/update.yml +++ b/swagger/paths/public/inboxes/contacts/update.yml @@ -3,8 +3,7 @@ tags: operationId: update-a-contact summary: Update a contact description: Update a contact's attributes -security: - - nil +security: [] parameters: - name: data in: body diff --git a/swagger/paths/public/inboxes/conversations/create.yml b/swagger/paths/public/inboxes/conversations/create.yml index 2654685f5..5f694ff34 100644 --- a/swagger/paths/public/inboxes/conversations/create.yml +++ b/swagger/paths/public/inboxes/conversations/create.yml @@ -3,8 +3,7 @@ tags: operationId: create-a-conversation summary: Create a conversation description: Create a conversation -security: - - nil +security: [] responses: 200: description: Success diff --git a/swagger/paths/public/inboxes/messages/create.yml b/swagger/paths/public/inboxes/messages/create.yml index 16e44eb0d..902090952 100644 --- a/swagger/paths/public/inboxes/messages/create.yml +++ b/swagger/paths/public/inboxes/messages/create.yml @@ -3,8 +3,7 @@ tags: operationId: create-a-message summary: Create a message description: Create a message -security: - - nil +security: [] parameters: - name: data in: body diff --git a/swagger/paths/public/inboxes/messages/update.yml b/swagger/paths/public/inboxes/messages/update.yml index 70ffb9d0c..a211f39ca 100644 --- a/swagger/paths/public/inboxes/messages/update.yml +++ b/swagger/paths/public/inboxes/messages/update.yml @@ -3,8 +3,7 @@ tags: operationId: update-a-message summary: Update a message description: Update a message -security: - - nil +security: [] parameters: - name: data in: body diff --git a/swagger/swagger.json b/swagger/swagger.json index fadd07720..d19f43a7f 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -14,7 +14,7 @@ } }, "host": "app.chatwoot.com", - "basePath": null, + "basePath": "/", "schemes": [ "https" ], @@ -52,7 +52,7 @@ } ], "paths": { - "platform/api/v1/accounts": { + "/platform/api/v1/accounts": { "post": { "tags": [ "Accounts" @@ -90,7 +90,7 @@ } } }, - "platform/api/v1/accounts/{id}": { + "/platform/api/v1/accounts/{account_id}": { "parameters": [ { "$ref": "#/parameters/account_id" @@ -188,7 +188,7 @@ } } }, - "platform/api/v1/accounts/{id}/account_users": { + "/platform/api/v1/accounts/{account_id}/account_users": { "parameters": [ { "$ref": "#/parameters/account_id" @@ -259,16 +259,18 @@ "required": true, "schema": { "type": "object", + "required": [ + "user_id", + "role" + ], "properties": { "user_id": { "type": "integer", - "description": "The ID of the user", - "required": true + "description": "The ID of the user" }, "role": { "type": "string", - "description": "whether user is an administrator or agent", - "required": true + "description": "whether user is an administrator or agent" } } } @@ -320,11 +322,13 @@ "required": true, "schema": { "type": "object", + "required": [ + "user_id" + ], "properties": { "user_id": { "type": "integer", - "description": "The ID of the user", - "required": true + "description": "The ID of the user" } } } @@ -343,7 +347,7 @@ } } }, - "platform/api/v1/agent_bots": { + "/platform/api/v1/agent_bots": { "get": { "tags": [ "AgentBots" @@ -411,7 +415,7 @@ } } }, - "platform/api/v1/agent_bots/{id}": { + "/platform/api/v1/agent_bots/{id}": { "parameters": [ { "$ref": "#/parameters/agent_bot_id" @@ -509,7 +513,7 @@ } } }, - "platform/api/v1/users": { + "/platform/api/v1/users": { "post": { "tags": [ "Users" @@ -547,7 +551,7 @@ } } }, - "platform/api/v1/users/{id}": { + "/platform/api/v1/users/{id}": { "parameters": [ { "$ref": "#/parameters/platform_user_id" @@ -645,7 +649,12 @@ } } }, - "platform/api/v1/users/{id}/login": { + "/platform/api/v1/users/{id}/login": { + "parameters": [ + { + "$ref": "#/parameters/platform_user_id" + } + ], "get": { "tags": [ "Users" @@ -682,7 +691,7 @@ } } }, - "public/api/v1/inboxes/{inbox_identifier}/contacts": { + "/public/api/v1/inboxes/{inbox_identifier}/contacts": { "parameters": [ { "$ref": "#/parameters/public_inbox_identifier" @@ -696,7 +705,7 @@ "summary": "Create a contact", "description": "Create a contact", "security": [ - "nil" + ], "parameters": [ { @@ -721,7 +730,7 @@ } } }, - "public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}": { + "/public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}": { "parameters": [ { "$ref": "#/parameters/public_inbox_identifier" @@ -738,7 +747,7 @@ "summary": "Get a contact", "description": "Get the details of a contact", "security": [ - "nil" + ], "responses": { "200": { @@ -763,7 +772,7 @@ "summary": "Update a contact", "description": "Update a contact's attributes", "security": [ - "nil" + ], "parameters": [ { @@ -788,7 +797,7 @@ } } }, - "public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations": { + "/public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations": { "parameters": [ { "$ref": "#/parameters/public_inbox_identifier" @@ -805,7 +814,7 @@ "summary": "Create a conversation", "description": "Create a conversation", "security": [ - "nil" + ], "responses": { "200": { @@ -843,7 +852,7 @@ } } }, - "public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages": { + "/public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages": { "parameters": [ { "$ref": "#/parameters/public_inbox_identifier" @@ -863,7 +872,7 @@ "summary": "Create a message", "description": "Create a message", "security": [ - "nil" + ], "parameters": [ { @@ -911,7 +920,7 @@ } } }, - "public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages/{message_id}": { + "/public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages/{message_id}": { "parameters": [ { "$ref": "#/parameters/public_inbox_identifier" @@ -934,7 +943,7 @@ "summary": "Update a message", "description": "Update a message", "security": [ - "nil" + ], "parameters": [ { @@ -978,11 +987,9 @@ "schema": { "type": "array", "description": "Array of agent bots", - "items": [ - { - "$ref": "#/definitions/agent_bot" - } - ] + "items": { + "$ref": "#/definitions/agent_bot" + } } }, "401": { @@ -1104,6 +1111,11 @@ } }, "/api/v1/accounts/{account_id}/agents": { + "parameters": [ + { + "$ref": "#/parameters/account_id" + } + ], "get": { "tags": [ "Agent" @@ -1155,16 +1167,19 @@ "required": true, "schema": { "type": "object", + "required": [ + "name", + "email", + "role" + ], "properties": { "name": { "type": "string", - "description": "Full Name of the agent", - "required": true + "description": "Full Name of the agent" }, "email": { "type": "string", - "description": "Email of the Agent", - "required": true + "description": "Email of the Agent" }, "role": { "type": "string", @@ -1172,8 +1187,7 @@ "agent", "administrator" ], - "description": "Whether its administrator or agent", - "required": true + "description": "Whether its administrator or agent" }, "availability_status": { "type": "string", @@ -1206,6 +1220,11 @@ } }, "/api/v1/accounts/{account_id}/agents/{id}": { + "parameters": [ + { + "$ref": "#/parameters/account_id" + } + ], "patch": { "tags": [ "Agent" @@ -1224,9 +1243,7 @@ { "in": "path", "name": "id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The ID of the agent to be updated." }, @@ -1236,6 +1253,9 @@ "required": true, "schema": { "type": "object", + "required": [ + "role" + ], "properties": { "role": { "type": "string", @@ -1243,8 +1263,7 @@ "agent", "administrator" ], - "description": "Whether its administrator or agent", - "required": true + "description": "Whether its administrator or agent" }, "availability": { "type": "string", @@ -1296,9 +1315,7 @@ { "in": "path", "name": "id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The ID of the agent to be deleted" } @@ -1387,6 +1404,18 @@ } }, "/api/v1/accounts/{account_id}/contacts/{id}": { + "parameters": [ + { + "$ref": "#/parameters/account_id" + }, + { + "name": "id", + "in": "path", + "type": "number", + "description": "ID of the contact", + "required": true + } + ], "get": { "tags": [ "Contact" @@ -1394,18 +1423,6 @@ "operationId": "contactDetails", "summary": "Show Contact", "description": "Get a contact belonging to the account using ID", - "parameters": [ - { - "$ref": "#/parameters/account_id" - }, - { - "name": "id", - "in": "path", - "type": "number", - "description": "ID of the contact", - "required": true - } - ], "responses": { "200": { "description": "Success", @@ -1429,16 +1446,6 @@ "summary": "Update Contact", "description": "Update a contact belonging to the account using ID", "parameters": [ - { - "$ref": "#/parameters/account_id" - }, - { - "name": "id", - "in": "path", - "type": "number", - "description": "ID of the contact", - "required": true - }, { "name": "data", "in": "body", @@ -1469,15 +1476,6 @@ ], "operationId": "contactDelete", "summary": "Delete Contact", - "parameters": [ - { - "name": "id", - "in": "path", - "type": "number", - "description": "ID of the contact", - "required": true - } - ], "responses": { "200": { "description": "Success" @@ -1598,14 +1596,17 @@ "required": true, "schema": { "type": "object", + "required": [ + "inbox_id" + ], "properties": { "inbox_id": { "type": "number", - "description": "The ID of the inbox", - "required": true + "description": "The ID of the inbox" }, "source_id": { - "$ref": "#/parameters/source_id" + "type": "string", + "description": "Contact Inbox Source Id" } } } @@ -1670,19 +1671,19 @@ } }, "/api/v1/accounts/{account_id}/conversations": { + "parameters": [ + { + "$ref": "#/parameters/account_id" + } + ], "get": { "tags": [ "Conversation" ], - "operationId": "conversationSearch", - "description": "Search for conversations containing a messages with the query string", - "summary": "Conversations Search", + "operationId": "conversationList", + "description": "List all the conversations with pagination", + "summary": "Conversations List", "parameters": [ - { - "name": "q", - "in": "query", - "type": "string" - }, { "name": "assignee_type", "in": "query", @@ -1692,7 +1693,8 @@ "unassigned", "all", "assigned" - ] + ], + "required": true }, { "name": "status", @@ -1701,14 +1703,15 @@ "enum": [ "open", "resolved", - "pending", - "all" - ] + "pending" + ], + "required": true }, { "name": "page", "in": "query", - "type": "integer" + "type": "integer", + "required": true }, { "name": "inbox_id", @@ -1722,9 +1725,6 @@ "items": { "type": "string" } - }, - { - "$ref": "#/parameters/account_id" } ], "responses": { @@ -1739,8 +1739,7 @@ "schema": { "$ref": "#/definitions/bad_request_error" } - }, - "description": "Access denied" + } } }, "post": { @@ -1763,9 +1762,6 @@ } ], "parameters": [ - { - "$ref": "#/parameters/account_id" - }, { "name": "data", "in": "body", @@ -1774,7 +1770,8 @@ "type": "object", "properties": { "source_id": { - "$ref": "#/parameters/source_id" + "type": "string", + "description": "Conversation source id" }, "inbox_id": { "type": "string", @@ -1836,79 +1833,12 @@ } } }, - "/api/v1/accounts/{account_id}/conversations/": { - "get": { - "tags": [ - "Conversation" - ], - "operationId": "conversationList", - "description": "List all the conversations with pagination", - "summary": "Conversations List", - "parameters": [ - { - "$ref": "#/parameters/account_id" - }, - { - "name": "assignee_type", - "in": "query", - "type": "string", - "enum": [ - "me", - "unassigned", - "all", - "assigned" - ], - "required": true - }, - { - "name": "status", - "in": "query", - "type": "string", - "enum": [ - "open", - "resolved", - "pending" - ], - "required": true - }, - { - "name": "page", - "in": "query", - "type": "integer", - "required": true - }, - { - "name": "inbox_id", - "in": "query", - "type": "integer" - }, - { - "name": "labels", - "in": "query", - "type": "array", - "items": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/conversation_list" - } - }, - "400": { - "description": "Bad Request Error", - "schema": { - "$ref": "#/definitions/bad_request_error" - } - }, - "description": "Access denied" - } - } - }, "/api/v1/accounts/{account_id}/conversations/filter": { + "parameters": [ + { + "$ref": "#/parameters/account_id" + } + ], "post": { "tags": [ "Conversation" @@ -1953,6 +1883,9 @@ }, "values": { "type": "array", + "items": { + "type": "string" + }, "description": "array of the attribute values to filter" }, "query_operator": { @@ -1962,9 +1895,6 @@ } } } - }, - { - "$ref": "#/parameters/account_id" } ], "responses": { @@ -1979,12 +1909,11 @@ "schema": { "$ref": "#/definitions/bad_request_error" } - }, - "description": "Access denied" + } } } }, - "/api/v1/accounts/{account_id}/conversations/{converstion_id}": { + "/api/v1/accounts/{account_id}/conversations/{conversation_id}": { "parameters": [ { "$ref": "#/parameters/account_id" @@ -2051,6 +1980,9 @@ "required": true, "schema": { "type": "object", + "required": [ + "status" + ], "properties": { "status": { "type": "string", @@ -2059,7 +1991,6 @@ "resolved", "pending" ], - "required": true, "description": "The status of the conversation" } } @@ -2183,7 +2114,7 @@ "labels": { "type": "array", "description": "Array of labels (comma-separated strings)", - "properties": { + "items": { "type": "string" } } @@ -2300,7 +2231,8 @@ "description": "The name of the inbox" }, "avatar": { - "type": "file", + "type": "string", + "format": "binary", "description": "File for avatar image" }, "channel": { @@ -2379,6 +2311,9 @@ "required": true, "schema": { "type": "object", + "required": [ + "enable_auto_assignment" + ], "properties": { "name": { "type": "string", @@ -2386,12 +2321,11 @@ }, "enable_auto_assignment": { "type": "boolean", - "required": true, "description": "Enable Auto Assignment" }, "avatar": { - "type": "file", - "required": false, + "type": "string", + "format": "binary", "description": "Image file for avatar" }, "channel": { @@ -2500,10 +2434,12 @@ "required": true, "schema": { "type": "object", + "required": [ + "agent_bot" + ], "properties": { "agent_bot": { "type": "number", - "required": true, "description": "Agent bot ID" } } @@ -2523,7 +2459,15 @@ } } }, - "/api/v1/accounts/{account_id}/inbox_members": { + "/api/v1/accounts/{account_id}/inbox_members/{inbox_id}": { + "parameters": [ + { + "$ref": "#/parameters/account_id" + }, + { + "$ref": "#/parameters/inbox_id" + } + ], "get": { "tags": [ "Inbox" @@ -2583,16 +2527,21 @@ "required": true, "schema": { "type": "object", + "required": [ + "inbox_id", + "user_ids" + ], "properties": { "inbox_id": { "type": "string", - "description": "The ID of the inbox", - "required": true + "description": "The ID of the inbox" }, "user_ids": { "type": "array", - "description": "IDs of users to be added to the inbox", - "required": true + "items": { + "type": "integer" + }, + "description": "IDs of users to be added to the inbox" } } } @@ -2626,7 +2575,7 @@ ], "operationId": "update-agents-in-inbox", "summary": "Update Agents in Inbox", - "description": "All agents execept the one passed in params will be removed", + "description": "All agents except the one passed in params will be removed", "security": [ { "userApiKey": [ @@ -2641,16 +2590,21 @@ "required": true, "schema": { "type": "object", + "required": [ + "inbox_id", + "user_ids" + ], "properties": { "inbox_id": { "type": "string", - "description": "The ID of the inbox", - "required": true + "description": "The ID of the inbox" }, "user_ids": { "type": "array", - "description": "IDs of users to be added to the inbox", - "required": true + "items": { + "type": "integer" + }, + "description": "IDs of users to be added to the inbox" } } } @@ -2699,16 +2653,21 @@ "required": true, "schema": { "type": "object", + "required": [ + "inbox_id", + "user_ids" + ], "properties": { "inbox_id": { "type": "string", - "description": "The ID of the inbox", - "required": true + "description": "The ID of the inbox" }, "user_ids": { "type": "array", - "description": "IDs of users to be deleted from the inbox", - "required": true + "items": { + "type": "integer" + }, + "description": "IDs of users to be deleted from the inbox" } } } @@ -2730,92 +2689,7 @@ } } }, - "/api/v1/accounts/{account_id}/conversations/{id}/messages": { - "post": { - "tags": [ - "Messages" - ], - "operationId": "conversationNewMessageAttachment", - "summary": "Create New Message Attachment", - "description": "Create an attachment message. Refer to this discussion if you have any further doubts. https://github.com/chatwoot/chatwoot/discussions/1809#discussioncomment-1211845", - "consumes": [ - "multipart/form-data" - ], - "security": [ - { - "userApiKey": [ - - ] - }, - { - "agentBotApiKey": [ - - ] - } - ], - "parameters": [ - { - "$ref": "#/parameters/account_id" - }, - { - "$ref": "#/parameters/conversation_id" - }, - { - "in": "formData", - "name": "content", - "type": "string", - "description": "The content of the message", - "required": true - }, - { - "in": "formData", - "name": "message_type", - "type": "string", - "enum": [ - "outgoing", - "incoming" - ] - }, - { - "in": "formData", - "name": "private", - "type": "boolean", - "description": "Flag to identify if it is a private note" - }, - { - "in": "formData", - "name": "attachments[]", - "type": "array", - "description": "The files to be uploaded.", - "items": { - "type": "file" - } - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/generic_id" - }, - { - "$ref": "#/definitions/message" - } - ] - } - }, - "404": { - "description": "Conversation not found" - }, - "403": { - "description": "Access denied" - } - } - } - }, - "/api/v1/accounts/{account_id}/conversations/{converstion_id}/messages": { + "/api/v1/accounts/{account_id}/conversations/{conversation_id}/messages": { "parameters": [ { "$ref": "#/parameters/account_id" @@ -2833,17 +2707,20 @@ "description": "List all messages of a conversation", "responses": { "200": { - "description": "Array of messages", - "type": "array", + "description": "Success", "schema": { - "allOf": [ - { - "$ref": "#/definitions/generic_id" - }, - { - "$ref": "#/definitions/message" - } - ] + "type": "array", + "description": "Array of messages", + "items": { + "allOf": [ + { + "$ref": "#/definitions/generic_id" + }, + { + "$ref": "#/definitions/message" + } + ] + } } }, "404": { @@ -3003,7 +2880,9 @@ "description": "Unauthorized" } } - }, + } + }, + "/api/v1/accounts/{account_id}/integrations/hooks/{hook_id}": { "patch": { "tags": [ "Integrations" @@ -3238,14 +3117,12 @@ { "in": "query", "name": "filter_type", - "schema": { - "type": "string", - "enum": [ - "conversation", - "contact", - "report" - ] - }, + "type": "string", + "enum": [ + "conversation", + "contact", + "report" + ], "required": false, "description": "The type of custom filter" } @@ -3386,7 +3263,7 @@ } } }, - "/api/v2/accounts/{id}/reports": { + "/api/v2/accounts/{account_id}/reports": { "parameters": [ { "$ref": "#/parameters/account_id" @@ -3400,25 +3277,19 @@ { "in": "query", "name": "id", - "schema": { - "type": "string" - }, + "type": "string", "description": "The Id of specific object in case of agent/inbox/label" }, { "in": "query", "name": "since", - "schema": { - "type": "string" - }, + "type": "string", "description": "The timestamp from where report should start." }, { "in": "query", "name": "until", - "schema": { - "type": "string" - }, + "type": "string", "description": "The timestamp from where report should stop." } ], @@ -3449,7 +3320,7 @@ } } }, - "/api/v2/accounts/{id}/reports/summary": { + "/api/v2/accounts/{account_id}/reports/summary": { "parameters": [ { "$ref": "#/parameters/account_id" @@ -3460,25 +3331,19 @@ { "in": "query", "name": "id", - "schema": { - "type": "string" - }, + "type": "string", "description": "The Id of specific object in case of agent/inbox/label" }, { "in": "query", "name": "since", - "schema": { - "type": "string" - }, + "type": "string", "description": "The timestamp from where report should start." }, { "in": "query", "name": "until", - "schema": { - "type": "string" - }, + "type": "string", "description": "The timestamp from where report should stop." } ], @@ -3587,7 +3452,10 @@ "description": "ID of the conversation" }, "messages": { - "type": "array" + "type": "array", + "items": { + "$ref": "#/definitions/message" + } }, "account_id": { "type": "number", @@ -3614,7 +3482,7 @@ "type": "string" }, "agent_last_seen_at": { - "type": "agent_last_seen_at" + "type": "string" }, "unread_count": { "type": "number", @@ -3909,11 +3777,13 @@ "description": "A query that needs to be saved as a custom filter" }, "created_at": { - "type": "datetime", + "type": "string", + "format": "date-time", "description": "The time at which the custom filter was created" }, "updated_at": { - "type": "datetime", + "type": "string", + "format": "date-time", "description": "The time at which the custom filter was updated" } } @@ -4010,6 +3880,9 @@ }, "hooks": { "type": "array", + "items": { + "type": "object" + }, "description": "If there are any hooks created for this integration" } } @@ -4085,6 +3958,9 @@ }, "messages": { "type": "array", + "items": { + "$ref": "#/definitions/message" + }, "description": "Messages in the conversation" }, "contact": { @@ -4126,6 +4002,9 @@ }, "attachments": { "type": "array", + "items": { + "type": "object" + }, "description": "Attachments if any" }, "sender": { @@ -4183,10 +4062,12 @@ }, "contact_create": { "type": "object", + "required": [ + "inbox_id" + ], "properties": { "inbox_id": { - "type": "number", - "required": true + "type": "number" }, "name": { "type": "string", @@ -4237,11 +4118,13 @@ }, "conversation_message_create": { "type": "object", + "required": [ + "content" + ], "properties": { "content": { "type": "string", - "description": "The content of the message", - "required": true + "description": "The content of the message" }, "message_type": { "type": "string", @@ -4689,165 +4572,138 @@ "account_id": { "in": "path", "name": "account_id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The numeric ID of the account" }, "agent_bot_id": { "in": "path", "name": "id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The ID of the agentbot to be updated" }, "team_id": { "in": "path", "name": "id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The ID of the team to be updated" }, "inbox_id": { "in": "path", "name": "inbox_id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The ID of the Inbox" }, "hook_id": { "in": "path", "name": "hook_id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The numeric ID of the integration hook" }, "source_id": { + "in": "path", + "name": "source_id", + "required": true, "type": "string", "description": "Id of the session for which the conversation is created.\n\n\n\n Source Ids can be obtained through contactable inboxes API or via generated.

Website: Chatwoot generated string which can be obtained from webhook events.
Phone Channels(Twilio): Phone number in e164 format
Email Channels: Contact Email address
API Channel: Any Random String" }, "conversation_id": { "in": "path", "name": "conversation_id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The numeric ID of the conversation" }, "message_id": { "in": "path", "name": "message_id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The numeric ID of the message" }, "contact_sort_param": { "in": "query", "name": "sort", - "schema": { - "type": "string", - "enum": [ - "name", - "email", - "phone_number", - "last_activity_at", - "-name", - "-email", - "-phone_number", - "-last_activity_at" - ] - }, + "type": "string", + "enum": [ + "name", + "email", + "phone_number", + "last_activity_at", + "-name", + "-email", + "-phone_number", + "-last_activity_at" + ], "required": false, "description": "The attribute by which list should be sorted" }, "page": { "in": "query", "name": "page", - "schema": { - "type": "integer", - "default": 1 - }, + "type": "integer", + "default": 1, "required": false, "description": "The page parameter" }, "platform_user_id": { "in": "path", "name": "id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The numeric ID of the user on the platform" }, "custom_filter_id": { "in": "path", "name": "custom_filter_id", - "schema": { - "type": "integer" - }, + "type": "integer", "required": true, "description": "The numeric ID of the custom filter" }, "report_type": { "in": "query", "name": "report_type", - "schema": { - "type": "string", - "enum": [ - "account", - "agent", - "inbox", - "label", - "team" - ] - }, + "type": "string", + "enum": [ + "account", + "agent", + "inbox", + "label", + "team" + ], "required": true, "description": "Type of report" }, "report_metric": { "in": "query", "name": "metric", - "schema": { - "type": "string", - "enum": [ - "conversations_count", - "incoming_messages_count", - "outgoing_messages_count", - "avg_first_response_time", - "avg_resolution_time", - "resolutions_count" - ] - }, + "type": "string", + "enum": [ + "conversations_count", + "incoming_messages_count", + "outgoing_messages_count", + "avg_first_response_time", + "avg_resolution_time", + "resolutions_count" + ], "required": true, "description": "The type of metric" }, "public_inbox_identifier": { "in": "path", "name": "inbox_identifier", - "schema": { - "type": "string" - }, + "type": "string", "required": true, "description": "The identifier obtained from API inbox channel" }, "public_contact_identifier": { "in": "path", "name": "contact_identifier", - "schema": { - "type": "string" - }, + "type": "string", "required": true, "description": "The source id of contact obtained on contact create" } From 4eeaadbd5bcd68c904e95f125194c905f12989d0 Mon Sep 17 00:00:00 2001 From: Vinayak <58037628+vinayak-gaikwad@users.noreply.github.com> Date: Wed, 17 Nov 2021 22:11:27 +0530 Subject: [PATCH 05/69] chore: Added SMTP_TLS and SMTP_SSL in .env.example Added SMTP_TLS and SMTP_SSL in .env.example Fixes #3396 --- .env.example | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.env.example b/.env.example index ef74a7c0f..36ca66be1 100644 --- a/.env.example +++ b/.env.example @@ -57,6 +57,9 @@ SMTP_AUTHENTICATION= SMTP_ENABLE_STARTTLS_AUTO=true # Can be: 'none', 'peer', 'client_once', 'fail_if_no_peer_cert', see http://api.rubyonrails.org/classes/ActionMailer/Base.html SMTP_OPENSSL_VERIFY_MODE=peer +# Comment out the following environment variables if required by your SMTP server +# SMTP_TLS= +# SMTP_SSL= # Mail Incoming # This is the domain set for the reply emails when conversation continuity is enabled From b81a9f201048cd470c9fe0fb7fb845238985c1da Mon Sep 17 00:00:00 2001 From: Akhil G Krishnan Date: Thu, 18 Nov 2021 10:32:29 +0530 Subject: [PATCH 06/69] Chore: Replaced dependent destroy with dependent destroy_async in all models (#3249) --- app/models/account.rb | 66 +++++++++++------------ app/models/agent_bot.rb | 4 +- app/models/concerns/access_tokenable.rb | 2 +- app/models/concerns/channelable.rb | 2 +- app/models/concerns/out_of_offisable.rb | 2 +- app/models/concerns/reportable.rb | 2 +- app/models/contact.rb | 10 ++-- app/models/contact_inbox.rb | 2 +- app/models/conversation.rb | 4 +- app/models/inbox.rb | 14 ++--- app/models/kbase/category.rb | 2 +- app/models/kbase/portal.rb | 4 +- app/models/message.rb | 4 +- app/models/platform_app.rb | 2 +- app/models/platform_app_permissible.rb | 2 +- app/models/team.rb | 2 +- app/models/telegram_bot.rb | 2 +- app/models/user.rb | 14 ++--- spec/models/account_spec.rb | 24 ++++----- spec/models/channel/facebook_page_spec.rb | 2 +- spec/models/contact_spec.rb | 2 +- spec/models/inbox_spec.rb | 8 +-- spec/models/user_spec.rb | 4 +- 23 files changed, 90 insertions(+), 90 deletions(-) diff --git a/app/models/account.rb b/app/models/account.rb index 8ce2a4beb..d16194e40 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -32,40 +32,40 @@ class Account < ApplicationRecord validates :name, presence: true validates :auto_resolve_duration, numericality: { greater_than_or_equal_to: 1, allow_nil: true } - has_many :account_users, dependent: :destroy - has_many :agent_bot_inboxes, dependent: :destroy - has_many :agent_bots, dependent: :destroy - has_many :csat_survey_responses, dependent: :destroy - has_many :data_imports, dependent: :destroy + has_many :account_users, dependent: :destroy_async + has_many :agent_bot_inboxes, dependent: :destroy_async + has_many :agent_bots, dependent: :destroy_async + has_many :csat_survey_responses, dependent: :destroy_async + has_many :data_imports, dependent: :destroy_async has_many :users, through: :account_users - has_many :inboxes, dependent: :destroy - has_many :notes, dependent: :destroy - has_many :campaigns, dependent: :destroy - has_many :conversations, dependent: :destroy - has_many :messages, dependent: :destroy - has_many :contacts, dependent: :destroy - has_many :facebook_pages, dependent: :destroy, class_name: '::Channel::FacebookPage' - has_many :telegram_bots, dependent: :destroy - has_many :twilio_sms, dependent: :destroy, class_name: '::Channel::TwilioSms' - has_many :twitter_profiles, dependent: :destroy, class_name: '::Channel::TwitterProfile' - has_many :web_widgets, dependent: :destroy, class_name: '::Channel::WebWidget' - has_many :email_channels, dependent: :destroy, class_name: '::Channel::Email' - has_many :api_channels, dependent: :destroy, class_name: '::Channel::Api' - has_many :line_channels, dependent: :destroy, class_name: '::Channel::Line' - has_many :telegram_channels, dependent: :destroy, class_name: '::Channel::Telegram' - has_many :whatsapp_channels, dependent: :destroy, class_name: '::Channel::Whatsapp' - has_many :canned_responses, dependent: :destroy - has_many :webhooks, dependent: :destroy - has_many :labels, dependent: :destroy - has_many :notification_settings, dependent: :destroy - has_many :hooks, dependent: :destroy, class_name: 'Integrations::Hook' - has_many :working_hours, dependent: :destroy - has_many :kbase_portals, dependent: :destroy, class_name: '::Kbase::Portal' - has_many :kbase_categories, dependent: :destroy, class_name: '::Kbase::Category' - has_many :kbase_articles, dependent: :destroy, class_name: '::Kbase::Article' - has_many :teams, dependent: :destroy - has_many :custom_filters, dependent: :destroy - has_many :custom_attribute_definitions, dependent: :destroy + has_many :inboxes, dependent: :destroy_async + has_many :notes, dependent: :destroy_async + has_many :campaigns, dependent: :destroy_async + has_many :conversations, dependent: :destroy_async + has_many :messages, dependent: :destroy_async + has_many :contacts, dependent: :destroy_async + has_many :facebook_pages, dependent: :destroy_async, class_name: '::Channel::FacebookPage' + has_many :telegram_bots, dependent: :destroy_async + has_many :twilio_sms, dependent: :destroy_async, class_name: '::Channel::TwilioSms' + has_many :twitter_profiles, dependent: :destroy_async, class_name: '::Channel::TwitterProfile' + has_many :web_widgets, dependent: :destroy_async, class_name: '::Channel::WebWidget' + has_many :email_channels, dependent: :destroy_async, class_name: '::Channel::Email' + has_many :api_channels, dependent: :destroy_async, class_name: '::Channel::Api' + has_many :line_channels, dependent: :destroy_async, class_name: '::Channel::Line' + has_many :telegram_channels, dependent: :destroy_async, class_name: '::Channel::Telegram' + has_many :whatsapp_channels, dependent: :destroy_async, class_name: '::Channel::Whatsapp' + has_many :canned_responses, dependent: :destroy_async + has_many :webhooks, dependent: :destroy_async + has_many :labels, dependent: :destroy_async + has_many :notification_settings, dependent: :destroy_async + has_many :hooks, dependent: :destroy_async, class_name: 'Integrations::Hook' + has_many :working_hours, dependent: :destroy_async + has_many :kbase_portals, dependent: :destroy_async, class_name: '::Kbase::Portal' + has_many :kbase_categories, dependent: :destroy_async, class_name: '::Kbase::Category' + has_many :kbase_articles, dependent: :destroy_async, class_name: '::Kbase::Article' + has_many :teams, dependent: :destroy_async + has_many :custom_filters, dependent: :destroy_async + has_many :custom_attribute_definitions, dependent: :destroy_async has_flags ACCOUNT_SETTINGS_FLAGS.merge(column: 'settings_flags').merge(DEFAULT_QUERY_SETTING) diff --git a/app/models/agent_bot.rb b/app/models/agent_bot.rb index 75f051f8e..beff22a22 100644 --- a/app/models/agent_bot.rb +++ b/app/models/agent_bot.rb @@ -23,10 +23,10 @@ class AgentBot < ApplicationRecord include AccessTokenable include Avatarable - has_many :agent_bot_inboxes, dependent: :destroy + has_many :agent_bot_inboxes, dependent: :destroy_async has_many :inboxes, through: :agent_bot_inboxes has_many :messages, as: :sender, dependent: :restrict_with_exception - belongs_to :account, dependent: :destroy, optional: true + belongs_to :account, dependent: :destroy_async, optional: true def available_name name diff --git a/app/models/concerns/access_tokenable.rb b/app/models/concerns/access_tokenable.rb index ae9aad2e5..0bb8daa4f 100644 --- a/app/models/concerns/access_tokenable.rb +++ b/app/models/concerns/access_tokenable.rb @@ -1,7 +1,7 @@ module AccessTokenable extend ActiveSupport::Concern included do - has_one :access_token, as: :owner, dependent: :destroy + has_one :access_token, as: :owner, dependent: :destroy_async after_create :create_access_token end diff --git a/app/models/concerns/channelable.rb b/app/models/concerns/channelable.rb index 76b18fc81..e60066d5f 100644 --- a/app/models/concerns/channelable.rb +++ b/app/models/concerns/channelable.rb @@ -3,7 +3,7 @@ module Channelable included do validates :account_id, presence: true belongs_to :account - has_one :inbox, as: :channel, dependent: :destroy + has_one :inbox, as: :channel, dependent: :destroy_async end def has_24_hour_messaging_window? diff --git a/app/models/concerns/out_of_offisable.rb b/app/models/concerns/out_of_offisable.rb index 53b466cdf..e22dd668c 100644 --- a/app/models/concerns/out_of_offisable.rb +++ b/app/models/concerns/out_of_offisable.rb @@ -6,7 +6,7 @@ module OutOfOffisable OFFISABLE_ATTRS = %w[day_of_week closed_all_day open_hour open_minutes close_hour close_minutes].freeze included do - has_many :working_hours, dependent: :destroy + has_many :working_hours, dependent: :destroy_async after_create :create_default_working_hours end diff --git a/app/models/concerns/reportable.rb b/app/models/concerns/reportable.rb index 3f230650f..9da1e93dc 100644 --- a/app/models/concerns/reportable.rb +++ b/app/models/concerns/reportable.rb @@ -4,6 +4,6 @@ module Reportable extend ActiveSupport::Concern included do - has_many :events, dependent: :destroy + has_many :events, dependent: :destroy_async end end diff --git a/app/models/contact.rb b/app/models/contact.rb index ec0b27d70..9ba3a4178 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -38,12 +38,12 @@ class Contact < ApplicationRecord format: { with: /\+[1-9]\d{1,14}\z/, message: 'should be in e164 format' } belongs_to :account - has_many :conversations, dependent: :destroy - has_many :contact_inboxes, dependent: :destroy - has_many :csat_survey_responses, dependent: :destroy + has_many :conversations, dependent: :destroy_async + has_many :contact_inboxes, dependent: :destroy_async + has_many :csat_survey_responses, dependent: :destroy_async has_many :inboxes, through: :contact_inboxes - has_many :messages, as: :sender, dependent: :destroy - has_many :notes, dependent: :destroy + has_many :messages, as: :sender, dependent: :destroy_async + has_many :notes, dependent: :destroy_async before_validation :prepare_email_attribute after_create_commit :dispatch_create_event, :ip_lookup diff --git a/app/models/contact_inbox.rb b/app/models/contact_inbox.rb index 6f36b8735..e87d30382 100644 --- a/app/models/contact_inbox.rb +++ b/app/models/contact_inbox.rb @@ -32,7 +32,7 @@ class ContactInbox < ApplicationRecord belongs_to :contact belongs_to :inbox - has_many :conversations, dependent: :destroy + has_many :conversations, dependent: :destroy_async def webhook_data { diff --git a/app/models/conversation.rb b/app/models/conversation.rb index a7a5b5b6d..c5cd30629 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -66,8 +66,8 @@ class Conversation < ApplicationRecord belongs_to :team, optional: true belongs_to :campaign, optional: true - has_many :messages, dependent: :destroy, autosave: true - has_one :csat_survey_response, dependent: :destroy + has_many :messages, dependent: :destroy_async, autosave: true + has_one :csat_survey_response, dependent: :destroy_async has_many :notifications, as: :primary_actor, dependent: :destroy before_save :ensure_snooze_until_reset diff --git a/app/models/inbox.rb b/app/models/inbox.rb index dbd64f820..ba85c9e64 100644 --- a/app/models/inbox.rb +++ b/app/models/inbox.rb @@ -39,19 +39,19 @@ class Inbox < ApplicationRecord belongs_to :channel, polymorphic: true, dependent: :destroy - has_many :campaigns, dependent: :destroy - has_many :contact_inboxes, dependent: :destroy + has_many :campaigns, dependent: :destroy_async + has_many :contact_inboxes, dependent: :destroy_async has_many :contacts, through: :contact_inboxes - has_many :inbox_members, dependent: :destroy + has_many :inbox_members, dependent: :destroy_async has_many :members, through: :inbox_members, source: :user - has_many :conversations, dependent: :destroy + has_many :conversations, dependent: :destroy_async has_many :messages, through: :conversations - has_one :agent_bot_inbox, dependent: :destroy + has_one :agent_bot_inbox, dependent: :destroy_async has_one :agent_bot, through: :agent_bot_inbox - has_many :webhooks, dependent: :destroy - has_many :hooks, dependent: :destroy, class_name: 'Integrations::Hook' + has_many :webhooks, dependent: :destroy_async + has_many :hooks, dependent: :destroy_async, class_name: 'Integrations::Hook' after_destroy :delete_round_robin_agents diff --git a/app/models/kbase/category.rb b/app/models/kbase/category.rb index a32331598..024efae8e 100644 --- a/app/models/kbase/category.rb +++ b/app/models/kbase/category.rb @@ -14,7 +14,7 @@ class Kbase::Category < ApplicationRecord belongs_to :account belongs_to :portal - has_many :folders, dependent: :destroy + has_many :folders, dependent: :destroy_async has_many :articles, dependent: :nullify before_validation :ensure_account_id diff --git a/app/models/kbase/portal.rb b/app/models/kbase/portal.rb index 5401361c4..03f8e29bf 100644 --- a/app/models/kbase/portal.rb +++ b/app/models/kbase/portal.rb @@ -20,9 +20,9 @@ # class Kbase::Portal < ApplicationRecord belongs_to :account - has_many :categories, dependent: :destroy + has_many :categories, dependent: :destroy_async has_many :folders, through: :categories - has_many :articles, dependent: :destroy + has_many :articles, dependent: :destroy_async validates :account_id, presence: true validates :name, presence: true diff --git a/app/models/message.rb b/app/models/message.rb index 920f338be..bd9c3c422 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -82,8 +82,8 @@ class Message < ApplicationRecord belongs_to :contact, required: false belongs_to :sender, polymorphic: true, required: false - has_many :attachments, dependent: :destroy, autosave: true, before_add: :validate_attachments_limit - has_one :csat_survey_response, dependent: :destroy + has_many :attachments, dependent: :destroy_async, autosave: true, before_add: :validate_attachments_limit + has_one :csat_survey_response, dependent: :destroy_async after_create_commit :execute_after_create_commit_callbacks diff --git a/app/models/platform_app.rb b/app/models/platform_app.rb index 2f7ec8e42..d8b2eb054 100644 --- a/app/models/platform_app.rb +++ b/app/models/platform_app.rb @@ -12,5 +12,5 @@ class PlatformApp < ApplicationRecord validates :name, presence: true - has_many :platform_app_permissibles, dependent: :destroy + has_many :platform_app_permissibles, dependent: :destroy_async end diff --git a/app/models/platform_app_permissible.rb b/app/models/platform_app_permissible.rb index c8efc59b4..14b804e84 100644 --- a/app/models/platform_app_permissible.rb +++ b/app/models/platform_app_permissible.rb @@ -22,5 +22,5 @@ class PlatformAppPermissible < ApplicationRecord validates :platform_app_id, uniqueness: { scope: [:permissible_id, :permissible_type] } belongs_to :platform_app - belongs_to :permissible, polymorphic: true, dependent: :destroy + belongs_to :permissible, polymorphic: true, dependent: :destroy_async end diff --git a/app/models/team.rb b/app/models/team.rb index 1b998eb4c..dd4713662 100644 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -21,7 +21,7 @@ # class Team < ApplicationRecord belongs_to :account - has_many :team_members, dependent: :destroy + has_many :team_members, dependent: :destroy_async has_many :members, through: :team_members, source: :user has_many :conversations, dependent: :nullify diff --git a/app/models/telegram_bot.rb b/app/models/telegram_bot.rb index 2d8706753..8468e233f 100644 --- a/app/models/telegram_bot.rb +++ b/app/models/telegram_bot.rb @@ -12,6 +12,6 @@ class TelegramBot < ApplicationRecord belongs_to :account - has_one :inbox, as: :channel, dependent: :destroy + has_one :inbox, as: :channel, dependent: :destroy_async validates_uniqueness_of :auth_key, scope: :account_id end diff --git a/app/models/user.rb b/app/models/user.rb index 6f5e67bee..c73aad20c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -67,7 +67,7 @@ class User < ApplicationRecord validates :email, :name, presence: true validates_length_of :name, minimum: 1 - has_many :account_users, dependent: :destroy + has_many :account_users, dependent: :destroy_async has_many :accounts, through: :account_users accepts_nested_attributes_for :account_users @@ -75,18 +75,18 @@ class User < ApplicationRecord alias_attribute :conversations, :assigned_conversations has_many :csat_survey_responses, foreign_key: 'assigned_agent_id', dependent: :nullify - has_many :inbox_members, dependent: :destroy + has_many :inbox_members, dependent: :destroy_async has_many :inboxes, through: :inbox_members, source: :inbox has_many :messages, as: :sender has_many :invitees, through: :account_users, class_name: 'User', foreign_key: 'inviter_id', source: :inviter, dependent: :nullify - has_many :notifications, dependent: :destroy - has_many :notification_settings, dependent: :destroy - has_many :notification_subscriptions, dependent: :destroy - has_many :team_members, dependent: :destroy + has_many :notifications, dependent: :destroy_async + has_many :notification_settings, dependent: :destroy_async + has_many :notification_subscriptions, dependent: :destroy_async + has_many :team_members, dependent: :destroy_async has_many :teams, through: :team_members has_many :notes, dependent: :nullify - has_many :custom_filters, dependent: :destroy + has_many :custom_filters, dependent: :destroy_async before_validation :set_password_and_uid, on: :create diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index cef952cf8..20ebf4bfd 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -8,17 +8,17 @@ RSpec.describe Account do it { is_expected.to have_many(:users).through(:account_users) } it { is_expected.to have_many(:account_users) } - it { is_expected.to have_many(:inboxes).dependent(:destroy) } - it { is_expected.to have_many(:conversations).dependent(:destroy) } - it { is_expected.to have_many(:contacts).dependent(:destroy) } - it { is_expected.to have_many(:telegram_bots).dependent(:destroy) } - it { is_expected.to have_many(:canned_responses).dependent(:destroy) } - it { is_expected.to have_many(:facebook_pages).class_name('::Channel::FacebookPage').dependent(:destroy) } - it { is_expected.to have_many(:web_widgets).class_name('::Channel::WebWidget').dependent(:destroy) } - it { is_expected.to have_many(:webhooks).dependent(:destroy) } - it { is_expected.to have_many(:notification_settings).dependent(:destroy) } + it { is_expected.to have_many(:inboxes).dependent(:destroy_async) } + it { is_expected.to have_many(:conversations).dependent(:destroy_async) } + it { is_expected.to have_many(:contacts).dependent(:destroy_async) } + it { is_expected.to have_many(:telegram_bots).dependent(:destroy_async) } + it { is_expected.to have_many(:canned_responses).dependent(:destroy_async) } + it { is_expected.to have_many(:facebook_pages).class_name('::Channel::FacebookPage').dependent(:destroy_async) } + it { is_expected.to have_many(:web_widgets).class_name('::Channel::WebWidget').dependent(:destroy_async) } + it { is_expected.to have_many(:webhooks).dependent(:destroy_async) } + it { is_expected.to have_many(:notification_settings).dependent(:destroy_async) } it { is_expected.to have_many(:events) } - it { is_expected.to have_many(:kbase_portals).dependent(:destroy) } - it { is_expected.to have_many(:kbase_categories).dependent(:destroy) } - it { is_expected.to have_many(:teams).dependent(:destroy) } + it { is_expected.to have_many(:kbase_portals).dependent(:destroy_async) } + it { is_expected.to have_many(:kbase_categories).dependent(:destroy_async) } + it { is_expected.to have_many(:teams).dependent(:destroy_async) } end diff --git a/spec/models/channel/facebook_page_spec.rb b/spec/models/channel/facebook_page_spec.rb index 8d4b7abf6..02baac4a1 100644 --- a/spec/models/channel/facebook_page_spec.rb +++ b/spec/models/channel/facebook_page_spec.rb @@ -13,7 +13,7 @@ RSpec.describe Channel::FacebookPage do it { is_expected.to validate_presence_of(:account_id) } # it { is_expected.to validate_uniqueness_of(:page_id).scoped_to(:account_id) } it { is_expected.to belong_to(:account) } - it { is_expected.to have_one(:inbox).dependent(:destroy) } + it { is_expected.to have_one(:inbox).dependent(:destroy_async) } describe 'concerns' do it_behaves_like 'reauthorizable' diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index d296907cc..9833b392a 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -9,7 +9,7 @@ RSpec.describe Contact do context 'associations' do it { is_expected.to belong_to(:account) } - it { is_expected.to have_many(:conversations).dependent(:destroy) } + it { is_expected.to have_many(:conversations).dependent(:destroy_async) } end describe 'pubsub_token' do diff --git a/spec/models/inbox_spec.rb b/spec/models/inbox_spec.rb index 2150d7048..ba94540d8 100644 --- a/spec/models/inbox_spec.rb +++ b/spec/models/inbox_spec.rb @@ -13,21 +13,21 @@ RSpec.describe Inbox do it { is_expected.to belong_to(:channel) } - it { is_expected.to have_many(:contact_inboxes).dependent(:destroy) } + it { is_expected.to have_many(:contact_inboxes).dependent(:destroy_async) } it { is_expected.to have_many(:contacts).through(:contact_inboxes) } - it { is_expected.to have_many(:inbox_members).dependent(:destroy) } + it { is_expected.to have_many(:inbox_members).dependent(:destroy_async) } it { is_expected.to have_many(:members).through(:inbox_members).source(:user) } - it { is_expected.to have_many(:conversations).dependent(:destroy) } + it { is_expected.to have_many(:conversations).dependent(:destroy_async) } it { is_expected.to have_many(:messages).through(:conversations) } it { is_expected.to have_one(:agent_bot_inbox) } - it { is_expected.to have_many(:webhooks).dependent(:destroy) } + it { is_expected.to have_many(:webhooks).dependent(:destroy_async) } it { is_expected.to have_many(:events) } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 5c4ce6850..674525a6f 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -16,8 +16,8 @@ RSpec.describe User do it { is_expected.to have_many(:accounts).through(:account_users) } it { is_expected.to have_many(:account_users) } it { is_expected.to have_many(:assigned_conversations).class_name('Conversation').dependent(:nullify) } - it { is_expected.to have_many(:inbox_members).dependent(:destroy) } - it { is_expected.to have_many(:notification_settings).dependent(:destroy) } + it { is_expected.to have_many(:inbox_members).dependent(:destroy_async) } + it { is_expected.to have_many(:notification_settings).dependent(:destroy_async) } it { is_expected.to have_many(:messages) } it { is_expected.to have_many(:events) } it { is_expected.to have_many(:teams) } From c2b4991fd8eb1223952ffb5ff39d05eb91f0f10a Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Thu, 18 Nov 2021 14:09:55 +0530 Subject: [PATCH 07/69] feat: Add automation route (#3410) --- .../dashboard/i18n/locale/en/automation.json | 6 ++++ .../dashboard/i18n/locale/en/index.js | 2 ++ .../dashboard/i18n/locale/en/settings.json | 1 + .../dashboard/i18n/sidebarItems/settings.js | 8 +++++ .../dashboard/settings/automation/Index.vue | 12 ++++++++ .../settings/automation/automation.routes.js | 30 +++++++++++++++++++ 6 files changed, 59 insertions(+) create mode 100644 app/javascript/dashboard/i18n/locale/en/automation.json create mode 100644 app/javascript/dashboard/routes/dashboard/settings/automation/Index.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/automation/automation.routes.js diff --git a/app/javascript/dashboard/i18n/locale/en/automation.json b/app/javascript/dashboard/i18n/locale/en/automation.json new file mode 100644 index 000000000..c3614a990 --- /dev/null +++ b/app/javascript/dashboard/i18n/locale/en/automation.json @@ -0,0 +1,6 @@ +{ + "AUTOMATION": { + "HEADER": "Automation", + "HEADER_BTN_TXT": "Add Automation Rule" + } +} diff --git a/app/javascript/dashboard/i18n/locale/en/index.js b/app/javascript/dashboard/i18n/locale/en/index.js index bfcef683a..9e81e9e76 100644 --- a/app/javascript/dashboard/i18n/locale/en/index.js +++ b/app/javascript/dashboard/i18n/locale/en/index.js @@ -18,6 +18,7 @@ import { default as _setNewPassword } from './setNewPassword.json'; import { default as _settings } from './settings.json'; import { default as _signup } from './signup.json'; import { default as _teamsSettings } from './teamsSettings.json'; +import { default as _automation } from './automation.json'; export default { ..._agentMgmt, @@ -40,4 +41,5 @@ export default { ..._settings, ..._signup, ..._teamsSettings, + ..._automation, }; diff --git a/app/javascript/dashboard/i18n/locale/en/settings.json b/app/javascript/dashboard/i18n/locale/en/settings.json index 837184245..5c8dcbf98 100644 --- a/app/javascript/dashboard/i18n/locale/en/settings.json +++ b/app/javascript/dashboard/i18n/locale/en/settings.json @@ -140,6 +140,7 @@ "APPLICATIONS": "Applications", "LABELS": "Labels", "CUSTOM_ATTRIBUTES": "Custom Attributes", + "AUTOMATION": "Automation", "TEAMS": "Teams", "ALL_CONTACTS": "All Contacts", "TAGGED_WITH": "Tagged with", diff --git a/app/javascript/dashboard/i18n/sidebarItems/settings.js b/app/javascript/dashboard/i18n/sidebarItems/settings.js index c2e7b8f0b..23f59bd7b 100644 --- a/app/javascript/dashboard/i18n/sidebarItems/settings.js +++ b/app/javascript/dashboard/i18n/sidebarItems/settings.js @@ -28,6 +28,7 @@ const settings = accountId => ({ 'settings_teams_edit', 'settings_teams_edit_members', 'settings_teams_edit_finish', + 'automation_list', ], menuItems: { back: { @@ -74,6 +75,13 @@ const settings = accountId => ({ ), toStateName: 'attributes_list', }, + automation: { + icon: 'ion-wrench', + label: 'AUTOMATION', + hasSubMenu: false, + toState: frontendURL(`accounts/${accountId}/settings/automation/list`), + toStateName: 'automation_list', + }, cannedResponses: { icon: 'ion-chatbox-working', label: 'CANNED_RESPONSES', diff --git a/app/javascript/dashboard/routes/dashboard/settings/automation/Index.vue b/app/javascript/dashboard/routes/dashboard/settings/automation/Index.vue new file mode 100644 index 000000000..dfade7e42 --- /dev/null +++ b/app/javascript/dashboard/routes/dashboard/settings/automation/Index.vue @@ -0,0 +1,12 @@ + + diff --git a/app/javascript/shared/components/FluentIcon/icons.json b/app/javascript/shared/components/FluentIcon/icons.json new file mode 100644 index 000000000..9ee0e82da --- /dev/null +++ b/app/javascript/shared/components/FluentIcon/icons.json @@ -0,0 +1,11 @@ +{ + "arrow-right-outline": "M13.267 4.209a.75.75 0 0 0-1.034 1.086l6.251 5.955H3.75a.75.75 0 0 0 0 1.5h14.734l-6.251 5.954a.75.75 0 0 0 1.034 1.087l7.42-7.067a.996.996 0 0 0 .3-.58.758.758 0 0 0-.001-.29.995.995 0 0 0-.3-.578l-7.419-7.067Z", + "attach-outline": "M11.772 3.743a6 6 0 0 1 8.66 8.302l-.19.197-8.8 8.798-.036.03a3.723 3.723 0 0 1-5.489-4.973.764.764 0 0 1 .085-.13l.054-.06.086-.088.142-.148.002.003 7.436-7.454a.75.75 0 0 1 .977-.074l.084.073a.75.75 0 0 1 .074.976l-.073.084-7.594 7.613a2.23 2.23 0 0 0 3.174 3.106l8.832-8.83A4.502 4.502 0 0 0 13 4.644l-.168.16-.013.014-9.536 9.536a.75.75 0 0 1-1.133-.977l.072-.084 9.549-9.55h.002Z", + "chevron-right-outline": "M8.293 4.293a1 1 0 0 0 0 1.414L14.586 12l-6.293 6.293a1 1 0 1 0 1.414 1.414l7-7a1 1 0 0 0 0-1.414l-7-7a1 1 0 0 0-1.414 0Z", + "dismiss-outline": "m4.397 4.554.073-.084a.75.75 0 0 1 .976-.073l.084.073L12 10.939l6.47-6.47a.75.75 0 1 1 1.06 1.061L13.061 12l6.47 6.47a.75.75 0 0 1 .072.976l-.073.084a.75.75 0 0 1-.976.073l-.084-.073L12 13.061l-6.47 6.47a.75.75 0 0 1-1.06-1.061L10.939 12l-6.47-6.47a.75.75 0 0 1-.072-.976l.073-.084-.073.084Z", + "document-outline": "M18.5 20a.5.5 0 0 1-.5.5H6a.5.5 0 0 1-.5-.5V4a.5.5 0 0 1 .5-.5h6V8a2 2 0 0 0 2 2h4.5v10Zm-5-15.379L17.378 8.5H14a.5.5 0 0 1-.5-.5V4.621Zm5.914 3.793-5.829-5.828c-.026-.026-.058-.046-.085-.07a2.072 2.072 0 0 0-.219-.18c-.04-.027-.086-.045-.128-.068-.071-.04-.141-.084-.216-.116a1.977 1.977 0 0 0-.624-.138C12.266 2.011 12.22 2 12.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9.828a2 2 0 0 0-.586-1.414Z", + "emoji-outline": "M12 1.999c5.524 0 10.002 4.478 10.002 10.002 0 5.523-4.478 10.001-10.002 10.001-5.524 0-10.002-4.478-10.002-10.001C1.998 6.477 6.476 1.999 12 1.999Zm0 1.5a8.502 8.502 0 1 0 0 17.003A8.502 8.502 0 0 0 12 3.5ZM8.462 14.784A4.491 4.491 0 0 0 12 16.502a4.492 4.492 0 0 0 3.535-1.714.75.75 0 1 1 1.177.93A5.991 5.991 0 0 1 12 18.002a5.991 5.991 0 0 1-4.716-2.29.75.75 0 0 1 1.178-.928ZM9 8.75a1.25 1.25 0 1 1 0 2.499A1.25 1.25 0 0 1 9 8.75Zm6 0a1.25 1.25 0 1 1 0 2.499 1.25 1.25 0 0 1 0-2.499Z", + "link-outline": "M9.25 7a.75.75 0 0 1 .11 1.492l-.11.008H7a3.5 3.5 0 0 0-.206 6.994L7 15.5h2.25a.75.75 0 0 1 .11 1.492L9.25 17H7a5 5 0 0 1-.25-9.994L7 7h2.25ZM17 7a5 5 0 0 1 .25 9.994L17 17h-2.25a.75.75 0 0 1-.11-1.492l.11-.008H17a3.5 3.5 0 0 0 .206-6.994L17 8.5h-2.25a.75.75 0 0 1-.11-1.492L14.75 7H17ZM7 11.25h10a.75.75 0 0 1 .102 1.493L17 12.75H7a.75.75 0 0 1-.102-1.493L7 11.25h10H7Z", + "open-outline": "M6.25 4.5A1.75 1.75 0 0 0 4.5 6.25v11.5c0 .966.783 1.75 1.75 1.75h11.5a1.75 1.75 0 0 0 1.75-1.75v-4a.75.75 0 0 1 1.5 0v4A3.25 3.25 0 0 1 17.75 21H6.25A3.25 3.25 0 0 1 3 17.75V6.25A3.25 3.25 0 0 1 6.25 3h4a.75.75 0 0 1 0 1.5h-4ZM13 3.75a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 .75.75v6.5a.75.75 0 0 1-1.5 0V5.56l-5.22 5.22a.75.75 0 0 1-1.06-1.06l5.22-5.22h-4.69a.75.75 0 0 1-.75-.75Z", + "send-outline": "M5.694 12 2.299 3.272c-.236-.607.356-1.188.942-.982l.093.04 18 9a.75.75 0 0 1 .097 1.283l-.097.058-18 9c-.583.291-1.217-.244-1.065-.847l.03-.096L5.694 12 2.299 3.272 5.694 12ZM4.402 4.54l2.61 6.71h6.627a.75.75 0 0 1 .743.648l.007.102a.75.75 0 0 1-.649.743l-.101.007H7.01l-2.609 6.71L19.322 12 4.401 4.54Z" +} diff --git a/app/javascript/survey/assets/scss/woot.scss b/app/javascript/survey/assets/scss/woot.scss index d7e7f5497..5c7a4a213 100755 --- a/app/javascript/survey/assets/scss/woot.scss +++ b/app/javascript/survey/assets/scss/woot.scss @@ -7,7 +7,6 @@ @import 'widget/assets/scss/mixins'; @import 'widget/assets/scss/forms'; @import 'shared/assets/fonts/widget_fonts'; -@import '~shared/assets/stylesheets/ionicons'; html, body { diff --git a/app/javascript/widget/assets/scss/_utilities.scss b/app/javascript/widget/assets/scss/_utilities.scss new file mode 100644 index 000000000..0832681e0 --- /dev/null +++ b/app/javascript/widget/assets/scss/_utilities.scss @@ -0,0 +1,3 @@ +.icon-button { + @include button-size; +} diff --git a/app/javascript/widget/assets/scss/_variables.scss b/app/javascript/widget/assets/scss/_variables.scss index 8840c0263..dff2c30b9 100755 --- a/app/javascript/widget/assets/scss/_variables.scss +++ b/app/javascript/widget/assets/scss/_variables.scss @@ -84,7 +84,6 @@ Roboto, Tahoma, Arial, sans-serif; -$ionicons-font-path: '~ionicons/fonts'; // Break points $break-point-medium: 667px; diff --git a/app/javascript/widget/assets/scss/woot.scss b/app/javascript/widget/assets/scss/woot.scss index d9084e8f4..5d8a44fdf 100755 --- a/app/javascript/widget/assets/scss/woot.scss +++ b/app/javascript/widget/assets/scss/woot.scss @@ -6,8 +6,8 @@ @import 'buttons'; @import 'mixins'; @import 'forms'; +@import 'utilities'; @import 'shared/assets/fonts/widget_fonts'; -@import '~shared/assets/stylesheets/ionicons'; @import '~spinkit/scss/spinners/7-three-bounce'; html, diff --git a/app/javascript/widget/components/ChatAttachment.vue b/app/javascript/widget/components/ChatAttachment.vue index 998b1745b..d1d789d61 100755 --- a/app/javascript/widget/components/ChatAttachment.vue +++ b/app/javascript/widget/components/ChatAttachment.vue @@ -4,10 +4,10 @@ accept="image/*, application/pdf, audio/mpeg, video/mp4, audio/ogg, text/csv" @input-file="onFileUpload" > - - + @@ -17,9 +17,9 @@ import Spinner from 'shared/components/Spinner.vue'; import { checkFileSizeLimit } from 'shared/helpers/FileHelper'; import { MAXIMUM_FILE_UPLOAD_SIZE } from 'shared/constants/messages'; import { BUS_EVENTS } from 'shared/constants/busEvents'; - +import FluentIcon from 'shared/components/FluentIcon/Index.vue'; export default { - components: { FileUpload, Spinner }, + components: { FluentIcon, FileUpload, Spinner }, props: { onAttach: { type: Function, @@ -66,28 +66,6 @@ export default { }, }; - diff --git a/app/javascript/widget/components/FileBubble.vue b/app/javascript/widget/components/FileBubble.vue index 93c30b891..24e580b85 100644 --- a/app/javascript/widget/components/FileBubble.vue +++ b/app/javascript/widget/components/FileBubble.vue @@ -1,13 +1,13 @@