From ab54d9c629e2c8ba59342591c3d6d4a7881d50e4 Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Tue, 3 Aug 2021 20:11:52 +0530 Subject: [PATCH] chore: Upgrade rails and ruby versions (#2400) ruby version: 3.0.2 rails version: 6.1.4 --- .circleci/config.yml | 2 +- .devcontainer/Dockerfile.base | 2 +- .devcontainer/docker-compose.yml | 4 +- .nvmrc | 2 +- .rubocop.yml | 30 +- .ruby-version | 2 +- Gemfile | 17 +- Gemfile.lock | 513 +++++++++--------- .../messages/facebook/message_builder.rb | 4 +- .../api/v1/accounts/base_controller.rb | 2 +- .../api/v1/accounts/callbacks_controller.rb | 4 +- .../channels/twilio_channels_controller.rb | 3 +- .../v1/accounts/inbox_members_controller.rb | 2 +- app/controllers/api/v1/webhooks_controller.rb | 2 +- app/controllers/application_controller.rb | 2 +- app/controllers/concerns/auth_helper.rb | 4 +- .../api/v1/inboxes/messages_controller.rb | 2 +- app/controllers/swagger_controller.rb | 2 +- app/jobs/contact_ip_lookup_job.rb | 2 +- app/jobs/hook_job.rb | 2 +- app/mailboxes/application_mailbox.rb | 2 +- app/mailboxes/reply_mailbox.rb | 2 +- app/models/channel/facebook_page.rb | 4 +- .../concerns/content_attribute_validator.rb | 2 +- app/models/integrations/app.rb | 2 - app/models/message.rb | 4 +- app/presenters/mail_presenter.rb | 2 +- .../contacts/contactable_inboxes_service.rb | 2 +- .../template/email_collect.rb | 2 +- .../message_templates/template/greeting.rb | 2 +- .../template/out_of_office.rb | 2 +- .../api/v2/accounts/reports/agents.csv.erb | 2 +- config/application.rb | 5 - .../initializers/active_record_query_trace.rb | 1 + config/initializers/assets.rb | 3 +- .../azure_storage_service_patch.rb | 170 ------ config/initializers/bot.rb | 41 -- .../initializers/facebook_messenger.rb | 27 +- config/initializers/sentry.rb | 28 +- .../20200418124534_add_sender_to_messages.rb | 4 +- ..._to_active_storage_blobs.active_storage.rb | 18 + ..._storage_variant_records.active_storage.rb | 12 + db/schema.rb | 12 +- deployment/chatwoot-web.1.service | 6 +- deployment/chatwoot-worker.1.service | 6 +- deployment/setup_18.04.sh | 4 +- deployment/setup_20.04.sh | 4 +- docker/Dockerfile | 10 +- lib/azure/storage.rb | 2 - .../core/auth/shared_access_signature.rb | 2 - lib/chatwoot_hub.rb | 4 +- lib/exception_list.rb | 2 +- lib/integrations/facebook/message_creator.rb | 2 +- lib/webhooks/trigger.rb | 2 +- lib/woot_message_seeder.rb | 18 +- spec/actions/contact_merge_action_spec.rb | 8 +- .../contacts/conversations_controller_spec.rb | 6 +- ...spec.rb => csat_survey_controller_spec.rb} | 0 spec/factories/integrations/hooks.rb | 2 +- spec/rails_helper.rb | 3 +- spec/support/slack_stubs.rb | 91 ++-- 61 files changed, 498 insertions(+), 626 deletions(-) create mode 100644 config/initializers/active_record_query_trace.rb delete mode 100644 config/initializers/azure_storage_service_patch.rb delete mode 100644 config/initializers/bot.rb rename app/bot/facebook_bot.rb => config/initializers/facebook_messenger.rb (62%) create mode 100644 db/migrate/20210611180221_add_service_name_to_active_storage_blobs.active_storage.rb create mode 100644 db/migrate/20210611180222_create_active_storage_variant_records.active_storage.rb delete mode 100644 lib/azure/storage.rb delete mode 100644 lib/azure/storage/core/auth/shared_access_signature.rb rename spec/controllers/public/api/v1/{csat_survey_controller.spec.rb => csat_survey_controller_spec.rb} (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0e3153a7a8ed8..f8ffdf076a5da 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ defaults: &defaults working_directory: ~/build docker: # specify the version you desire here - - image: circleci/ruby:2.7.3-node-browsers + - image: circleci/ruby:3.0.2-node-browsers # Specify service dependencies here if necessary # CircleCI maintains a library of pre-built images diff --git a/.devcontainer/Dockerfile.base b/.devcontainer/Dockerfile.base index dcbbd27ca75d9..de007e2020661 100644 --- a/.devcontainer/Dockerfile.base +++ b/.devcontainer/Dockerfile.base @@ -1,5 +1,5 @@ # pre-build stage -ARG VARIANT=2.7 +ARG VARIANT=3 FROM mcr.microsoft.com/vscode/devcontainers/ruby:${VARIANT} # Update args in docker-compose.yaml to set the UID/GID of the "vscode" user. diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 6a2ffbea62589..36e4e82141521 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -10,8 +10,8 @@ services: context: .. dockerfile: .devcontainer/Dockerfile args: - # Update 'VARIANT' to pick a Ruby version: 2, 2.7, 2.6, 2.5 - VARIANT: 2.7 + # Update 'VARIANT' to pick a Ruby version: https://github.com/microsoft/vscode-dev-containers/tree/main/containers/ruby + VARIANT: 3 # [Choice] Install Node.js INSTALL_NODE: "true" NODE_VERSION: "lts/*" diff --git a/.nvmrc b/.nvmrc index 66df3b7ab2d11..e0228cf182652 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -12.16.1 +16.1.0 diff --git a/.rubocop.yml b/.rubocop.yml index ac0a64665ca9d..c05cbb9bfb70c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -40,6 +40,14 @@ Style/ClassVars: Lint/MissingSuper: Exclude: - 'app/drops/base_drop.rb' +Lint/SymbolConversion: + Enabled: false +Lint/EmptyBlock: + Exclude: + - 'app/views/api/v1/accounts/conversations/toggle_status.json.jbuilder' +Lint/OrAssignmentToConstant: + Exclude: + - 'lib/redis/config.rb' Metrics/BlockLength: Exclude: - spec/**/* @@ -58,6 +66,10 @@ Rails/ApplicationController: - 'app/controllers/platform_controller.rb' - 'app/controllers/public_controller.rb' - 'app/controllers/survey/responses_controller.rb' +Rails/EnvironmentVariableAccess: + Enabled: false +Rails/TimeZoneAssignment: + Enabled: false Style/ClassAndModuleChildren: EnforcedStyle: compact Exclude: @@ -67,6 +79,10 @@ RSpec/NestedGroups: Max: 4 RSpec/MessageSpies: Enabled: false +RSpec/StubbedMock: + Enabled: false +Naming/VariableNumber: + Enabled: false Metrics/MethodLength: Exclude: - 'db/migrate/20161123131628_devise_token_auth_create_users.rb' @@ -114,14 +130,19 @@ Rails/UniqueValidationWithoutIndex: - 'app/models/channel/twitter_profile.rb' - 'app/models/webhook.rb' - 'app/models/contact.rb' + - 'app/models/integrations/hook.rb' Rails/RenderInline: Exclude: - 'app/controllers/swagger_controller.rb' +Performance/CollectionLiteralInLoop: + Exclude: + - 'db/migrate/20210315101919_enable_email_channel.rb' RSpec/NamedSubject: Enabled: false # we should bring this down RSpec/MultipleMemoizedHelpers: Max: 12 + AllCops: NewCops: enable Exclude: @@ -136,4 +157,11 @@ AllCops: - 'tmp/**/*' - 'storage/**/*' - 'db/migrate/20200225162150_init_schema.rb' - - 'config/initializers/azure_storage_service_patch.rb' + - 'db/migrate/20210611180222_create_active_storage_variant_records.active_storage.rb' + - 'db/migrate/20210611180221_add_service_name_to_active_storage_blobs.active_storage.rb' + - db/migrate/20200309213132_add_account_id_to_agent_bot_inboxes.rb + - db/migrate/20200331095710_add_identifier_to_contact.rb + - db/migrate/20200429082655_add_medium_to_twilio_sms.rb + - db/migrate/20200503151130_add_account_feature_flag.rb + - db/migrate/20200927135222_add_last_activity_at_to_conversation.rb + - db/migrate/20210306170117_add_last_activity_at_to_contacts.rb diff --git a/.ruby-version b/.ruby-version index 2c9b4ef42ecbc..b50214693056f 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.3 +3.0.2 diff --git a/Gemfile b/Gemfile index 29fbb8af26d8e..0b5336889bc71 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -ruby '2.7.3' +ruby '3.0.2' ##-- base gems for rails --## gem 'rack-cors', require: 'rack/cors' @@ -40,7 +40,7 @@ gem 'rack-attack' gem 'aws-sdk-s3', require: false gem 'azure-storage-blob', require: false gem 'google-cloud-storage', require: false -gem 'mini_magick' +gem 'image_processing' ##-- gems for database --# gem 'groupdate' @@ -91,8 +91,11 @@ gem 'google-cloud-dialogflow' ##--- gems for debugging and error reporting ---## # static analysis gem 'brakeman' +gem 'ddtrace' gem 'scout_apm' -gem 'sentry-raven' +gem 'sentry-rails' +gem 'sentry-ruby' +gem 'sentry-sidekiq' ##-- background job processing --## gem 'sidekiq' @@ -121,7 +124,7 @@ group :development do gem 'web-console' # used in swagger build - gem 'json_refs', git: 'https://github.com/tzmfreedom/json_refs', ref: '131b11294fd6af9c428171f38516e6222a58c874' + gem 'json_refs' # When we want to squash migrations gem 'squasher' @@ -135,19 +138,19 @@ group :test do end group :development, :test do + gem 'active_record_query_trace' gem 'bundle-audit', require: false gem 'byebug', platform: :mri gem 'factory_bot_rails' gem 'faker' gem 'listen' - gem 'mock_redis', git: 'https://github.com/sds/mock_redis', ref: '16d00789f0341a3aac35126c0ffe97a596753ff9' + gem 'mock_redis' gem 'pry-rails' - gem 'rspec-rails', '~> 4.0.0.beta2' + gem 'rspec-rails', '~> 5.0.0' gem 'rubocop', require: false gem 'rubocop-performance', require: false gem 'rubocop-rails', require: false gem 'rubocop-rspec', require: false - gem 'scss_lint', require: false gem 'seed_dump' gem 'shoulda-matchers' gem 'simplecov', '0.17.1', require: false diff --git a/Gemfile.lock b/Gemfile.lock index fc581ae277ba8..533bccb8b85f8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,80 +1,70 @@ -GIT - remote: https://github.com/sds/mock_redis - revision: 16d00789f0341a3aac35126c0ffe97a596753ff9 - ref: 16d00789f0341a3aac35126c0ffe97a596753ff9 - specs: - mock_redis (0.22.0) - -GIT - remote: https://github.com/tzmfreedom/json_refs - revision: 131b11294fd6af9c428171f38516e6222a58c874 - ref: 131b11294fd6af9c428171f38516e6222a58c874 - specs: - json_refs (0.1.6) - hana - GEM remote: https://rubygems.org/ specs: - actioncable (6.0.3.7) - actionpack (= 6.0.3.7) + actioncable (6.1.4) + actionpack (= 6.1.4) + activesupport (= 6.1.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.0.3.7) - actionpack (= 6.0.3.7) - activejob (= 6.0.3.7) - activerecord (= 6.0.3.7) - activestorage (= 6.0.3.7) - activesupport (= 6.0.3.7) + actionmailbox (6.1.4) + actionpack (= 6.1.4) + activejob (= 6.1.4) + activerecord (= 6.1.4) + activestorage (= 6.1.4) + activesupport (= 6.1.4) mail (>= 2.7.1) - actionmailer (6.0.3.7) - actionpack (= 6.0.3.7) - actionview (= 6.0.3.7) - activejob (= 6.0.3.7) + actionmailer (6.1.4) + actionpack (= 6.1.4) + actionview (= 6.1.4) + activejob (= 6.1.4) + activesupport (= 6.1.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.0.3.7) - actionview (= 6.0.3.7) - activesupport (= 6.0.3.7) - rack (~> 2.0, >= 2.0.8) + actionpack (6.1.4) + actionview (= 6.1.4) + activesupport (= 6.1.4) + rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.0.3.7) - actionpack (= 6.0.3.7) - activerecord (= 6.0.3.7) - activestorage (= 6.0.3.7) - activesupport (= 6.0.3.7) + actiontext (6.1.4) + actionpack (= 6.1.4) + activerecord (= 6.1.4) + activestorage (= 6.1.4) + activesupport (= 6.1.4) nokogiri (>= 1.8.5) - actionview (6.0.3.7) - activesupport (= 6.0.3.7) + actionview (6.1.4) + activesupport (= 6.1.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.0.3.7) - activesupport (= 6.0.3.7) + active_record_query_trace (1.8) + activejob (6.1.4) + activesupport (= 6.1.4) globalid (>= 0.3.6) - activemodel (6.0.3.7) - activesupport (= 6.0.3.7) - activerecord (6.0.3.7) - activemodel (= 6.0.3.7) - activesupport (= 6.0.3.7) - activerecord-import (1.0.7) + activemodel (6.1.4) + activesupport (= 6.1.4) + activerecord (6.1.4) + activemodel (= 6.1.4) + activesupport (= 6.1.4) + activerecord-import (1.2.0) activerecord (>= 3.2) - activestorage (6.0.3.7) - actionpack (= 6.0.3.7) - activejob (= 6.0.3.7) - activerecord (= 6.0.3.7) + activestorage (6.1.4) + actionpack (= 6.1.4) + activejob (= 6.1.4) + activerecord (= 6.1.4) + activesupport (= 6.1.4) marcel (~> 1.0.0) - activesupport (6.0.3.7) + mini_mime (>= 1.1.0) + activesupport (6.1.4) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) - acts-as-taggable-on (6.5.0) - activerecord (>= 5.0, < 6.1) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + acts-as-taggable-on (8.1.0) + activerecord (>= 5.0, < 6.2) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) administrate (0.16.0) @@ -90,23 +80,23 @@ GEM annotate (3.1.1) activerecord (>= 3.2, < 7.0) rake (>= 10.4, < 14.0) - ast (2.4.1) + ast (2.4.2) attr_extras (6.2.4) - aws-eventstream (1.1.0) - aws-partitions (1.360.0) - aws-sdk-core (3.105.0) + aws-eventstream (1.1.1) + aws-partitions (1.482.0) + aws-sdk-core (3.119.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-kms (1.37.0) - aws-sdk-core (~> 3, >= 3.99.0) + aws-sdk-kms (1.46.0) + aws-sdk-core (~> 3, >= 3.119.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.79.1) - aws-sdk-core (~> 3, >= 3.104.3) + aws-sdk-s3 (1.98.0) + aws-sdk-core (~> 3, >= 3.119.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.1) - aws-sigv4 (1.2.2) + aws-sigv4 (1.2.4) aws-eventstream (~> 1, >= 1.0.2) axiom-types (0.1.1) descendants_tracker (~> 0.0.4) @@ -120,42 +110,48 @@ GEM faraday_middleware (~> 1.0.0.rc1) net-http-persistent (~> 4.0) nokogiri (~> 1.11.0.rc2) - barnes (0.0.8) + barnes (0.0.9) multi_json (~> 1) statsd-ruby (~> 1.1) bcrypt (3.1.16) bindex (0.8.1) - bootsnap (1.4.8) + bootsnap (1.7.6) msgpack (~> 1.0) - brakeman (4.9.0) + brakeman (5.1.1) browser (5.3.1) builder (3.2.4) - bullet (6.1.0) + bullet (6.1.4) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) bundle-audit (0.1.0) bundler-audit - bundler-audit (0.7.0.1) + bundler-audit (0.8.0) bundler (>= 1.2.0, < 3) - thor (>= 0.18, < 2) + thor (~> 1.0) byebug (11.1.3) coderay (1.1.3) coercible (1.0.0) descendants_tracker (~> 0.0.1) - commonmarker (0.21.1) - ruby-enum (~> 0.5) - concurrent-ruby (1.1.8) - connection_pool (2.2.3) - crack (0.4.3) - safe_yaml (~> 1.0.0) + commonmarker (0.22.0) + concurrent-ruby (1.1.9) + connection_pool (2.2.5) + crack (0.4.5) + rexml crass (1.0.6) - cypress-on-rails (1.8.0) + cypress-on-rails (1.10.1) rack - database_cleaner (1.8.5) + database_cleaner (2.0.1) + database_cleaner-active_record (~> 2.0.0) + database_cleaner-active_record (2.0.1) + activerecord (>= 5.a) + database_cleaner-core (~> 2.0.0) + database_cleaner-core (2.0.1) datetime_picker_rails (0.0.7) momentjs-rails (>= 2.8.1) + ddtrace (0.51.1) + ffi (~> 1.0) + msgpack declarative (0.0.20) - declarative-option (0.1.0) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) devise (4.8.0) @@ -167,48 +163,47 @@ GEM devise-secure_password (2.0.1) devise (>= 4.0.0, < 5.0.0) railties (>= 5.0.0, < 7.0.0) - devise_token_auth (1.1.4) + devise_token_auth (1.2.0) bcrypt (~> 3.0) devise (> 3.5.2, < 5) - rails (>= 4.2.0, < 6.1) - sprockets (= 3.7.2) + rails (>= 4.2.0, < 6.2) diff-lcs (1.4.4) - digest-crc (0.6.1) - rake (~> 13.0) - docile (1.3.2) + digest-crc (0.6.4) + rake (>= 12.0.0, < 14.0.0) + docile (1.4.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) dotenv (2.7.6) dotenv-rails (2.7.6) dotenv (= 2.7.6) railties (>= 3.2) - ecma-re-validator (0.2.1) - regexp_parser (~> 1.2) - equalizer (0.0.11) + dry-inflector (0.2.1) + ecma-re-validator (0.3.0) + regexp_parser (~> 2.0) erubi (1.10.0) et-orbi (1.2.4) tzinfo - execjs (2.7.0) + execjs (2.8.1) facebook-messenger (2.0.1) httparty (~> 0.13, >= 0.13.7) rack (>= 1.4.5) - factory_bot (6.1.0) + factory_bot (6.2.0) activesupport (>= 5.0.0) - factory_bot_rails (6.1.0) - factory_bot (~> 6.1.0) + factory_bot_rails (6.2.0) + factory_bot (~> 6.2.0) railties (>= 5.0.0) - faker (2.13.0) + faker (2.18.0) i18n (>= 1.6, < 2) faraday (1.0.1) multipart-post (>= 1.2, < 3) faraday_middleware (1.0.0) faraday (~> 1.0) - fcm (1.0.2) - faraday (~> 1.0.0) - ffi (1.15.0) + fcm (1.0.3) + faraday (~> 1) + ffi (1.15.3) flag_shih_tzu (0.3.23) foreman (0.87.2) - fugit (1.4.1) + fugit (1.5.0) et-orbi (~> 1.1, >= 1.1.8) raabro (~> 1.4) gapic-common (0.3.4) @@ -217,18 +212,23 @@ GEM googleapis-common-protos-types (>= 1.0.4, < 2.0) googleauth (~> 0.9) grpc (~> 1.25) - geocoder (1.6.3) - gli (2.19.2) - globalid (0.4.2) - activesupport (>= 4.2.0) - google-api-client (0.43.0) + geocoder (1.6.7) + gli (2.20.1) + globalid (0.5.1) + activesupport (>= 5.0) + google-apis-core (0.4.1) addressable (~> 2.5, >= 2.5.1) - googleauth (~> 0.9) - httpclient (>= 2.8.1, < 3.0) + googleauth (>= 0.16.2, < 2.a) + httpclient (>= 2.8.1, < 3.a) mini_mime (~> 1.0) representable (~> 3.0) - retriable (>= 2.0, < 4.0) - signet (~> 0.12) + retriable (>= 2.0, < 4.a) + rexml + webrick + google-apis-iamcredentials_v1 (0.6.0) + google-apis-core (>= 0.4, < 2.a) + google-apis-storage_v1 (0.6.0) + google-apis-core (>= 0.4, < 2.a) google-cloud-core (1.6.0) google-cloud-env (~> 1.0) google-cloud-errors (~> 1.0) @@ -241,21 +241,23 @@ GEM google-cloud-env (1.5.0) faraday (>= 0.17.3, < 2.0) google-cloud-errors (1.1.0) - google-cloud-storage (1.28.0) + google-cloud-storage (1.34.1) addressable (~> 2.5) digest-crc (~> 0.4) - google-api-client (~> 0.33) - google-cloud-core (~> 1.2) - googleauth (~> 0.9) + google-apis-iamcredentials_v1 (~> 0.1) + google-apis-storage_v1 (~> 0.1) + google-cloud-core (~> 1.6) + googleauth (>= 0.16.2, < 2.a) mini_mime (~> 1.0) - google-protobuf (3.15.8) + google-protobuf (3.17.3-universal-darwin) + google-protobuf (3.17.3-x86_64-linux) googleapis-common-protos (1.3.11) google-protobuf (~> 3.14) googleapis-common-protos-types (>= 1.0.6, < 2.0) grpc (~> 1.27) - googleapis-common-protos-types (1.0.6) + googleapis-common-protos-types (1.1.0) google-protobuf (~> 3.14) - googleauth (0.16.2) + googleauth (0.17.0) faraday (>= 0.17.3, < 2.0) jwt (>= 1.4, < 3.0) memoist (~> 0.16) @@ -264,11 +266,14 @@ GEM signet (~> 0.14) groupdate (5.2.2) activesupport (>= 5) - grpc (1.37.1) + grpc (1.38.0-universal-darwin) google-protobuf (~> 3.15) googleapis-common-protos-types (~> 1.0) - haikunator (1.1.0) - hairtrigger (0.2.23) + grpc (1.38.0-x86_64-linux) + google-protobuf (~> 3.15) + googleapis-common-protos-types (~> 1.0) + haikunator (1.1.1) + hairtrigger (0.2.24) activerecord (>= 5.0, < 7) ruby2ruby (~> 2.4) ruby_parser (~> 3.10) @@ -277,7 +282,7 @@ GEM hashie (4.1.0) hkdf (0.3.0) http-accept (1.7.0) - http-cookie (1.0.3) + http-cookie (1.0.4) domain_name (~> 0.5) httparty (0.18.1) mime-types (~> 3.0) @@ -286,19 +291,23 @@ GEM i18n (1.8.10) concurrent-ruby (~> 1.0) ice_nine (0.11.2) - inflecto (0.0.2) - jbuilder (2.10.0) + image_processing (1.12.1) + mini_magick (>= 4.9.5, < 5) + ruby-vips (>= 2.0.17, < 3) + jbuilder (2.11.2) activesupport (>= 5.0.0) jmespath (1.4.0) jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.3.1) - json_schemer (0.2.16) - ecma-re-validator (~> 0.2) + json (2.5.1) + json_refs (0.1.6) + hana + json_schemer (0.2.18) + ecma-re-validator (~> 0.3) hana (~> 1.3) - regexp_parser (~> 1.5) + regexp_parser (~> 2.0) uri_template (~> 0.7) jwt (2.2.3) kaminari (1.2.1) @@ -321,11 +330,11 @@ GEM addressable (~> 2.7) letter_opener (1.7.0) launchy (~> 2.2) - liquid (4.0.3) - listen (3.3.3) + liquid (5.0.1) + listen (3.6.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.9.1) + loofah (2.11.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -336,40 +345,42 @@ GEM method_source (1.0.0) mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2021.0225) - mini_magick (4.10.1) + mime-types-data (3.2021.0704) + mini_magick (4.11.0) mini_mime (1.1.0) - mini_portile2 (2.5.1) minitest (5.14.4) + mock_redis (0.28.0) + ruby2_keywords momentjs-rails (2.20.1) railties (>= 3.1) - msgpack (1.3.3) + msgpack (1.4.2) multi_json (1.15.0) multi_xml (0.6.0) multipart-post (2.1.1) - net-http-persistent (4.0.0) + net-http-persistent (4.0.1) connection_pool (~> 2.2) netrc (0.11.0) nio4r (2.5.7) - nokogiri (1.11.6) - mini_portile2 (~> 2.5.0) + nokogiri (1.11.7-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.11.7-x86_64-linux) racc (~> 1.4) oauth (0.5.6) orm_adapter (0.5.0) os (1.1.1) - parallel (1.19.2) - parser (2.7.1.4) + parallel (1.20.1) + parser (3.0.2.0) ast (~> 2.4.1) pg (1.2.3) - procore-sift (0.15.0) + procore-sift (0.16.0) rails (> 4.2.0) - pry (0.13.1) + pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) pry-rails (0.3.9) pry (>= 0.10.4) public_suffix (4.0.6) - puma (4.3.8) + puma (5.4.0) nio4r (~> 2.0) pundit (2.1.0) activesupport (>= 3.0.0) @@ -380,49 +391,49 @@ GEM rack (>= 1.0, < 3) rack-cors (1.1.1) rack (>= 2.0.0) - rack-proxy (0.6.5) + rack-proxy (0.7.0) rack rack-test (1.1.0) rack (>= 1.0, < 3) rack-timeout (0.6.0) - rails (6.0.3.7) - actioncable (= 6.0.3.7) - actionmailbox (= 6.0.3.7) - actionmailer (= 6.0.3.7) - actionpack (= 6.0.3.7) - actiontext (= 6.0.3.7) - actionview (= 6.0.3.7) - activejob (= 6.0.3.7) - activemodel (= 6.0.3.7) - activerecord (= 6.0.3.7) - activestorage (= 6.0.3.7) - activesupport (= 6.0.3.7) - bundler (>= 1.3.0) - railties (= 6.0.3.7) + rails (6.1.4) + actioncable (= 6.1.4) + actionmailbox (= 6.1.4) + actionmailer (= 6.1.4) + actionpack (= 6.1.4) + actiontext (= 6.1.4) + actionview (= 6.1.4) + activejob (= 6.1.4) + activemodel (= 6.1.4) + activerecord (= 6.1.4) + activestorage (= 6.1.4) + activesupport (= 6.1.4) + bundler (>= 1.15.0) + railties (= 6.1.4) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) - railties (6.0.3.7) - actionpack (= 6.0.3.7) - activesupport (= 6.0.3.7) + railties (6.1.4) + actionpack (= 6.1.4) + activesupport (= 6.1.4) method_source - rake (>= 0.8.7) - thor (>= 0.20.3, < 2.0) + rake (>= 0.13) + thor (~> 1.0) rainbow (3.0.0) - rake (13.0.3) - rb-fsevent (0.10.4) + rake (13.0.6) + rb-fsevent (0.11.0) rb-inotify (0.10.1) ffi (~> 1.0) - redis (4.2.1) - redis-namespace (1.8.0) + redis (4.4.0) + redis-namespace (1.8.1) redis (>= 3.0.4) - regexp_parser (1.7.1) - representable (3.0.4) + regexp_parser (2.1.1) + representable (3.1.1) declarative (< 0.1.0) - declarative-option (< 0.2.0) + trailblazer-option (>= 0.1.1, < 0.2.0) uber (< 0.2.0) responders (3.0.1) actionpack (>= 5.0) @@ -434,57 +445,53 @@ GEM netrc (~> 0.8) retriable (3.1.2) rexml (3.2.5) - rspec-core (3.9.2) - rspec-support (~> 3.9.3) - rspec-expectations (3.9.2) + rspec-core (3.10.1) + rspec-support (~> 3.10.0) + rspec-expectations (3.10.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-mocks (3.9.1) + rspec-support (~> 3.10.0) + rspec-mocks (3.10.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-rails (4.0.1) - actionpack (>= 4.2) - activesupport (>= 4.2) - railties (>= 4.2) - rspec-core (~> 3.9) - rspec-expectations (~> 3.9) - rspec-mocks (~> 3.9) - rspec-support (~> 3.9) - rspec-support (3.9.3) - rubocop (0.89.1) + rspec-support (~> 3.10.0) + rspec-rails (5.0.1) + actionpack (>= 5.2) + activesupport (>= 5.2) + railties (>= 5.2) + rspec-core (~> 3.10) + rspec-expectations (~> 3.10) + rspec-mocks (~> 3.10) + rspec-support (~> 3.10) + rspec-support (3.10.2) + rubocop (1.18.4) parallel (~> 1.10) - parser (>= 2.7.1.1) + parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.7) + regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 0.3.0, < 1.0) + rubocop-ast (>= 1.8.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (0.3.0) - parser (>= 2.7.1.4) - rubocop-performance (1.7.1) - rubocop (>= 0.82.0) - rubocop-rails (2.8.1) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.8.0) + parser (>= 3.0.1.1) + rubocop-performance (1.11.4) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + rubocop-rails (2.11.3) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 0.87.0) - rubocop-rspec (1.43.2) - rubocop (~> 0.87) - ruby-enum (0.9.0) - i18n - ruby-progressbar (1.10.1) + rubocop (>= 1.7.0, < 2.0) + rubocop-rspec (2.4.0) + rubocop (~> 1.0) + rubocop-ast (>= 1.1.0) + ruby-progressbar (1.11.0) + ruby-vips (2.1.2) + ffi (~> 1.12) + ruby2_keywords (0.0.5) ruby2ruby (2.4.4) ruby_parser (~> 3.1) sexp_processor (~> 4.6) - ruby_parser (3.15.0) - rubocop (>= 0.87.0) - sexp_processor (~> 4.9) - safe_yaml (1.0.5) - sass (3.7.4) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) + ruby_parser (3.16.0) + sexp_processor (~> 4.15, >= 4.15.1) sassc (2.4.0) ffi (~> 1.9) sassc-rails (2.1.2) @@ -493,21 +500,30 @@ GEM sprockets (> 3.0) sprockets-rails tilt - scout_apm (2.6.9) + scout_apm (4.1.1) parser - scss_lint (0.59.0) - sass (~> 3.5, >= 3.5.5) seed_dump (3.3.1) activerecord (>= 4) activesupport (>= 4) selectize-rails (0.12.6) - semantic_range (2.3.0) - sentry-raven (3.0.3) + semantic_range (3.0.0) + sentry-rails (4.6.4) + railties (>= 5.0) + sentry-ruby-core (~> 4.6.0) + sentry-ruby (4.6.4) + concurrent-ruby (~> 1.0, >= 1.0.2) faraday (>= 1.0) - sexp_processor (4.15.1) - shoulda-matchers (4.4.1) - activesupport (>= 4.2.0) - sidekiq (6.1.1) + sentry-ruby-core (= 4.6.4) + sentry-ruby-core (4.6.4) + concurrent-ruby + faraday + sentry-sidekiq (4.6.4) + sentry-ruby-core (~> 4.6.0) + sidekiq (>= 3.0) + sexp_processor (4.15.3) + shoulda-matchers (5.0.0) + activesupport (>= 5.2.0) + sidekiq (6.2.1) connection_pool (>= 2.2.2) rack (~> 2.0) redis (>= 4.2.0) @@ -524,7 +540,7 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - slack-ruby-client (0.15.0) + slack-ruby-client (0.17.0) faraday (>= 1.0) faraday_middleware gli @@ -534,7 +550,7 @@ GEM spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) - sprockets (3.7.2) + sprockets (4.0.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.2.2) @@ -542,27 +558,28 @@ GEM activesupport (>= 4.0) sprockets (>= 3.0.0) squasher (0.6.2) - statsd-ruby (1.4.0) - telegram-bot-ruby (0.12.0) + statsd-ruby (1.5.0) + telegram-bot-ruby (0.16.0) + dry-inflector faraday - inflecto - virtus - telephone_number (1.4.9) + virtus (~> 2.0) + telephone_number (1.4.12) thor (1.1.0) thread_safe (0.3.6) tilt (2.0.10) time_diff (0.3.0) activesupport i18n + trailblazer-option (0.1.1) twilio-ruby (5.32.0) faraday (~> 1.0.0) jwt (>= 1.5, <= 2.5) nokogiri (>= 1.6, < 2.0) - twitty (0.1.1) + twitty (0.1.4) oauth - tzinfo (1.2.9) - thread_safe (~> 0.1) - tzinfo-data (1.2020.1) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + tzinfo-data (1.2021.1) tzinfo (>= 1.0.0) uber (0.1.0) uglifier (4.2.0) @@ -570,46 +587,48 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.7.7) - unicode-display_width (1.7.0) - uniform_notifier (1.13.0) + unicode-display_width (2.0.0) + uniform_notifier (1.14.2) uri_template (0.7.0) - valid_email2 (3.3.1) + valid_email2 (4.0.0) activemodel (>= 3.2) mail (~> 2.5) - virtus (1.0.5) + virtus (2.0.0) axiom-types (~> 0.1) coercible (~> 1.0) descendants_tracker (~> 0.0, >= 0.0.3) - equalizer (~> 0.0, >= 0.0.9) warden (1.2.9) rack (>= 2.0.9) - web-console (4.0.4) + web-console (4.1.0) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webmock (3.8.3) + webmock (3.13.0) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - webpacker (5.2.1) + webpacker (5.4.0) activesupport (>= 5.2) rack-proxy (>= 0.6.1) railties (>= 5.2) semantic_range (>= 2.3.0) - webpush (1.0.0) + webpush (1.1.0) hkdf (~> 0.2) jwt (~> 2.0) - websocket-driver (0.7.3) + webrick (1.7.0) + websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) wisper (2.0.0) zeitwerk (2.4.2) PLATFORMS - ruby + x86_64-darwin-21 + x86_64-linux DEPENDENCIES + active_record_query_trace activerecord-import acts-as-taggable-on administrate @@ -627,6 +646,7 @@ DEPENDENCIES commonmarker cypress-on-rails (~> 1.0) database_cleaner + ddtrace devise devise-secure_password (~> 2.0) devise_token_auth @@ -644,8 +664,9 @@ DEPENDENCIES haikunator hairtrigger hashie + image_processing jbuilder - json_refs! + json_refs json_schemer jwt kaminari @@ -654,8 +675,7 @@ DEPENDENCIES liquid listen maxminddb - mini_magick - mock_redis! + mock_redis pg procore-sift pry-rails @@ -669,15 +689,16 @@ DEPENDENCIES redis-namespace responders rest-client - rspec-rails (~> 4.0.0.beta2) + rspec-rails (~> 5.0.0) rubocop rubocop-performance rubocop-rails rubocop-rspec scout_apm - scss_lint seed_dump - sentry-raven + sentry-rails + sentry-ruby + sentry-sidekiq shoulda-matchers sidekiq sidekiq-cron @@ -701,7 +722,7 @@ DEPENDENCIES wisper (= 2.0.0) RUBY VERSION - ruby 2.7.3p183 + ruby 3.0.2p107 BUNDLED WITH - 2.1.4 + 2.2.25 diff --git a/app/builders/messages/facebook/message_builder.rb b/app/builders/messages/facebook/message_builder.rb index dedc14be78685..bd9212ce0ca2d 100644 --- a/app/builders/messages/facebook/message_builder.rb +++ b/app/builders/messages/facebook/message_builder.rb @@ -27,7 +27,7 @@ def perform rescue Koala::Facebook::AuthenticationError Rails.logger.info "Facebook Authorization expired for Inbox #{@inbox.id}" rescue StandardError => e - Raven.capture_exception(e) + Sentry.capture_exception(e) true end @@ -146,7 +146,7 @@ def contact_params raise rescue StandardError => e result = {} - Raven.capture_exception(e) + Sentry.capture_exception(e) end { name: "#{result['first_name'] || 'John'} #{result['last_name'] || 'Doe'}", diff --git a/app/controllers/api/v1/accounts/base_controller.rb b/app/controllers/api/v1/accounts/base_controller.rb index ef52206db0b28..ddb0f44f49c20 100644 --- a/app/controllers/api/v1/accounts/base_controller.rb +++ b/app/controllers/api/v1/accounts/base_controller.rb @@ -14,7 +14,7 @@ def ensure_current_account account = Account.find(params[:account_id]) if current_user account_accessible_for_user?(account) - elsif @resource&.is_a?(AgentBot) + elsif @resource.is_a?(AgentBot) account_accessible_for_bot?(account) end account diff --git a/app/controllers/api/v1/accounts/callbacks_controller.rb b/app/controllers/api/v1/accounts/callbacks_controller.rb index 9a4cd85e87e4b..82c82f4bcdc39 100644 --- a/app/controllers/api/v1/accounts/callbacks_controller.rb +++ b/app/controllers/api/v1/accounts/callbacks_controller.rb @@ -69,7 +69,7 @@ def mark_already_existing_facebook_pages(data) return [] if data.empty? data.inject([]) do |result, page_detail| - page_detail[:exists] = Current.account.facebook_pages.exists?(page_id: page_detail['id']) ? true : false + page_detail[:exists] = Current.account.facebook_pages.exists?(page_id: page_detail['id']) result << page_detail end end @@ -99,7 +99,7 @@ def get_avatar_url(page_id) end pic_url = response.base_uri.to_s rescue StandardError => e - Rails.logger.debug "Rescued: #{e.inspect}" + Rails.logger.debug { "Rescued: #{e.inspect}" } pic_url = nil end pic_url diff --git a/app/controllers/api/v1/accounts/channels/twilio_channels_controller.rb b/app/controllers/api/v1/accounts/channels/twilio_channels_controller.rb index ffbc78eb50851..a53650e65f7b1 100644 --- a/app/controllers/api/v1/accounts/channels/twilio_channels_controller.rb +++ b/app/controllers/api/v1/accounts/channels/twilio_channels_controller.rb @@ -6,9 +6,8 @@ def create authenticate_twilio build_inbox setup_webhooks if @twilio_channel.sms? - rescue Twilio::REST::TwilioError => e - render_could_not_create_error(e.message) rescue StandardError => e + Sentry.capture_exception(e) render_could_not_create_error(e.message) end end diff --git a/app/controllers/api/v1/accounts/inbox_members_controller.rb b/app/controllers/api/v1/accounts/inbox_members_controller.rb index 27e31c855b84c..c5fb3486bb3a1 100644 --- a/app/controllers/api/v1/accounts/inbox_members_controller.rb +++ b/app/controllers/api/v1/accounts/inbox_members_controller.rb @@ -9,7 +9,7 @@ def create update_agents_list head :ok rescue StandardError => e - Rails.logger.debug "Rescued: #{e.inspect}" + Rails.logger.debug { "Rescued: #{e.inspect}" } render_could_not_create_error('Could not add agents to inbox') end end diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index b2c4949df0998..c96ae9a96df10 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -10,7 +10,7 @@ def twitter_events twitter_consumer.consume head :ok rescue StandardError => e - Raven.capture_exception(e) + Sentry.capture_exception(e) head :ok end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9399771c36814..d25f882694a4a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -16,7 +16,7 @@ class ApplicationController < ActionController::Base def handle_with_exception yield rescue ActiveRecord::RecordNotFound => e - Raven.capture_exception(e) + Sentry.capture_exception(e) render_not_found_error('Resource could not be found') rescue Pundit::NotAuthorizedError render_unauthorized('You are not authorized to do this action') diff --git a/app/controllers/concerns/auth_helper.rb b/app/controllers/concerns/auth_helper.rb index 2000276f0799d..f56be37ef898a 100644 --- a/app/controllers/concerns/auth_helper.rb +++ b/app/controllers/concerns/auth_helper.rb @@ -1,8 +1,8 @@ module AuthHelper def send_auth_headers(user) data = user.create_new_auth_token - response.headers[DeviseTokenAuth.headers_names[:"access-token"]] = data['access-token'] - response.headers[DeviseTokenAuth.headers_names[:"token-type"]] = 'Bearer' + response.headers[DeviseTokenAuth.headers_names[:'access-token']] = data['access-token'] + response.headers[DeviseTokenAuth.headers_names[:'token-type']] = 'Bearer' response.headers[DeviseTokenAuth.headers_names[:client]] = data['client'] response.headers[DeviseTokenAuth.headers_names[:expiry]] = data['expiry'] response.headers[DeviseTokenAuth.headers_names[:uid]] = data['uid'] diff --git a/app/controllers/public/api/v1/inboxes/messages_controller.rb b/app/controllers/public/api/v1/inboxes/messages_controller.rb index 65a21183a6504..68c0f5223e470 100644 --- a/app/controllers/public/api/v1/inboxes/messages_controller.rb +++ b/app/controllers/public/api/v1/inboxes/messages_controller.rb @@ -14,7 +14,7 @@ def create def update @message.update!(message_update_params) rescue StandardError => e - render json: { error: @contact.errors, message: e.message }.to_json, status: 500 + render json: { error: @contact.errors, message: e.message }.to_json, status: :internal_server_error end private diff --git a/app/controllers/swagger_controller.rb b/app/controllers/swagger_controller.rb index c5f8c0f5b18fe..23a87b75720dc 100644 --- a/app/controllers/swagger_controller.rb +++ b/app/controllers/swagger_controller.rb @@ -3,7 +3,7 @@ def respond if Rails.env.development? || Rails.env.test? render inline: File.read(Rails.root.join('swagger', derived_path)) else - head 404 + head :not_found end end diff --git a/app/jobs/contact_ip_lookup_job.rb b/app/jobs/contact_ip_lookup_job.rb index fe005a4fe1495..c8651a5c4fd1e 100644 --- a/app/jobs/contact_ip_lookup_job.rb +++ b/app/jobs/contact_ip_lookup_job.rb @@ -45,7 +45,7 @@ def ensure_look_up_db def setup_vendor_db base_url = 'https://download.maxmind.com/app/geoip_download' - source = URI.open("#{base_url}?edition_id=GeoLite2-City&suffix=tar.gz&license_key=#{ENV['IP_LOOKUP_API_KEY']}") + source = URI.parse("#{base_url}?edition_id=GeoLite2-City&suffix=tar.gz&license_key=#{ENV['IP_LOOKUP_API_KEY']}").open tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(source)) tar_extract.rewind diff --git a/app/jobs/hook_job.rb b/app/jobs/hook_job.rb index 46d10c464b8d1..57c2896a51fdf 100644 --- a/app/jobs/hook_job.rb +++ b/app/jobs/hook_job.rb @@ -9,7 +9,7 @@ def perform(hook, event_name, event_data = {}) process_dialogflow_integration(hook, event_name, event_data) end rescue StandardError => e - Raven.capture_exception(e) + Sentry.capture_exception(e) end private diff --git a/app/mailboxes/application_mailbox.rb b/app/mailboxes/application_mailbox.rb index fb3b451b039cb..5f61f5f7c358d 100644 --- a/app/mailboxes/application_mailbox.rb +++ b/app/mailboxes/application_mailbox.rb @@ -1,7 +1,7 @@ class ApplicationMailbox < ActionMailbox::Base # Last part is the regex for the UUID # Eg: email should be something like : reply+6bdc3f4d-0bec-4515-a284-5d916fdde489@domain.com - REPLY_EMAIL_USERNAME_PATTERN = /^reply\+([0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12})$/i.freeze + REPLY_EMAIL_USERNAME_PATTERN = /^reply\+([0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12})$/i def self.reply_mail? proc do |inbound_mail_obj| diff --git a/app/mailboxes/reply_mailbox.rb b/app/mailboxes/reply_mailbox.rb index f79a4421d2821..c74a9c887c63b 100644 --- a/app/mailboxes/reply_mailbox.rb +++ b/app/mailboxes/reply_mailbox.rb @@ -5,7 +5,7 @@ class ReplyMailbox < ApplicationMailbox # Last part is the regex for the UUID # Eg: email should be something like : reply+6bdc3f4d-0bec-4515-a284-5d916fdde489@domain.com - EMAIL_PART_PATTERN = /^reply\+([0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12})$/i.freeze + EMAIL_PART_PATTERN = /^reply\+([0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12})$/i before_processing :conversation_uuid_from_to_address, :verify_decoded_params, diff --git a/app/models/channel/facebook_page.rb b/app/models/channel/facebook_page.rb index 8c0ba1b9c01de..ade13990e762f 100644 --- a/app/models/channel/facebook_page.rb +++ b/app/models/channel/facebook_page.rb @@ -47,14 +47,14 @@ def subscribe ] ) rescue => e - Rails.logger.debug "Rescued: #{e.inspect}" + Rails.logger.debug { "Rescued: #{e.inspect}" } true end def unsubscribe Facebook::Messenger::Subscriptions.unsubscribe(access_token: page_access_token) rescue => e - Rails.logger.debug "Rescued: #{e.inspect}" + Rails.logger.debug { "Rescued: #{e.inspect}" } true end end diff --git a/app/models/concerns/content_attribute_validator.rb b/app/models/concerns/content_attribute_validator.rb index 868dffa4c8913..bad93c9137b29 100644 --- a/app/models/concerns/content_attribute_validator.rb +++ b/app/models/concerns/content_attribute_validator.rb @@ -31,7 +31,7 @@ def validate_items!(record) end def validate_item_attributes!(record, valid_keys) - item_keys = record.items.collect(&:keys).flatten.map(&:to_sym).compact + item_keys = record.items.collect(&:keys).flatten.filter_map(&:to_sym) invalid_keys = item_keys - valid_keys record.errors.add(:content_attributes, "contains invalid keys for items : #{invalid_keys}") if invalid_keys.present? end diff --git a/app/models/integrations/app.rb b/app/models/integrations/app.rb index 149a305b36572..7861cc5c826ee 100644 --- a/app/models/integrations/app.rb +++ b/app/models/integrations/app.rb @@ -38,8 +38,6 @@ def active? case params[:id] when 'slack' ENV['SLACK_CLIENT_SECRET'].present? - when 'dialogflow', 'fullcontact' - true else true end diff --git a/app/models/message.rb b/app/models/message.rb index f9c473dbe900e..740e0c91cb816 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -105,7 +105,7 @@ def push_event_data def merge_sender_attributes(data) data.merge!(sender: sender.push_event_data) if sender && !sender.is_a?(AgentBot) - data.merge!(sender: sender.push_event_data(inbox)) if sender&.is_a?(AgentBot) + data.merge!(sender: sender.push_event_data(inbox)) if sender.is_a?(AgentBot) data end @@ -142,7 +142,7 @@ def execute_after_create_commit_callbacks end def update_contact_activity - sender.update(last_activity_at: DateTime.now) if sender&.is_a?(Contact) + sender.update(last_activity_at: DateTime.now) if sender.is_a?(Contact) end def dispatch_create_events diff --git a/app/presenters/mail_presenter.rb b/app/presenters/mail_presenter.rb index ce8433151c72e..9d2bfa1c1e7f6 100644 --- a/app/presenters/mail_presenter.rb +++ b/app/presenters/mail_presenter.rb @@ -38,7 +38,7 @@ def html_content def attachments # ref : https://github.com/gorails-screencasts/action-mailbox-action-text/blob/master/app/mailboxes/posts_mailbox.rb mail.attachments.map do |attachment| - blob = ActiveStorage::Blob.create_after_upload!( + blob = ActiveStorage::Blob.create_and_upload!( io: StringIO.new(attachment.body.to_s), filename: attachment.filename, content_type: attachment.content_type diff --git a/app/services/contacts/contactable_inboxes_service.rb b/app/services/contacts/contactable_inboxes_service.rb index b40e6cee7bcf3..1950b190c5104 100644 --- a/app/services/contacts/contactable_inboxes_service.rb +++ b/app/services/contacts/contactable_inboxes_service.rb @@ -3,7 +3,7 @@ class Contacts::ContactableInboxesService def get account = contact.account - account.inboxes.map { |inbox| get_contactable_inbox(inbox) }.compact + account.inboxes.filter_map { |inbox| get_contactable_inbox(inbox) } end private diff --git a/app/services/message_templates/template/email_collect.rb b/app/services/message_templates/template/email_collect.rb index 667b6b6cd1889..ba49a6c56c6fa 100644 --- a/app/services/message_templates/template/email_collect.rb +++ b/app/services/message_templates/template/email_collect.rb @@ -7,7 +7,7 @@ def perform conversation.messages.create!(email_input_box_template_message_params) end rescue StandardError => e - Raven.capture_exception(e) + Sentry.capture_exception(e) true end diff --git a/app/services/message_templates/template/greeting.rb b/app/services/message_templates/template/greeting.rb index 6b857efa6f9c9..11388ae7d0a29 100644 --- a/app/services/message_templates/template/greeting.rb +++ b/app/services/message_templates/template/greeting.rb @@ -6,7 +6,7 @@ def perform conversation.messages.create!(greeting_message_params) end rescue StandardError => e - Raven.capture_exception(e) + Sentry.capture_exception(e) true end diff --git a/app/services/message_templates/template/out_of_office.rb b/app/services/message_templates/template/out_of_office.rb index eb0a19c7f6e70..f208f72841b54 100644 --- a/app/services/message_templates/template/out_of_office.rb +++ b/app/services/message_templates/template/out_of_office.rb @@ -6,7 +6,7 @@ def perform conversation.messages.create!(out_of_office_message_params) end rescue StandardError => e - Raven.capture_exception(e) + Sentry.capture_exception(e) true end diff --git a/app/views/api/v2/accounts/reports/agents.csv.erb b/app/views/api/v2/accounts/reports/agents.csv.erb index ca0a7e1f472cf..6738fe51bbf95 100644 --- a/app/views/api/v2/accounts/reports/agents.csv.erb +++ b/app/views/api/v2/accounts/reports/agents.csv.erb @@ -16,4 +16,4 @@ <% row = [ agent.name, agent_report[:conversations_count], (agent_report[:avg_first_response_time]/60).to_i, (agent_report[:avg_resolution_time]/60).to_i ] %> <%= CSV.generate_line row %> <% end %> -<%= CSV.generate_line [I18n.t('reports.period', { since: Date.strptime(params[:since], '%s'), until: Date.strptime(params[:until], '%s') })] %> +<%= CSV.generate_line [I18n.t('reports.period', since: Date.strptime(params[:since], '%s'), until: Date.strptime(params[:until], '%s'))] %> diff --git a/config/application.rb b/config/application.rb index fc74dcf52cf30..074a2f7443bdc 100644 --- a/config/application.rb +++ b/config/application.rb @@ -15,11 +15,6 @@ class Application < Rails::Application config.autoload_paths << Rails.root.join('lib') config.eager_load_paths << Rails.root.join('lib') - Rails.autoloaders.main.ignore(Rails.root.join('lib/azure')) - - # This is required in production for zeitwerk to autoload the file - config.paths.add File.join('app', 'bot'), glob: File.join('**', '*.rb') - config.autoload_paths << Rails.root.join('app/bot/*') # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers diff --git a/config/initializers/active_record_query_trace.rb b/config/initializers/active_record_query_trace.rb new file mode 100644 index 0000000000000..fbe10cd089137 --- /dev/null +++ b/config/initializers/active_record_query_trace.rb @@ -0,0 +1 @@ +ActiveRecordQueryTrace.enabled = true if Rails.env.development? diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 9ac37c73130e8..e6a0ab96a0833 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -16,4 +16,5 @@ # to take care of fonts in assets pre-compiling # Ref: https://stackoverflow.com/questions/56960709/rails-font-cors-policy -Rails.application.config.assets.precompile << /\.(?:svg|eot|woff|ttf|woff2)$/ +# https://github.com/rails/sprockets/issues/632#issuecomment-551324428 +Rails.application.config.assets.precompile << ['*.svg', '*.eot', '*.woff', '*.ttf'] diff --git a/config/initializers/azure_storage_service_patch.rb b/config/initializers/azure_storage_service_patch.rb deleted file mode 100644 index 82a0cbd14a752..0000000000000 --- a/config/initializers/azure_storage_service_patch.rb +++ /dev/null @@ -1,170 +0,0 @@ -# TODO: Remove this once the changes comes into rails version -# https://github.com/Azure/azure-storage-ruby/issues/166#issuecomment-637696565 -# Remove this once the changes comes into rails version - -# code from current master : https://github.com/rails/rails/blob/8520cc77133d9ff642e2c393b4ee5eae2a2a28b6/activestorage/lib/active_storage/service/azure_storage_service.rb - -require 'azure/storage/blob' -require 'active_storage/service/azure_storage_service' -module ActiveStorage - # Wraps the Microsoft Azure Storage Blob Service as an Active Storage service. - # See ActiveStorage::Service for the generic API documentation that applies to all services. - class Service::AzureStorageService < Service - attr_reader :client, :container, :signer - - def initialize(storage_account_name:, storage_access_key:, container:, public: false, **options) - @client = Azure::Storage::Blob::BlobService.create(storage_account_name: storage_account_name, storage_access_key: storage_access_key, **options) - @signer = Azure::Storage::Common::Core::Auth::SharedAccessSignature.new(storage_account_name, storage_access_key) - @container = container - @public = public - end - - def upload(key, io, checksum: nil, filename: nil, content_type: nil, disposition: nil, **) - instrument :upload, key: key, checksum: checksum do - handle_errors do - content_disposition = content_disposition_with(filename: filename, type: disposition) if disposition && filename - - client.create_block_blob(container, key, IO.try_convert(io) || io, content_md5: checksum, content_type: content_type, content_disposition: content_disposition) - end - end - end - - def download(key, &block) - if block_given? - instrument :streaming_download, key: key do - stream(key, &block) - end - else - instrument :download, key: key do - handle_errors do - _, io = client.get_blob(container, key) - io.force_encoding(Encoding::BINARY) - end - end - end - end - - def download_chunk(key, range) - instrument :download_chunk, key: key, range: range do - handle_errors do - _, io = client.get_blob(container, key, start_range: range.begin, end_range: range.exclude_end? ? range.end - 1 : range.end) - io.force_encoding(Encoding::BINARY) - end - end - end - - def delete(key) - instrument :delete, key: key do - client.delete_blob(container, key) - rescue Azure::Core::Http::HTTPError => e - raise unless e.type == "BlobNotFound" - # Ignore files already deleted - end - end - - def delete_prefixed(prefix) - instrument :delete_prefixed, prefix: prefix do - marker = nil - - loop do - results = client.list_blobs(container, prefix: prefix, marker: marker) - - results.each do |blob| - client.delete_blob(container, blob.name) - end - - break unless marker = results.continuation_token.presence - end - end - end - - def exist?(key) - instrument :exist, key: key do |payload| - answer = blob_for(key).present? - payload[:exist] = answer - answer - end - end - - def url_for_direct_upload(key, expires_in:, content_type:, content_length:, checksum:) - instrument :url, key: key do |payload| - generated_url = signer.signed_uri( - uri_for(key), false, - service: "b", - permissions: "rw", - expiry: format_expiry(expires_in) - ).to_s - - payload[:url] = generated_url - - generated_url - end - end - - def headers_for_direct_upload(key, content_type:, checksum:, filename: nil, disposition: nil, **) - content_disposition = content_disposition_with(type: disposition, filename: filename) if filename - - { "Content-Type" => content_type, "Content-MD5" => checksum, "x-ms-blob-content-disposition" => content_disposition, "x-ms-blob-type" => "BlockBlob" } - end - - private - def private_url(key, expires_in:, filename:, disposition:, content_type:, **) - signer.signed_uri( - uri_for(key), false, - service: "b", - permissions: "r", - expiry: format_expiry(expires_in), - content_disposition: content_disposition_with(type: disposition, filename: filename), - content_type: content_type - ).to_s - end - - def public_url(key, **) - uri_for(key).to_s - end - - - def uri_for(key) - client.generate_uri("#{container}/#{key}") - end - - def blob_for(key) - client.get_blob_properties(container, key) - rescue Azure::Core::Http::HTTPError - false - end - - def format_expiry(expires_in) - expires_in ? Time.now.utc.advance(seconds: expires_in).iso8601 : nil - end - - # Reads the object for the given key in chunks, yielding each to the block. - def stream(key) - blob = blob_for(key) - - chunk_size = 5.megabytes - offset = 0 - - raise ActiveStorage::FileNotFoundError unless blob.present? - - while offset < blob.properties[:content_length] - _, chunk = client.get_blob(container, key, start_range: offset, end_range: offset + chunk_size - 1) - yield chunk.force_encoding(Encoding::BINARY) - offset += chunk_size - end - end - - def handle_errors - yield - rescue Azure::Core::Http::HTTPError => e - case e.type - when "BlobNotFound" - raise ActiveStorage::FileNotFoundError - when "Md5Mismatch" - raise ActiveStorage::IntegrityError - else - raise - end - end - end -end \ No newline at end of file diff --git a/config/initializers/bot.rb b/config/initializers/bot.rb deleted file mode 100644 index 00ef3a0ac3075..0000000000000 --- a/config/initializers/bot.rb +++ /dev/null @@ -1,41 +0,0 @@ -# Remember that Rails only eager loads everything in its production environment. -# In the development and test environments, it only requires files as you reference constants. -# You'll need to explicitly load app/bot - -unless Rails.env.production? - bot_files = Dir[Rails.root.join('app', 'bot', '**', '*.rb')] - bot_reloader = ActiveSupport::FileUpdateChecker.new(bot_files) do - bot_files.each { |file| require_dependency file } - end - - ActiveSupport::Reloader.to_prepare do - bot_reloader.execute_if_updated - end - - bot_files.each { |file| require_dependency file } -end - -# ref: https://github.com/jgorset/facebook-messenger#make-a-configuration-provider -class ChatwootFbProvider < Facebook::Messenger::Configuration::Providers::Base - def valid_verify_token?(_verify_token) - ENV['FB_VERIFY_TOKEN'] - end - - def app_secret_for(_page_id) - ENV['FB_APP_SECRET'] - end - - def access_token_for(page_id) - Channel::FacebookPage.where(page_id: page_id).last.page_access_token - end - - private - - def bot - Chatwoot::Bot - end -end - -Facebook::Messenger.configure do |config| - config.provider = ChatwootFbProvider.new -end diff --git a/app/bot/facebook_bot.rb b/config/initializers/facebook_messenger.rb similarity index 62% rename from app/bot/facebook_bot.rb rename to config/initializers/facebook_messenger.rb index c13cf12edc90e..f4f80a457f4ef 100644 --- a/app/bot/facebook_bot.rb +++ b/config/initializers/facebook_messenger.rb @@ -1,6 +1,29 @@ -require 'facebook/messenger' +# ref: https://github.com/jgorset/facebook-messenger#make-a-configuration-provider +class ChatwootFbProvider < Facebook::Messenger::Configuration::Providers::Base + def valid_verify_token?(_verify_token) + ENV['FB_VERIFY_TOKEN'] + end + + def app_secret_for(_page_id) + ENV['FB_APP_SECRET'] + end + + def access_token_for(page_id) + Channel::FacebookPage.where(page_id: page_id).last.page_access_token + end + + private + + def bot + Chatwoot::Bot + end +end + +Rails.application.reloader.to_prepare do + Facebook::Messenger.configure do |config| + config.provider = ChatwootFbProvider.new + end -class FacebookBot Facebook::Messenger::Bot.on :message do |message| Rails.logger.info "MESSAGE_RECIEVED #{message}" response = ::Integrations::Facebook::MessageParser.new(message) diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index 1237c47b5c426..bfa2914c58a9e 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -1,28 +1,4 @@ -Raven.configure do |config| +Sentry.init do |config| config.dsn = ENV['SENTRY_DSN'] - config.environments = %w[staging production] + config.enabled_environments = %w[staging production] end - -module QueryTrace - def self.enable! - ::ActiveRecord::LogSubscriber.send(:include, self) - end - - def self.append_features(klass) - super - klass.class_eval do - unless method_defined?(:log_info_without_trace) - alias_method :log_info_without_trace, :sql - alias_method :sql, :log_info_with_trace - end - end - end - - def log_info_with_trace(event) - log_info_without_trace(event) - trace_log = Rails.backtrace_cleaner.clean(caller).first - logger.debug(" \\_ \e[33mCalled from:\e[0m #{trace_log}") if trace_log && event.payload[:name] != 'SCHEMA' - end -end - -QueryTrace.enable! unless Rails.env.production? diff --git a/db/migrate/20200418124534_add_sender_to_messages.rb b/db/migrate/20200418124534_add_sender_to_messages.rb index 02efdc4a51ac3..a28160e1a1684 100644 --- a/db/migrate/20200418124534_add_sender_to_messages.rb +++ b/db/migrate/20200418124534_add_sender_to_messages.rb @@ -15,9 +15,7 @@ def add_sender_from_message # rubocop:disable Rails/SkipsModelValidations message.update_columns(sender_id: message.user.id, sender_type: 'User') if message.user.present? message.update_columns(sender_id: message.contact.id, sender_type: 'Contact') if message.contact.present? - if message.sender.nil? - message.update_columns(sender_id: message.conversation.contact.id, sender_type: 'Contact') if message.incoming? - end + message.update_columns(sender_id: message.conversation.contact.id, sender_type: 'Contact') if message.sender.nil? && message.incoming? # rubocop:enable Rails/SkipsModelValidations end end diff --git a/db/migrate/20210611180221_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20210611180221_add_service_name_to_active_storage_blobs.active_storage.rb new file mode 100644 index 0000000000000..9967a1323707f --- /dev/null +++ b/db/migrate/20210611180221_add_service_name_to_active_storage_blobs.active_storage.rb @@ -0,0 +1,18 @@ +# This migration comes from active_storage (originally 20190112182829) +class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] + def up + unless column_exists?(:active_storage_blobs, :service_name) + add_column :active_storage_blobs, :service_name, :string + + if configured_service = ActiveStorage::Blob.service.name + ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) + end + + change_column :active_storage_blobs, :service_name, :string, null: false + end + end + + def down + remove_column :active_storage_blobs, :service_name + end +end diff --git a/db/migrate/20210611180222_create_active_storage_variant_records.active_storage.rb b/db/migrate/20210611180222_create_active_storage_variant_records.active_storage.rb new file mode 100644 index 0000000000000..71b27d1c1cfbd --- /dev/null +++ b/db/migrate/20210611180222_create_active_storage_variant_records.active_storage.rb @@ -0,0 +1,12 @@ +# This migration comes from active_storage (originally 20191206030411) +class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] + def change + create_table :active_storage_variant_records do |t| + t.belongs_to :blob, null: false, index: false + t.string :variation_digest, null: false + + t.index %i[blob_id variation_digest], name: 'index_active_storage_variant_records_uniqueness', unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 77cf9d447eb37..238120369eebf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2,8 +2,8 @@ # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# This file is the source Rails uses to define your schema when running `rails -# db:schema:load`. When creating a new database, `rails db:schema:load` tends to +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to # be faster and is potentially less error prone than running all of your # migrations from scratch. Old migrations may fail to apply correctly if those # migrations use external dependencies or application code. @@ -79,9 +79,16 @@ t.bigint "byte_size", null: false t.string "checksum", null: false t.datetime "created_at", null: false + t.string "service_name", null: false t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true end + create_table "active_storage_variant_records", force: :cascade do |t| + t.bigint "blob_id", null: false + t.string "variation_digest", null: false + t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true + end + create_table "agent_bot_inboxes", force: :cascade do |t| t.integer "inbox_id" t.integer "agent_bot_id" @@ -685,6 +692,7 @@ add_foreign_key "account_users", "accounts" add_foreign_key "account_users", "users" add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" + add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" add_foreign_key "agent_bots", "accounts" add_foreign_key "campaigns", "accounts" add_foreign_key "campaigns", "inboxes" diff --git a/deployment/chatwoot-web.1.service b/deployment/chatwoot-web.1.service index 1e55b55bb7a2b..40f64b56321e5 100644 --- a/deployment/chatwoot-web.1.service +++ b/deployment/chatwoot-web.1.service @@ -16,10 +16,10 @@ KillMode=mixed StandardInput=null SyslogIdentifier=%p -Environment="PATH=/home/chatwoot/.rvm/gems/ruby-2.7.3/bin:/home/chatwoot/.rvm/gems/ruby-2.7.3@global/bin:/home/chatwoot/.rvm/rubies/ruby-2.7.3/bin:/home/chatwoot/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/chatwoot/.rvm/bin:/home/chatwoot/.rvm/bin" +Environment="PATH=/home/chatwoot/.rvm/gems/ruby-3.0.2/bin:/home/chatwoot/.rvm/gems/ruby-3.0.2@global/bin:/home/chatwoot/.rvm/rubies/ruby-3.0.2/bin:/home/chatwoot/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/chatwoot/.rvm/bin:/home/chatwoot/.rvm/bin" Environment="PORT=3000" Environment="RAILS_ENV=production" Environment="NODE_ENV=production" Environment="RAILS_LOG_TO_STDOUT=true" -Environment="GEM_HOME=/home/chatwoot/.rvm/gems/ruby-2.7.3" -Environment="GEM_PATH=/home/chatwoot/.rvm/gems/ruby-2.7.3:/home/chatwoot/.rvm/gems/ruby-2.7.3@global" +Environment="GEM_HOME=/home/chatwoot/.rvm/gems/ruby-3.0.2" +Environment="GEM_PATH=/home/chatwoot/.rvm/gems/ruby-3.0.2:/home/chatwoot/.rvm/gems/ruby-3.0.2@global" diff --git a/deployment/chatwoot-worker.1.service b/deployment/chatwoot-worker.1.service index 98cdf357a31df..fa13898c07aaf 100644 --- a/deployment/chatwoot-worker.1.service +++ b/deployment/chatwoot-worker.1.service @@ -16,10 +16,10 @@ KillMode=mixed StandardInput=null SyslogIdentifier=%p -Environment="PATH=/home/chatwoot/.rvm/gems/ruby-2.7.3/bin:/home/chatwoot/.rvm/gems/ruby-2.7.3@global/bin:/home/chatwoot/.rvm/rubies/ruby-2.7.3/bin:/home/chatwoot/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/chatwoot/.rvm/bin:/home/chatwoot/.rvm/bin" +Environment="PATH=/home/chatwoot/.rvm/gems/ruby-3.0.2/bin:/home/chatwoot/.rvm/gems/ruby-3.0.2@global/bin:/home/chatwoot/.rvm/rubies/ruby-3.0.2/bin:/home/chatwoot/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/chatwoot/.rvm/bin:/home/chatwoot/.rvm/bin" Environment="PORT=3000" Environment="RAILS_ENV=production" Environment="NODE_ENV=production" Environment="RAILS_LOG_TO_STDOUT=true" -Environment="GEM_HOME=/home/chatwoot/.rvm/gems/ruby-2.7.3" -Environment="GEM_PATH=/home/chatwoot/.rvm/gems/ruby-2.7.3:/home/chatwoot/.rvm/gems/ruby-2.7.3@global" +Environment="GEM_HOME=/home/chatwoot/.rvm/gems/ruby-3.0.2" +Environment="GEM_PATH=/home/chatwoot/.rvm/gems/ruby-3.0.2:/home/chatwoot/.rvm/gems/ruby-3.0.2@global" diff --git a/deployment/setup_18.04.sh b/deployment/setup_18.04.sh index fb2184f190b70..610cef22bc9c7 100644 --- a/deployment/setup_18.04.sh +++ b/deployment/setup_18.04.sh @@ -43,8 +43,8 @@ RAILS_ENV=production sudo -i -u chatwoot << EOF rvm --version rvm autolibs disable -rvm install "ruby-2.7.3" -rvm use 2.7.3 --default +rvm install "ruby-3.0.2" +rvm use 3.0.2 --default git clone https://github.com/chatwoot/chatwoot.git cd chatwoot diff --git a/deployment/setup_20.04.sh b/deployment/setup_20.04.sh index 384ffdda06cf5..7dcace44de110 100644 --- a/deployment/setup_20.04.sh +++ b/deployment/setup_20.04.sh @@ -50,8 +50,8 @@ RAILS_ENV=production sudo -i -u chatwoot << EOF rvm --version rvm autolibs disable -rvm install "ruby-2.7.3" -rvm use 2.7.3 --default +rvm install "ruby-3.0.2" +rvm use 3.0.2 --default git clone https://github.com/chatwoot/chatwoot.git cd chatwoot diff --git a/docker/Dockerfile b/docker/Dockerfile index 7eebf35a572f6..daa0dcf5b8df4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,5 @@ # pre-build stage -FROM ruby:2.7.3-alpine AS pre-builder +FROM ruby:3.0.2-alpine AS pre-builder # ARG default to production settings # For development docker-compose file overrides ARGS @@ -51,7 +51,7 @@ RUN if [ "$RAILS_ENV" = "production" ]; then \ fi # final build stage -FROM ruby:2.7.3-alpine +FROM ruby:3.0.2-alpine ARG BUNDLE_WITHOUT="development:test" ENV BUNDLE_WITHOUT ${BUNDLE_WITHOUT} @@ -83,9 +83,9 @@ COPY --from=pre-builder /gems/ /gems/ COPY --from=pre-builder /app /app # Remove unnecessary files -RUN rm -rf /gems/ruby/2.7.0/cache/*.gem \ - && find /gems/ruby/2.7.0/gems/ -name "*.c" -delete \ - && find /gems/ruby/2.7.0/gems/ -name "*.o" -delete +RUN rm -rf /gems/ruby/3.0.2/cache/*.gem \ + && find /gems/ruby/3.0.2/gems/ -name "*.c" -delete \ + && find /gems/ruby/3.0.2/gems/ -name "*.o" -delete # creating a log directory so that image wont fail when RAILS_LOG_TO_STDOUT is false # https://github.com/chatwoot/chatwoot/issues/701 diff --git a/lib/azure/storage.rb b/lib/azure/storage.rb deleted file mode 100644 index f0bb9129a2825..0000000000000 --- a/lib/azure/storage.rb +++ /dev/null @@ -1,2 +0,0 @@ -# https://github.com/Azure/azure-storage-ruby/issues/166#issuecomment-637696565 -# Remove this once the changes comes into rails diff --git a/lib/azure/storage/core/auth/shared_access_signature.rb b/lib/azure/storage/core/auth/shared_access_signature.rb deleted file mode 100644 index ba10b61c03bc4..0000000000000 --- a/lib/azure/storage/core/auth/shared_access_signature.rb +++ /dev/null @@ -1,2 +0,0 @@ -# TODO: Remove this once the changes comes into rails version -# https://github.com/Azure/azure-storage-ruby/issues/166#issuecomment-637696565 diff --git a/lib/chatwoot_hub.rb b/lib/chatwoot_hub.rb index 2de8f5d30e762..e98a6b86ef5fc 100644 --- a/lib/chatwoot_hub.rb +++ b/lib/chatwoot_hub.rb @@ -39,7 +39,7 @@ def self.latest_version rescue *ExceptionList::REST_CLIENT_EXCEPTIONS, *ExceptionList::URI_EXCEPTIONS => e Rails.logger.info "Exception: #{e.message}" rescue StandardError => e - Raven.capture_exception(e) + Sentry.capture_exception(e) end version end @@ -61,6 +61,6 @@ def self.emit_event(event_name, event_data) rescue *ExceptionList::REST_CLIENT_EXCEPTIONS, *ExceptionList::URI_EXCEPTIONS => e Rails.logger.info "Exception: #{e.message}" rescue StandardError => e - Raven.capture_exception(e) + Sentry.capture_exception(e) end end diff --git a/lib/exception_list.rb b/lib/exception_list.rb index 3909e4e2206b5..513dd53650c2b 100644 --- a/lib/exception_list.rb +++ b/lib/exception_list.rb @@ -1,5 +1,5 @@ module ExceptionList - URI_EXCEPTIONS = [Errno::ETIMEDOUT, Errno::ECONNREFUSED, URI::InvalidURIError, Net::OpenTimeout, SocketError, OpenURI::HTTPError].freeze + URI_EXCEPTIONS = [Errno::ETIMEDOUT, Errno::ECONNREFUSED, URI::InvalidURIError, Net::OpenTimeout, SocketError].freeze REST_CLIENT_EXCEPTIONS = [RestClient::NotFound, RestClient::GatewayTimeout, RestClient::BadRequest, RestClient::MethodNotAllowed, RestClient::Forbidden, RestClient::InternalServerError, RestClient::PayloadTooLarge].freeze SMTP_EXCEPTIONS = [ diff --git a/lib/integrations/facebook/message_creator.rb b/lib/integrations/facebook/message_creator.rb index 09d9526fed53b..a77c4d805f6e8 100644 --- a/lib/integrations/facebook/message_creator.rb +++ b/lib/integrations/facebook/message_creator.rb @@ -15,7 +15,7 @@ def perform create_contact_message end # rescue => e - # Raven.capture_exception(e) + # Sentry.capture_exception(e) # end end diff --git a/lib/webhooks/trigger.rb b/lib/webhooks/trigger.rb index 8bbaa05a4b140..fa90f30937a41 100644 --- a/lib/webhooks/trigger.rb +++ b/lib/webhooks/trigger.rb @@ -9,6 +9,6 @@ def self.execute(url, payload) rescue *ExceptionList::REST_CLIENT_EXCEPTIONS, *ExceptionList::URI_EXCEPTIONS => e Rails.logger.info "Exception: invalid webhook url #{url} : #{e.message}" rescue StandardError => e - Raven.capture_exception(e) + Sentry.capture_exception(e) end end diff --git a/lib/woot_message_seeder.rb b/lib/woot_message_seeder.rb index 5dc3aee480c7e..2e38868d8096f 100644 --- a/lib/woot_message_seeder.rb +++ b/lib/woot_message_seeder.rb @@ -91,15 +91,15 @@ def self.create_sample_form_message(conversation) def self.sample_form { - "items": [ - { "name": 'email', "placeholder": 'Please enter your email', "type": 'email', "label": 'Email', "required": 'required', - "pattern_error": 'Please fill this field', "pattern": '^[^\s@]+@[^\s@]+\.[^\s@]+$' }, - { "name": 'text_area', "placeholder": 'Please enter text', "type": 'text_area', "label": 'Large Text', "required": 'required', - "pattern_error": 'Please fill this field' }, - { "name": 'text', "placeholder": 'Please enter text', "type": 'text', "label": 'text', "default": 'defaut value', "required": 'required', - "pattern": '^[a-zA-Z ]*$', "pattern_error": 'Only alphabets are allowed' }, - { "name": 'select', "label": 'Select Option', "type": 'select', "options": [{ "label": '🌯 Burito', "value": 'Burito' }, - { "label": '🍝 Pasta', "value": 'Pasta' }] } + items: [ + { name: 'email', placeholder: 'Please enter your email', type: 'email', label: 'Email', required: 'required', + pattern_error: 'Please fill this field', pattern: '^[^\s@]+@[^\s@]+\.[^\s@]+$' }, + { name: 'text_area', placeholder: 'Please enter text', type: 'text_area', label: 'Large Text', required: 'required', + pattern_error: 'Please fill this field' }, + { name: 'text', placeholder: 'Please enter text', type: 'text', label: 'text', default: 'defaut value', required: 'required', + pattern: '^[a-zA-Z ]*$', pattern_error: 'Only alphabets are allowed' }, + { name: 'select', label: 'Select Option', type: 'select', options: [{ label: '🌯 Burito', value: 'Burito' }, + { label: '🍝 Pasta', value: 'Pasta' }] } ] } end diff --git a/spec/actions/contact_merge_action_spec.rb b/spec/actions/contact_merge_action_spec.rb index b87644a92ce51..62ff81a5242a4 100644 --- a/spec/actions/contact_merge_action_spec.rb +++ b/spec/actions/contact_merge_action_spec.rb @@ -8,9 +8,11 @@ let!(:mergee_contact) { create(:contact, account: account) } before do - 2.times.each { create(:conversation, contact: base_contact) } - 2.times.each { create(:conversation, contact: mergee_contact) } - 2.times.each { create(:message, sender: mergee_contact) } + 2.times.each do + create(:conversation, contact: base_contact) + create(:conversation, contact: mergee_contact) + create(:message, sender: mergee_contact) + end end describe '#perform' do diff --git a/spec/controllers/api/v1/accounts/contacts/conversations_controller_spec.rb b/spec/controllers/api/v1/accounts/contacts/conversations_controller_spec.rb index 54759d9d14aa8..489ac60a4c5ac 100644 --- a/spec/controllers/api/v1/accounts/contacts/conversations_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/contacts/conversations_controller_spec.rb @@ -13,8 +13,10 @@ before do create(:inbox_member, user: agent, inbox: inbox_1) - 2.times.each { create(:conversation, account: account, inbox: inbox_1, contact: contact, contact_inbox: contact_inbox_1) } - 2.times.each { create(:conversation, account: account, inbox: inbox_2, contact: contact, contact_inbox: contact_inbox_2) } + 2.times.each do + create(:conversation, account: account, inbox: inbox_1, contact: contact, contact_inbox: contact_inbox_1) + create(:conversation, account: account, inbox: inbox_2, contact: contact, contact_inbox: contact_inbox_2) + end end describe 'GET /api/v1/accounts/{account.id}/contacts/:id/conversations' do diff --git a/spec/controllers/public/api/v1/csat_survey_controller.spec.rb b/spec/controllers/public/api/v1/csat_survey_controller_spec.rb similarity index 100% rename from spec/controllers/public/api/v1/csat_survey_controller.spec.rb rename to spec/controllers/public/api/v1/csat_survey_controller_spec.rb diff --git a/spec/factories/integrations/hooks.rb b/spec/factories/integrations/hooks.rb index ac7c36fbc8cff..598d68c11eed6 100644 --- a/spec/factories/integrations/hooks.rb +++ b/spec/factories/integrations/hooks.rb @@ -3,7 +3,7 @@ app_id { 'slack' } inbox account - settings { { 'test': 'test' } } + settings { { test: 'test' } } status { Integrations::Hook.statuses['enabled'] } access_token { SecureRandom.hex } reference_id { SecureRandom.hex } diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 4c8b38e254e98..517f336a093fe 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -23,7 +23,7 @@ # require only the support files necessary. # # rubocop:disable Rails/FilePath -Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } +Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f } # rubocop:enable Rails/FilePath # Checks for pending migrations and applies them before tests are run. @@ -79,4 +79,5 @@ # Required for fixture_file_upload FactoryBot::SyntaxRunner.class_eval do include ActionDispatch::TestProcess + include ActiveSupport::Testing::FileFixtures end diff --git a/spec/support/slack_stubs.rb b/spec/support/slack_stubs.rb index 28a25ba547ac1..d0e89221b301b 100644 --- a/spec/support/slack_stubs.rb +++ b/spec/support/slack_stubs.rb @@ -1,75 +1,76 @@ module SlackStubs def slack_url_verification_stub { - "token": 'Jhj5dZrVaK7ZwHHjRyZWjbDl', - "challenge": '3eZbrw1aBm2rZgRNFdxV2595E9CY3gmdALWMmHkvFXO7tYXAYM8P', - "type": 'url_verification' + token: 'Jhj5dZrVaK7ZwHHjRyZWjbDl', + challenge: '3eZbrw1aBm2rZgRNFdxV2595E9CY3gmdALWMmHkvFXO7tYXAYM8P', + type: 'url_verification' } end def slack_message_stub { - "token": '[FILTERED]', - "team_id": 'TLST3048H', - "api_app_id": 'A012S5UETV4', - "event": message_event, - "type": 'event_callback', - "event_id": 'Ev013QUX3WV6', - "event_time": 1_588_623_033, - "authed_users": '[FILTERED]', - "webhook": {} + token: '[FILTERED]', + team_id: 'TLST3048H', + api_app_id: 'A012S5UETV4', + event: message_event, + type: 'event_callback', + event_id: 'Ev013QUX3WV6', + event_time: 1_588_623_033, + authed_users: '[FILTERED]', + webhook: {} } end def slack_message_stub_without_thread_ts { - "token": '[FILTERED]', - "team_id": '', - "api_app_id": '', - "event": { - "type": 'message', - "client_msg_id": 'ffc6e64e-6f0c-4a3d-b594-faa6b44e48ab', - "text": 'this is test', - "user": 'ULYPAKE5S', - "ts": '1588623033.006000', - "team": 'TLST3048H' + token: '[FILTERED]', + team_id: '', + api_app_id: '', + event: { + type: 'message', + client_msg_id: 'ffc6e64e-6f0c-4a3d-b594-faa6b44e48ab', + text: 'this is test', + user: 'ULYPAKE5S', + ts: '1588623033.006000', + team: 'TLST3048H' }, - "type": 'event_callback', - "event_id": '', - "event_time": 1_588_623_033, - "authed_users": '[FILTERED]', - "webhook": {} + type: 'event_callback', + event_id: '', + event_time: 1_588_623_033, + authed_users: '[FILTERED]', + webhook: {} } end def message_event { - "client_msg_id": 'ffc6e64e-6f0c-4a3d-b594-faa6b44e48ab', - "type": 'message', - "text": 'this is test Hey <@U019KT237LP|Sojan> Test again', - "user": 'ULYPAKE5S', - "ts": '1588623033.006000', - "team": 'TLST3048H', - "blocks": message_blocks, - "thread_ts": '1588623023.005900', - "channel": 'G01354F6A6Q', - "event_ts": '1588623033.006000', - "channel_type": 'group' + + client_msg_id: 'ffc6e64e-6f0c-4a3d-b594-faa6b44e48ab', + type: 'message', + text: 'this is test Hey <@U019KT237LP|Sojan> Test again', + user: 'ULYPAKE5S', + ts: '1588623033.006000', + team: 'TLST3048H', + blocks: message_blocks, + thread_ts: '1588623023.005900', + channel: 'G01354F6A6Q', + event_ts: '1588623033.006000', + channel_type: 'group' } end def message_blocks [ { - "type": 'rich_text', - "block_id": 'jaIv3', - "elements": [ + type: 'rich_text', + block_id: 'jaIv3', + elements: [ { - "type": 'rich_text_section', - "elements": [ + type: 'rich_text_section', + elements: [ { - "type": 'text', - "text": 'this is test' + type: 'text', + text: 'this is test' } ] }