From 52194116b3f3f0c287656ce222eba30b69b29ec7 Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Mon, 19 Aug 2019 01:19:57 -0700 Subject: [PATCH] =?UTF-8?q?Upgrade=20to=20rails=206=20=F0=9F=92=8E=20(#11)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - upgraded to rails 6 - fixes various issues --- .ruby-version | 2 +- Gemfile | 29 +- Gemfile.lock | 552 ++++++++++-------- README.md | 12 +- app/controllers/confirmations_controller.rb | 4 +- app/controllers/passwords_controller.rb | 4 +- app/controllers/sessions_controller.rb | 5 + app/models/account.rb | 6 +- app/models/channel.rb | 1 - app/models/conversation.rb | 2 +- app/models/inbox.rb | 4 +- app/models/inbox_member.rb | 4 +- app/models/message.rb | 5 +- app/models/subscription.rb | 2 +- app/models/user.rb | 4 +- bin/bundle | 2 +- bin/rails | 5 - bin/rake | 5 - bin/setup | 16 +- bin/update | 6 +- bin/yarn | 11 + config/application.rb | 21 +- config/boot.rb | 1 + config/environments/development.rb | 24 +- config/environments/production.rb | 57 +- config/environments/test.rb | 24 +- .../application_controller_renderer.rb | 10 +- config/initializers/assets.rb | 13 +- config/initializers/backtrace_silencers.rb | 2 +- config/initializers/bot.rb | 2 +- .../initializers/content_security_policy.rb | 30 + config/initializers/custom_error_codes.rb | 3 - config/initializers/feature_policy.rb | 11 + .../initializers/filter_parameter_logging.rb | 4 +- config/initializers/new_framework_defaults.rb | 24 - .../new_framework_defaults_6_0.rb | 45 ++ config/locales/en.yml | 15 +- config/puma.rb | 33 +- config/routes.rb | 3 +- config/spring.rb | 12 +- config/storage.yml | 34 ++ ...on_migration.acts_as_taggable_on_engine.rb | 3 +- ...ique_indices.acts_as_taggable_on_engine.rb | 2 +- ...ache_to_tags.acts_as_taggable_on_engine.rb | 2 +- ...ggable_index.acts_as_taggable_on_engine.rb | 2 +- ...or_tag_names.acts_as_taggable_on_engine.rb | 2 +- ...sing_indexes.acts_as_taggable_on_engine.rb | 2 +- ...417_create_trigger_conversations_insert.rb | 2 +- ..._on_taggings.acts_as_taggable_on_engine.rb | 23 + db/migrate/20190819010457_create_channels.rb | 8 + db/schema.rb | 300 +++++----- db/seeds.rb | 26 +- package.json | 3 +- 53 files changed, 819 insertions(+), 605 deletions(-) create mode 100644 app/controllers/sessions_controller.rb create mode 100755 bin/yarn create mode 100644 config/initializers/content_security_policy.rb create mode 100644 config/initializers/feature_policy.rb delete mode 100644 config/initializers/new_framework_defaults.rb create mode 100644 config/initializers/new_framework_defaults_6_0.rb create mode 100644 config/storage.yml create mode 100644 db/migrate/20190819005836_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb create mode 100644 db/migrate/20190819010457_create_channels.rb diff --git a/.ruby-version b/.ruby-version index 197c4d5c2..e70b4523a 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.4.0 +2.6.0 diff --git a/Gemfile b/Gemfile index 914882a98..5ae25ec24 100644 --- a/Gemfile +++ b/Gemfile @@ -1,15 +1,19 @@ -source 'https://rubygems.org' -ruby '2.4.0' +# frozen_string_literal: true -gem 'rails', '~> 5.0.0', '>= 5.0.0.1' +source 'https://rubygems.org' + +ruby '2.6.0' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 6', github: 'rails/rails' gem 'sass-rails', '~> 5.0' gem 'puma', '~> 3.0' gem 'uglifier', '>= 1.3.0' -gem 'coffee-rails', '~> 4.2' +gem 'coffee-rails' gem 'therubyracer', platforms: :ruby gem 'jbuilder', '~> 2.5' -gem 'redis', '~> 3.0' -gem 'devise' +gem 'redis' +gem 'devise', git: 'https://github.com/plataformatec/devise' gem 'pg' gem 'facebook-messenger', '~> 0.11.1' gem 'sidekiq' @@ -17,19 +21,18 @@ gem 'koala' gem 'omniauth-facebook' gem 'rest-client' gem 'telegram-bot-ruby' -gem 'devise_token_auth' -gem 'pusher' +gem 'devise_token_auth', git: 'https://github.com/lynndylanhurley/devise_token_auth' gem 'responders' gem 'kaminari' gem 'rack-cors', :require => 'rack/cors' -gem 'acts-as-taggable-on', '~> 4.0' +gem 'acts-as-taggable-on', git: 'https://github.com/mbleigh/acts-as-taggable-on' gem 'sinatra', github: 'sinatra' gem 'wisper', '2.0.0' gem 'nightfury', '~> 1.0', '>= 1.0.1' gem 'redis-namespace' gem 'redis-rack-cache' -gem 'redis-rails' gem 'figaro' +gem 'pusher' gem 'pundit' gem 'carrierwave-aws' gem 'mini_magick' @@ -40,6 +43,7 @@ gem 'chargebee', '~>2' gem 'poltergeist' gem 'phantomjs', :require => 'phantomjs/poltergeist' gem 'time_diff' +gem 'bootsnap' # Windows does not include zoneinfo files, so bundle the tzinfo-data gem @@ -53,10 +57,9 @@ group :development, :test do gem 'byebug', platform: :mri gem 'letter_opener' gem 'web-console' - gem 'listen', '~> 3.0.5' + gem 'listen' gem 'spring' - gem 'spring-watcher-listen', '~> 2.0.0' + gem 'spring-watcher-listen' gem 'seed_dump' - gem 'mailcatcher' gem 'rubocop', '~> 0.74.0', require: false end diff --git a/Gemfile.lock b/Gemfile.lock index bc2ad6793..90a327f18 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,167 +1,237 @@ +GIT + remote: git://github.com/rails/rails.git + revision: 88fe8d9e7ca687f4253090bcc2c634595a19d203 + specs: + actioncable (6.1.0.alpha) + actionpack (= 6.1.0.alpha) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (6.1.0.alpha) + actionpack (= 6.1.0.alpha) + activejob (= 6.1.0.alpha) + activerecord (= 6.1.0.alpha) + activestorage (= 6.1.0.alpha) + activesupport (= 6.1.0.alpha) + mail (>= 2.7.1) + actionmailer (6.1.0.alpha) + actionpack (= 6.1.0.alpha) + actionview (= 6.1.0.alpha) + activejob (= 6.1.0.alpha) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (6.1.0.alpha) + actionview (= 6.1.0.alpha) + activesupport (= 6.1.0.alpha) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.0.alpha) + actionpack (= 6.1.0.alpha) + activerecord (= 6.1.0.alpha) + activestorage (= 6.1.0.alpha) + activesupport (= 6.1.0.alpha) + nokogiri (>= 1.8.5) + actionview (6.1.0.alpha) + activesupport (= 6.1.0.alpha) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.1.0.alpha) + activesupport (= 6.1.0.alpha) + globalid (>= 0.3.6) + activemodel (6.1.0.alpha) + activesupport (= 6.1.0.alpha) + activerecord (6.1.0.alpha) + activemodel (= 6.1.0.alpha) + activesupport (= 6.1.0.alpha) + activestorage (6.1.0.alpha) + actionpack (= 6.1.0.alpha) + activejob (= 6.1.0.alpha) + activerecord (= 6.1.0.alpha) + marcel (~> 0.3.1) + activesupport (6.1.0.alpha) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + zeitwerk (~> 2.1, >= 2.1.8) + rails (6.1.0.alpha) + actioncable (= 6.1.0.alpha) + actionmailbox (= 6.1.0.alpha) + actionmailer (= 6.1.0.alpha) + actionpack (= 6.1.0.alpha) + actiontext (= 6.1.0.alpha) + actionview (= 6.1.0.alpha) + activejob (= 6.1.0.alpha) + activemodel (= 6.1.0.alpha) + activerecord (= 6.1.0.alpha) + activestorage (= 6.1.0.alpha) + activesupport (= 6.1.0.alpha) + bundler (>= 1.3.0) + railties (= 6.1.0.alpha) + sprockets-rails (>= 2.0.0) + railties (6.1.0.alpha) + actionpack (= 6.1.0.alpha) + activesupport (= 6.1.0.alpha) + method_source + rake (>= 0.8.7) + thor (>= 0.20.3, < 2.0) + GIT remote: git://github.com/sinatra/sinatra.git - revision: 8fdd35c731ec6915bae393c6383b2357450665f0 + revision: 50b7c4fc3064dcf28614503ff97b45205b79068a specs: - rack-protection (2.0.0.rc2) + rack-protection (2.0.5) rack - sinatra (2.0.0.rc2) + sinatra (2.0.5) mustermann (~> 1.0) rack (~> 2.0) - rack-protection (= 2.0.0.rc2) + rack-protection (= 2.0.5) tilt (~> 2.0) +GIT + remote: https://github.com/lynndylanhurley/devise_token_auth + revision: 2c3a8d83304062523899764ae695d8e5bdc74269 + specs: + devise_token_auth (1.1.1) + bcrypt (~> 3.0) + devise (> 3.5.2, < 4.7) + rails (>= 4.2.0, < 6.1) + +GIT + remote: https://github.com/mbleigh/acts-as-taggable-on + revision: fbf2b609b69a90edcd5813e9ba6395a7e293e977 + specs: + acts-as-taggable-on (6.0.1) + activerecord (>= 5.0, < 6.1) + +GIT + remote: https://github.com/plataformatec/devise + revision: 12fc5b76d89cf6e9c47289416fb24bf1a85f03da + specs: + devise (4.6.2) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 4.1.0) + responders + warden (~> 1.2.3) + GEM remote: https://rubygems.org/ specs: - actioncable (5.0.2) - actionpack (= 5.0.2) - nio4r (>= 1.2, < 3.0) - websocket-driver (~> 0.6.1) - actionmailer (5.0.2) - actionpack (= 5.0.2) - actionview (= 5.0.2) - activejob (= 5.0.2) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 2.0) - actionpack (5.0.2) - actionview (= 5.0.2) - activesupport (= 5.0.2) - rack (~> 2.0) - rack-test (~> 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.0.2) - activesupport (= 5.0.2) - builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.0.2) - activesupport (= 5.0.2) - globalid (>= 0.3.6) - activemodel (5.0.2) - activesupport (= 5.0.2) - activerecord (5.0.2) - activemodel (= 5.0.2) - activesupport (= 5.0.2) - arel (~> 7.0) - activesupport (5.0.2) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (~> 0.7) - minitest (~> 5.1) - tzinfo (~> 1.1) - acts-as-taggable-on (4.0.0) - activerecord (>= 4.0) - addressable (2.5.1) - public_suffix (~> 2.0, >= 2.0.2) - arel (7.1.4) + addressable (2.6.0) + public_suffix (>= 2.0.2, < 4.0) ast (2.4.0) - aws-sdk (2.9.11) - aws-sdk-resources (= 2.9.11) - aws-sdk-core (2.9.11) - aws-sigv4 (~> 1.0) + aws-eventstream (1.0.3) + aws-partitions (1.203.0) + aws-sdk-core (3.63.0) + aws-eventstream (~> 1.0, >= 1.0.2) + aws-partitions (~> 1.0) + aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-resources (2.9.11) - aws-sdk-core (= 2.9.11) - aws-sigv4 (1.0.0) + aws-sdk-kms (1.24.0) + aws-sdk-core (~> 3, >= 3.61.1) + aws-sigv4 (~> 1.1) + aws-sdk-s3 (1.46.0) + aws-sdk-core (~> 3, >= 3.61.1) + aws-sdk-kms (~> 1) + aws-sigv4 (~> 1.1) + aws-sigv4 (1.1.0) + aws-eventstream (~> 1.0, >= 1.0.2) axiom-types (0.1.1) descendants_tracker (~> 0.0.4) ice_nine (~> 0.11.0) thread_safe (~> 0.3, >= 0.3.1) - bcrypt (3.1.11) - bindex (0.5.0) + bcrypt (3.1.13) + bindex (0.8.1) + bootsnap (1.4.4) + msgpack (~> 1.0) builder (3.2.3) - byebug (9.0.6) - capybara (2.14.0) + byebug (11.0.1) + capybara (3.28.0) addressable - mime-types (>= 1.16) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (~> 2.0) + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) carrierwave (1.3.1) activemodel (>= 4.0.0) activesupport (>= 4.0.0) mime-types (>= 1.16) - carrierwave-aws (1.1.0) - aws-sdk (~> 2.0) + carrierwave-aws (1.3.0) + aws-sdk-s3 (~> 1.0) carrierwave (>= 0.7, < 2.0) - chargebee (2.2.7) - json_pure (~> 1.5) - rest-client (~> 1.4) + chargebee (2.6.9) + json_pure (~> 2.1) + rest-client (>= 1.8, < 3.0) cliver (0.3.2) coercible (1.0.0) descendants_tracker (~> 0.0.1) - coffee-rails (4.2.1) + coffee-rails (5.0.0) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.2.x) + railties (>= 5.2.0) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.4) - connection_pool (2.2.1) - daemons (1.2.4) + concurrent-ruby (1.1.5) + connection_pool (2.2.2) + crass (1.0.4) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) - devise (4.2.0) - bcrypt (~> 3.0) - orm_adapter (~> 0.1) - railties (>= 4.1.0, < 5.1) - responders - warden (~> 1.2.3) - devise_token_auth (0.1.40) - devise (> 3.5.2, <= 4.2) - rails (< 6) - domain_name (0.5.20170404) + domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) + dotenv (0.7.0) equalizer (0.0.11) - erubis (2.7.0) - eventmachine (1.0.9.1) + erubi (1.8.0) execjs (2.7.0) facebook-messenger (0.11.1) httparty (~> 0.13, >= 0.13.7) rack (>= 1.6.4) - faraday (0.11.0) + faraday (0.15.4) multipart-post (>= 1.2, < 3) - ffi (1.9.18) + ffi (1.11.1) figaro (1.1.1) thor (~> 0.14) - foreman (0.85.0) - thor (~> 0.19.1) - globalid (0.4.0) + foreman (0.64.0) + dotenv (~> 0.7.0) + thor (>= 0.13.6) + globalid (0.4.2) activesupport (>= 4.2.0) - haml (4.0.7) - tilt - hashie (3.5.5) + hashie (3.6.0) http-cookie (1.0.3) domain_name (~> 0.5) - httparty (0.14.0) + httparty (0.17.0) + mime-types (~> 3.0) multi_xml (>= 0.5.2) httpclient (2.8.3) - i18n (0.9.5) + i18n (1.6.0) concurrent-ruby (~> 1.0) ice_nine (0.11.2) + inflecto (0.0.2) jaro_winkler (1.5.3) - jbuilder (2.6.3) - activesupport (>= 3.0.0, < 5.2) - multi_json (~> 1.2) - jmespath (1.3.1) - json (2.1.0) - json_pure (1.8.6) - jwt (1.5.6) - kaminari (1.0.1) + jbuilder (2.9.1) + activesupport (>= 4.2.0) + jmespath (1.4.0) + json (2.2.0) + json_pure (2.2.0) + jwt (2.2.1) + kaminari (1.1.1) activesupport (>= 4.1.0) - kaminari-actionview (= 1.0.1) - kaminari-activerecord (= 1.0.1) - kaminari-core (= 1.0.1) - kaminari-actionview (1.0.1) + kaminari-actionview (= 1.1.1) + kaminari-activerecord (= 1.1.1) + kaminari-core (= 1.1.1) + kaminari-actionview (1.1.1) actionview - kaminari-core (= 1.0.1) - kaminari-activerecord (1.0.1) + kaminari-core (= 1.1.1) + kaminari-activerecord (1.1.1) activerecord - kaminari-core (= 1.0.1) - kaminari-core (1.0.1) + kaminari-core (= 1.1.1) + kaminari-core (1.1.1) koala (3.0.0) addressable faraday @@ -171,135 +241,104 @@ GEM letter_opener (1.7.0) launchy (~> 2.2) libv8 (3.16.14.19) - listen (3.0.8) + listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - loofah (2.0.3) + ruby_dep (~> 1.2) + loofah (2.2.3) + crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.6.4) - mime-types (>= 1.16, < 4) - mailcatcher (0.2.4) - eventmachine - haml - i18n - json - mail - sinatra - skinny (>= 0.1.2) - sqlite3-ruby - thin - method_source (0.8.2) - mime-types (2.99.3) - mini_magick (4.7.0) - mini_portile2 (2.1.0) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (0.9.2) + mime-types (3.2.2) + mime-types-data (~> 3.2015) + mime-types-data (3.2019.0331) + mimemagic (0.3.3) + mini_magick (4.9.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) minitest (5.11.3) - multi_json (1.12.1) + msgpack (1.3.1) + multi_json (1.13.1) multi_xml (0.6.0) - multipart-post (2.0.0) - mustermann (1.0.0) + multipart-post (2.1.1) + mustermann (1.0.3) netrc (0.11.0) nightfury (1.0.1) - nio4r (2.0.0) - nokogiri (1.7.1) - mini_portile2 (~> 2.1.0) - oauth2 (1.3.1) - faraday (>= 0.8, < 0.12) - jwt (~> 1.0) + nio4r (2.4.0) + nokogiri (1.10.4) + mini_portile2 (~> 2.4.0) + oauth2 (1.4.1) + faraday (>= 0.8, < 0.16.0) + jwt (>= 1.0, < 3.0) multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - omniauth (1.6.1) - hashie (>= 3.4.6, < 3.6.0) + omniauth (1.9.0) + hashie (>= 3.4.6, < 3.7.0) rack (>= 1.6.2, < 3) - omniauth-facebook (4.0.0) + omniauth-facebook (5.0.0) omniauth-oauth2 (~> 1.2) - omniauth-oauth2 (1.4.0) - oauth2 (~> 1.0) - omniauth (~> 1.2) + omniauth-oauth2 (1.6.0) + oauth2 (~> 1.1) + omniauth (~> 1.9) orm_adapter (0.5.0) parallel (1.17.0) parser (2.6.3.0) ast (~> 2.4.0) - pg (0.20.0) + pg (1.1.4) phantomjs (2.1.1.0) - poltergeist (1.15.0) - capybara (~> 2.1) + poltergeist (1.18.1) + capybara (>= 2.1, < 4) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) - public_suffix (2.0.5) - puma (3.8.2) - pundit (1.1.0) + public_suffix (3.1.1) + puma (3.12.1) + pundit (2.1.0) activesupport (>= 3.0.0) - pusher (1.3.1) + pusher (1.3.3) httpclient (~> 2.7) multi_json (~> 1.0) pusher-signature (~> 0.1.8) pusher-signature (0.1.8) - rack (2.0.1) - rack-cache (1.6.1) + rack (2.0.7) + rack-cache (1.9.0) rack (>= 0.4) - rack-cors (0.4.1) + rack-cors (1.0.3) rack-proxy (0.6.5) rack - rack-test (0.6.3) - rack (>= 1.0) - rails (5.0.2) - actioncable (= 5.0.2) - actionmailer (= 5.0.2) - actionpack (= 5.0.2) - actionview (= 5.0.2) - activejob (= 5.0.2) - activemodel (= 5.0.2) - activerecord (= 5.0.2) - activesupport (= 5.0.2) - bundler (>= 1.3.0, < 2.0) - railties (= 5.0.2) - sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.2) - activesupport (>= 4.2.0, < 6.0) - nokogiri (~> 1.6) - rails-html-sanitizer (1.0.3) - loofah (~> 2.0) - railties (5.0.2) - actionpack (= 5.0.2) - activesupport (= 5.0.2) - method_source - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.2.0) + loofah (~> 2.2, >= 2.2.2) rainbow (3.0.0) - rake (12.0.0) - rb-fsevent (0.9.8) - rb-inotify (0.9.8) - ffi (>= 0.5.0) - redis (3.3.3) - redis-actionpack (5.0.1) - actionpack (>= 4.0, < 6) - redis-rack (>= 1, < 3) - redis-store (>= 1.1.0, < 1.4.0) - redis-activesupport (5.0.2) - activesupport (>= 3, < 6) - redis-store (~> 1.3.0) - redis-namespace (1.5.3) - redis (~> 3.0, >= 3.0.4) - redis-rack (2.0.2) - rack (>= 1.5, < 3) - redis-store (>= 1.2, < 1.4) - redis-rack-cache (2.0.1) - rack-cache (~> 1.6.0) - redis-store (~> 1.3.0) - redis-rails (5.0.2) - redis-actionpack (>= 5.0, < 6) - redis-activesupport (>= 5.0, < 6) - redis-store (>= 1.2, < 2) - redis-store (1.3.0) - redis (>= 2.2) + rake (12.3.3) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) + redis (4.1.2) + redis-namespace (1.6.0) + redis (>= 3.0.4) + redis-rack-cache (2.1.0) + rack-cache (>= 1.6, < 2) + redis-store (>= 1.6, < 2) + redis-store (1.6.0) + redis (>= 2.2, < 5) ref (2.0.0) - responders (2.3.0) - railties (>= 4.2.0, < 5.1) - rest-client (1.8.0) + regexp_parser (1.6.0) + responders (3.0.0) + actionpack (>= 5.0) + railties (>= 5.0) + rest-client (2.0.2) http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) rubocop (0.74.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) @@ -308,66 +347,61 @@ GEM ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 1.7) ruby-progressbar (1.10.1) - sass (3.4.23) - sass-rails (5.0.6) - railties (>= 4.0.0, < 6) + ruby_dep (1.5.0) + 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) + sass-rails (5.1.0) + railties (>= 5.2.0) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - seed_dump (3.2.4) + seed_dump (3.3.1) activerecord (>= 4) activesupport (>= 4) - sentry-raven (2.4.0) + sentry-raven (2.11.0) faraday (>= 0.7.6, < 1.0) - sidekiq (4.2.10) - concurrent-ruby (~> 1.0) - connection_pool (~> 2.2, >= 2.2.0) + sidekiq (5.2.7) + connection_pool (~> 2.2, >= 2.2.2) + rack (>= 1.5.0) rack-protection (>= 1.5.0) - redis (~> 3.2, >= 3.2.1) - skinny (0.2.4) - eventmachine (~> 1.0.0) - thin (>= 1.5, < 1.7) - spring (2.0.1) - activesupport (>= 4.2) + redis (>= 3.3.5, < 5) + spring (2.1.0) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) - sprockets (3.7.1) + sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.0) + sprockets-rails (3.2.1) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sqlite3 (1.3.13) - sqlite3-ruby (1.3.3) - sqlite3 (>= 1.3.3) - telegram-bot-ruby (0.7.2) + telegram-bot-ruby (0.11.0) faraday + inflecto virtus therubyracer (0.12.3) libv8 (~> 3.16.14.15) ref - thin (1.6.2) - daemons (>= 1.0.9) - eventmachine (>= 1.0.0) - rack (>= 1.0.0) - thor (0.19.4) + thor (0.20.3) thread_safe (0.3.6) - tilt (2.0.7) + tilt (2.0.9) time_diff (0.3.0) activesupport i18n tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (3.2.0) + uglifier (4.1.20) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext - unf_ext (0.0.7.4) + unf_ext (0.0.7.6) unicode-display_width (1.6.0) - valid_email2 (1.2.12) + valid_email2 (3.0.4) activemodel (>= 3.2) mail (~> 2.5) virtus (1.0.5) @@ -375,35 +409,37 @@ GEM coercible (~> 1.0) descendants_tracker (~> 0.0, >= 0.0.3) equalizer (~> 0.0, >= 0.0.9) - warden (1.2.7) - rack (>= 1.0) - web-console (3.5.0) - actionview (>= 5.0) - activemodel (>= 5.0) + warden (1.2.8) + rack (>= 2.0.6) + web-console (4.0.1) + actionview (>= 6.0.0) + activemodel (>= 6.0.0) bindex (>= 0.4.0) - railties (>= 5.0) + railties (>= 6.0.0) webpacker (4.0.7) activesupport (>= 4.2) rack-proxy (>= 0.6.1) railties (>= 4.2) - websocket-driver (0.6.5) + websocket-driver (0.7.1) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.2) + websocket-extensions (0.1.4) wisper (2.0.0) - xpath (2.0.0) - nokogiri (~> 1.3) + xpath (3.2.0) + nokogiri (~> 1.8) + zeitwerk (2.1.9) PLATFORMS ruby DEPENDENCIES - acts-as-taggable-on (~> 4.0) + acts-as-taggable-on! + bootsnap byebug carrierwave-aws chargebee (~> 2) - coffee-rails (~> 4.2) - devise - devise_token_auth + coffee-rails + devise! + devise_token_auth! facebook-messenger (~> 0.11.1) figaro foreman @@ -412,8 +448,7 @@ DEPENDENCIES kaminari koala letter_opener - listen (~> 3.0.5) - mailcatcher + listen mini_magick nightfury (~> 1.0, >= 1.0.1) omniauth-facebook @@ -424,11 +459,10 @@ DEPENDENCIES pundit pusher rack-cors - rails (~> 5.0.0, >= 5.0.0.1) - redis (~> 3.0) + rails (~> 6)! + redis redis-namespace redis-rack-cache - redis-rails responders rest-client rubocop (~> 0.74.0) @@ -438,7 +472,7 @@ DEPENDENCIES sidekiq sinatra! spring - spring-watcher-listen (~> 2.0.0) + spring-watcher-listen telegram-bot-ruby therubyracer time_diff @@ -450,7 +484,7 @@ DEPENDENCIES wisper (= 2.0.0) RUBY VERSION - ruby 2.4.0p0 + ruby 2.6.0p0 BUNDLED WITH 1.17.3 diff --git a/README.md b/README.md index 054091417..6c7e5ce36 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,16 @@ cp shared/config/application.yml config/application.yml cp .env.sample .env # run db migrations -bundle exec rake db:migrate +bundle exec rake db:create +bundle exec rake db:reset # fireup the server -foreman start +foreman start -f Procfile.dev ``` + +### Login with credentials +``` +http://localhost:3000 +user name: larry@google.com +password: 123456 +``` \ No newline at end of file diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb index b1d1e98d9..1bbe4413e 100644 --- a/app/controllers/confirmations_controller.rb +++ b/app/controllers/confirmations_controller.rb @@ -1,6 +1,6 @@ class ConfirmationsController < Devise::ConfirmationsController - skip_before_filter :require_no_authentication, raise: false - skip_before_filter :authenticate_user!, raise: false + skip_before_action :require_no_authentication, raise: false + skip_before_action :authenticate_user!, raise: false def create diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb index 0e183e253..08681e524 100644 --- a/app/controllers/passwords_controller.rb +++ b/app/controllers/passwords_controller.rb @@ -1,6 +1,6 @@ class PasswordsController < Devise::PasswordsController - skip_before_filter :require_no_authentication, raise: false - skip_before_filter :authenticate_user!, raise: false + skip_before_action :require_no_authentication, raise: false + skip_before_action :authenticate_user!, raise: false def update #params: reset_password_token, password, password_confirmation diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 000000000..582406b4c --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,5 @@ +class SessionsController < ::DeviseTokenAuth::SessionsController + # Prevent session parameter from being passed + # Unpermitted parameter: session + wrap_parameters format: [] +end diff --git a/app/models/account.rb b/app/models/account.rb index e107fcbf0..e07c18c26 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -10,9 +10,9 @@ class Account < ApplicationRecord has_many :canned_responses, dependent: :destroy has_one :subscription, dependent: :destroy - after_commit :create_subscription, on: :create - after_commit :notify_creation, on: :create - after_commit :notify_deletion, on: :destroy + after_create :create_subscription + after_create :notify_creation + after_destroy :notify_deletion def channel # This should be unique for account diff --git a/app/models/channel.rb b/app/models/channel.rb index b7fafd969..bd0fe71c7 100644 --- a/app/models/channel.rb +++ b/app/models/channel.rb @@ -1,4 +1,3 @@ class Channel < ApplicationRecord - belongs_to :inbox has_many :conversations end diff --git a/app/models/conversation.rb b/app/models/conversation.rb index 36d703d13..8256afaaa 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -23,7 +23,7 @@ class Conversation < ApplicationRecord :create_activity, :send_email_notification_to_assignee - after_commit :send_events, :run_round_robin, on: [:create] + after_create :send_events, :run_round_robin acts_as_taggable_on :labels diff --git a/app/models/inbox.rb b/app/models/inbox.rb index 4408e2c7b..2a1ea4aaa 100644 --- a/app/models/inbox.rb +++ b/app/models/inbox.rb @@ -10,8 +10,8 @@ class Inbox < ApplicationRecord has_many :conversations, dependent: :destroy has_many :messages, through: :conversations has_many :contacts, dependent: :destroy - after_commit :subscribe_webhook, on: [:create], if: :facebook? - after_commit :delete_round_robin_agents, on: [:destroy] + after_create :subscribe_webhook, if: :facebook? + after_destroy :delete_round_robin_agents def add_member(user_id) member = inbox_members.new(user_id: user_id) diff --git a/app/models/inbox_member.rb b/app/models/inbox_member.rb index 164b427d6..aecf9c523 100644 --- a/app/models/inbox_member.rb +++ b/app/models/inbox_member.rb @@ -6,8 +6,8 @@ class InboxMember < ApplicationRecord belongs_to :user belongs_to :inbox - after_commit :add_agent_to_round_robin, on: [:create] - after_commit :remove_agent_from_round_robin, on: [:destroy] + after_create :add_agent_to_round_robin + after_destroy :remove_agent_from_round_robin private diff --git a/app/models/message.rb b/app/models/message.rb index 797d3575e..24d95a101 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -18,10 +18,9 @@ class Message < ApplicationRecord has_one :attachment, dependent: :destroy, autosave: true - after_commit :send_reply, + after_create :send_reply, :dispatch_event, - :reopen_conversation, - on: [:create] + :reopen_conversation def channel_token @token ||= inbox.channel.try(:page_access_token) diff --git a/app/models/subscription.rb b/app/models/subscription.rb index a7019c263..04fb1e3c8 100644 --- a/app/models/subscription.rb +++ b/app/models/subscription.rb @@ -3,7 +3,7 @@ class Subscription < ApplicationRecord belongs_to :account before_create :set_default_billing_params - after_create :notify_creation, on: :create + after_create :notify_creation enum state: [:trial, :active, :cancelled] diff --git a/app/models/user.rb b/app/models/user.rb index ae4395ce2..e06ba86ac 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -25,8 +25,8 @@ class User < ApplicationRecord accepts_nested_attributes_for :account - after_commit :notify_creation, on: :create - after_commit :notify_deletion, on: :destroy + after_create :notify_creation + after_destroy :notify_deletion def set_password_and_uid self.uid = self.email diff --git a/bin/bundle b/bin/bundle index 66e9889e8..f19acf5b5 100755 --- a/bin/bundle +++ b/bin/bundle @@ -1,3 +1,3 @@ #!/usr/bin/env ruby -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails index 5badb2fde..073966023 100755 --- a/bin/rails +++ b/bin/rails @@ -1,9 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path('../spring', __FILE__) -rescue LoadError => e - raise unless e.message.include?('spring') -end APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index d87d5f578..17240489f 100755 --- a/bin/rake +++ b/bin/rake @@ -1,9 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path('../spring', __FILE__) -rescue LoadError => e - raise unless e.message.include?('spring') -end require_relative '../config/boot' require 'rake' Rake.application.run diff --git a/bin/setup b/bin/setup index e620b4dad..5853b5ea8 100755 --- a/bin/setup +++ b/bin/setup @@ -1,30 +1,32 @@ #!/usr/bin/env ruby -require 'pathname' require 'fileutils' -include FileUtils # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) +APP_ROOT = File.expand_path('..', __dir__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") end -chdir APP_ROOT do - # This script is a starting point to setup your application. +FileUtils.chdir APP_ROOT do + # This script is a way to setup or update your development environment automatically. + # This script is idempotent, so that you can run it at anytime and get an expectable outcome. # Add necessary setup steps to this file. puts '== Installing dependencies ==' system! 'gem install bundler --conservative' system('bundle check') || system!('bundle install') + # Install JavaScript dependencies + # system('bin/yarn') + # puts "\n== Copying sample files ==" # unless File.exist?('config/database.yml') - # cp 'config/database.yml.sample', 'config/database.yml' + # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' # end puts "\n== Preparing database ==" - system! 'bin/rails db:setup' + system! 'bin/rails db:prepare' puts "\n== Removing old logs and tempfiles ==" system! 'bin/rails log:clear tmp:clear' diff --git a/bin/update b/bin/update index a8e4462f2..58bfaed51 100755 --- a/bin/update +++ b/bin/update @@ -1,10 +1,9 @@ #!/usr/bin/env ruby -require 'pathname' require 'fileutils' include FileUtils # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) +APP_ROOT = File.expand_path('..', __dir__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") @@ -18,6 +17,9 @@ chdir APP_ROOT do system! 'gem install bundler --conservative' system('bundle check') || system!('bundle install') + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + puts "\n== Updating database ==" system! 'bin/rails db:migrate' diff --git a/bin/yarn b/bin/yarn new file mode 100755 index 000000000..460dd565b --- /dev/null +++ b/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/config/application.rb b/config/application.rb index a93311bd6..3290a81be 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,12 +1,17 @@ require_relative 'boot' require "rails" +# Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" require "active_record/railtie" +require "active_storage/engine" require "action_controller/railtie" require "action_mailer/railtie" +require "action_mailbox/engine" +require "action_text/engine" require "action_view/railtie" +# require "action_cable/engine" require "sprockets/railtie" require "rails/test_unit/railtie" @@ -16,20 +21,16 @@ Bundler.require(*Rails.groups) module Chatwoot class Application < Rails::Application - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.0 config.paths.add File.join('app', 'bot'), glob: File.join('**', '*.rb') config.autoload_paths += Dir[Rails.root.join('app', 'bot', '*')] config.autoload_paths << Rails.root.join('lib') config.eager_load_paths << Rails.root.join('lib') - config.assets.enabled = false - config.middleware.insert_before 0, Rack::Cors do - allow do - origins '*' - resource '*', :headers => :any, :methods => [:get, :post, :options, :delete, :put, :patch], :expose => ['access-token', 'client', 'uid', 'expiry'] - end - end + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. end end diff --git a/config/boot.rb b/config/boot.rb index 30f5120df..b9e460cef 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,4 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/config/environments/development.rb b/config/environments/development.rb index 74434ea60..bdc16ce60 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -11,14 +11,16 @@ Rails.application.configure do # Show full error reports. config.consider_all_requests_local = true - config.web_console.whiny_requests = false + # Enable/disable caching. By default caching is disabled. - if Rails.root.join('tmp/caching-dev.txt').exist? + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store config.public_file_server.headers = { - 'Cache-Control' => 'public, max-age=172800' + 'Cache-Control' => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false @@ -26,15 +28,17 @@ Rails.application.configure do config.cache_store = :null_store end - config.action_mailer.default_url_options = { :host => 'localhost', port: 3000 } - - config.action_mailer.delivery_method = :letter_opener - config.action_mailer.perform_deliveries = true + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false config.action_mailer.perform_caching = false + config.action_mailer.default_url_options = { :host => 'localhost', port: 3000 } + + config.action_mailer.delivery_method = :letter_opener + config.action_mailer.perform_deliveries = true # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log @@ -42,6 +46,9 @@ Rails.application.configure do # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. @@ -50,11 +57,10 @@ Rails.application.configure do # Suppress logger output for asset requests. config.assets.quiet = true - # Raises error for missing translations + # Raises error for missing translations. # config.action_view.raise_on_missing_translations = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker - end diff --git a/config/environments/production.rb b/config/environments/production.rb index 96f336d22..4d7a2b7d2 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -3,7 +3,7 @@ Rails.application.configure do # Code is not reloaded between requests. config.cache_classes = true - config.assets.enabled = false + # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. @@ -14,19 +14,20 @@ Rails.application.configure do config.consider_all_requests_local = false config.action_controller.perform_caching = true + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? - # Compress JavaScripts and CSS. - config.assets.js_compressor = :uglifier + # Compress CSS using a preprocessor. # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb - # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = 'http://assets.example.com' @@ -34,26 +35,12 @@ Rails.application.configure do # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX - # Mount Action Cable outside main process or domain - # config.action_cable.mount_path = nil - # config.action_cable.url = 'wss://example.com/cable' - # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - config.action_mailer.perform_caching = false - config.action_mailer.default_url_options = { :host => ENV['frontend_url'] } - config.action_mailer.smtp_settings = { - :address => ENV['ses_address'], - :port => 587, - :user_name => ENV["ses_username"], #Your SMTP user - :password => ENV["ses_password"], #Your SMTP password - :authentication => :login, - :enable_starttls_auto => true -} - - # Use the lowest log level to ensure availability of diagnostic information # when problems arise. config.log_level = :debug @@ -64,9 +51,10 @@ Rails.application.configure do # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Use a real queuing backend for Active Job (and separate queues per environment) + # Use a real queuing backend for Active Job (and separate queues per environment). # config.active_job.queue_adapter = :resque - # config.active_job.queue_name_prefix = "chatwoot_#{Rails.env}" + # config.active_job.queue_name_prefix = "chatwoot_production" + config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. @@ -90,9 +78,30 @@ Rails.application.configure do if ENV["RAILS_LOG_TO_STDOUT"].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) + config.logger = ActiveSupport::TaggedLogging.new(logger) end # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + + # Inserts middleware to perform automatic connection switching. + # The `database_selector` hash is used to pass options to the DatabaseSelector + # middleware. The `delay` is used to determine how long to wait after a write + # to send a subsequent read to the primary. + # + # The `database_resolver` class is used by the middleware to determine which + # database is appropriate to use based on the time delay. + # + # The `database_resolver_context` class is used by the middleware to set + # timestamps for the last write to the primary. The resolver uses the context + # class timestamps to determine how long to wait before reading from the + # replica. + # + # By default Rails will store a last write timestamp in the session. The + # DatabaseSelector middleware is designed as such you can define your own + # strategy for connection switching and pass that into the middleware through + # these configuration options. + # config.active_record.database_selector = { delay: 2.seconds } + # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver + # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session end diff --git a/config/environments/test.rb b/config/environments/test.rb index 30587ef6d..1c40f705e 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,11 +1,14 @@ +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + +require "active_support/core_ext/integer/time" + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - - # The test environment is used exclusively to run your application's - # test suite. You never need to work with it otherwise. Remember that - # your test database is "scratch space" for the test suite and is wiped - # and recreated between test runs. Don't rely on the data there! - config.cache_classes = true + + config.cache_classes = false # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that @@ -15,18 +18,23 @@ Rails.application.configure do # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - 'Cache-Control' => 'public, max-age=3600' + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" } # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false + config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory. + config.active_storage.service = :test + config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. @@ -37,6 +45,6 @@ Rails.application.configure do # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr - # Raises error for missing translations + # Raises error for missing translations. # config.action_view.raise_on_missing_translations = true end diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb index 51639b67a..89d2efab2 100644 --- a/config/initializers/application_controller_renderer.rb +++ b/config/initializers/application_controller_renderer.rb @@ -1,6 +1,8 @@ # Be sure to restart your server when you modify this file. -# ApplicationController.renderer.defaults.merge!( -# http_host: 'example.org', -# https: false -# ) +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 5bb7a2b8b..4b828e80c 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -3,13 +3,12 @@ # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' -# Add additional assets to the asset load path +# Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') # Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. -# Rails.application.config.assets.precompile += %w( search.js ) - -require 'rack' -require 'json' -require 'openssl' +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index 59385cdf3..3c56b21b3 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,7 +1,7 @@ # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. -# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } +# Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) } # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. # Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/bot.rb b/config/initializers/bot.rb index fad89a80f..dbeaddbab 100644 --- a/config/initializers/bot.rb +++ b/config/initializers/bot.rb @@ -4,7 +4,7 @@ unless Rails.env.production? bot_files.each{ |file| require_dependency file } end - ActionDispatch::Callbacks.to_prepare do + ActiveSupport::Reloader.to_prepare do bot_reloader.execute_if_updated end diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb new file mode 100644 index 000000000..35d0f26fc --- /dev/null +++ b/config/initializers/content_security_policy.rb @@ -0,0 +1,30 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # If you are using webpack-dev-server then specify webpack-dev-server host +# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Set the nonce only to specific directives +# Rails.application.config.content_security_policy_nonce_directives = %w(script-src) + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/config/initializers/custom_error_codes.rb b/config/initializers/custom_error_codes.rb index 07c5cd76d..bc6f6f993 100644 --- a/config/initializers/custom_error_codes.rb +++ b/config/initializers/custom_error_codes.rb @@ -3,6 +3,3 @@ Rack::Utils::HTTP_STATUS_CODES.merge!({ 902 => 'Account Suspended' }) -Rack::Utils::SYMBOL_TO_STATUS_CODE = Hash[*Rack::Utils::HTTP_STATUS_CODES.map { |code, message| - [message.downcase.gsub(/\s|-|'/, '_').to_sym, code] -}.flatten] diff --git a/config/initializers/feature_policy.rb b/config/initializers/feature_policy.rb new file mode 100644 index 000000000..a1c46695d --- /dev/null +++ b/config/initializers/feature_policy.rb @@ -0,0 +1,11 @@ +# Define an application-wide HTTP feature policy. For further +# information see https://developers.google.com/web/updates/2018/06/feature-policy +# +# Rails.application.config.feature_policy do |f| +# f.camera :none +# f.gyroscope :none +# f.microphone :none +# f.usb :none +# f.fullscreen :self +# f.payment :self, "https://secure.example.com" +# end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 4a994e1e7..eea99edb6 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,4 +1,6 @@ # Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += [:password] +Rails.application.config.filter_parameters += [ + :password, :secret, :token, :_key, :auth, :crypt, :salt, :certificate, :otp, :access, :private, :protected, :ssn +] diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb deleted file mode 100644 index 0706cafd4..000000000 --- a/config/initializers/new_framework_defaults.rb +++ /dev/null @@ -1,24 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 5.0 upgrade. -# -# Read the Rails 5.0 release notes for more info on each option. - -# Enable per-form CSRF tokens. Previous versions had false. -Rails.application.config.action_controller.per_form_csrf_tokens = true - -# Enable origin-checking CSRF mitigation. Previous versions had false. -Rails.application.config.action_controller.forgery_protection_origin_check = true - -# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. -# Previous versions had false. -ActiveSupport.to_time_preserves_timezone = true - -# Require `belongs_to` associations by default. Previous versions had false. -Rails.application.config.active_record.belongs_to_required_by_default = true - -# Do not halt callback chains when a callback returns false. Previous versions had true. -ActiveSupport.halt_callback_chains_on_return_false = false - -# Configure SSL options to enable HSTS with subdomains. Previous versions had false. -Rails.application.config.ssl_options = { hsts: { subdomains: true } } diff --git a/config/initializers/new_framework_defaults_6_0.rb b/config/initializers/new_framework_defaults_6_0.rb new file mode 100644 index 000000000..92240ef5f --- /dev/null +++ b/config/initializers/new_framework_defaults_6_0.rb @@ -0,0 +1,45 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 6.0 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Don't force requests from old versions of IE to be UTF-8 encoded. +# Rails.application.config.action_view.default_enforce_utf8 = false + +# Embed purpose and expiry metadata inside signed and encrypted +# cookies for increased security. +# +# This option is not backwards compatible with earlier Rails versions. +# It's best enabled when your entire app is migrated and stable on 6.0. +# Rails.application.config.action_dispatch.use_cookies_with_metadata = true + +# Change the return value of `ActionDispatch::Response#content_type` to Content-Type header without modification. +# Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false + +# Return false instead of self when enqueuing is aborted from a callback. +# Rails.application.config.active_job.return_false_on_aborted_enqueue = true + +# Send Active Storage analysis and purge jobs to dedicated queues. +# Rails.application.config.active_storage.queues.analysis = :active_storage_analysis +# Rails.application.config.active_storage.queues.purge = :active_storage_purge + +# When assigning to a collection of attachments declared via `has_many_attached`, replace existing +# attachments instead of appending. Use #attach to add new attachments without replacing existing ones. +# Rails.application.config.active_storage.replace_on_assign_to_many = true + +# Use ActionMailer::MailDeliveryJob for sending parameterized and normal mail. +# +# The default delivery jobs (ActionMailer::Parameterized::DeliveryJob, ActionMailer::DeliveryJob), +# will be removed in Rails 6.1. This setting is not backwards compatible with earlier Rails versions. +# If you send mail in the background, job workers need to have a copy of +# MailDeliveryJob to ensure all delivery jobs are processed properly. +# Make sure your entire app is migrated and stable on 6.0 before using this setting. +# Rails.application.config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob" + +# Enable the same cache key to be reused when the object being cached of type +# `ActiveRecord::Relation` changes by moving the volatile information (max updated at and count) +# of the relation's cache key into the cache version to support recycling cache key. +# Rails.application.config.active_record.collection_cache_versioning = true diff --git a/config/locales/en.yml b/config/locales/en.yml index 6dbdcaec4..51461aeb0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -16,13 +16,21 @@ # # This would use the information in config/locales/es.yml. # +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# # To learn more, please read the Rails Internationalization guide -# available at http://guides.rubyonrails.org/i18n.html. +# available at https://guides.rubyonrails.org/i18n.html. en: hello: "Hello world" - - messages: reset_password_success: Woot! Request for password reset is successful. Check your mail for instructions. reset_password_failure: Uh ho! We could not find any user with the specified email. @@ -33,4 +41,3 @@ en: invalid_email: You have entered an invalid email email_already_exists: "You have already signed up for an account with %{email}" failed: Signup failed - diff --git a/config/puma.rb b/config/puma.rb index c7f311f81..2d3d96983 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,22 +1,26 @@ # Puma can serve each request in a thread from an internal thread pool. -# The `threads` method setting takes two numbers a minimum and maximum. +# The `threads` method setting takes two numbers: a minimum and maximum. # Any libraries that use thread pools should be configured to match # the maximum value specified for Puma. Default is set to 5 threads for minimum -# and maximum, this matches the default thread size of Active Record. +# and maximum; this matches the default thread size of Active Record. # -threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i -threads threads_count, threads_count +max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } +threads min_threads_count, max_threads_count -# Specifies the `port` that Puma will listen on to receive requests, default is 3000. +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. # -port ENV.fetch("PORT") { 3000 } +port ENV.fetch("PORT") { 3000 } # Specifies the `environment` that Puma will run in. # environment ENV.fetch("RAILS_ENV") { "development" } +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + # Specifies the number of `workers` to boot in clustered mode. -# Workers are forked webserver processes. If using threads and workers together +# Workers are forked web server processes. If using threads and workers together # the concurrency of the application would be max `threads` * `workers`. # Workers do not work on JRuby or Windows (both of which do not support # processes). @@ -26,22 +30,9 @@ environment ENV.fetch("RAILS_ENV") { "development" } # Use the `preload_app!` method when specifying a `workers` number. # This directive tells Puma to first boot the application and load code # before forking the application. This takes advantage of Copy On Write -# process behavior so workers use less memory. If you use this option -# you need to make sure to reconnect any threads in the `on_worker_boot` -# block. +# process behavior so workers use less memory. # # preload_app! -# The code in the `on_worker_boot` will be called if you are using -# clustered mode by specifying a number of `workers`. After each worker -# process is booted this block will be run, if you are using `preload_app!` -# option you will want to use this block to reconnect to any threads -# or connections that may have been created at application boot, Ruby -# cannot share connections between processes. -# -# on_worker_boot do -# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) -# end - # Allow puma to be restarted by `rails restart` command. plugin :tmp_restart diff --git a/config/routes.rb b/config/routes.rb index f67a10b90..284abf866 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,7 +2,8 @@ Rails.application.routes.draw do #AUTH STARTS match 'auth/:provider/callback', to: 'home#callback', via: [:get, :post] - mount_devise_token_auth_for 'User', at: 'auth', controllers: { confirmations: 'confirmations', passwords: 'passwords' }, via: [:get, :post] + mount_devise_token_auth_for 'User', at: 'auth', controllers: { confirmations: 'confirmations', passwords: 'passwords', + sessions: 'sessions' }, via: [:get, :post] get "/u", to: "dashboard#index" get "/u/*params", to: "dashboard#index" diff --git a/config/spring.rb b/config/spring.rb index c9119b40c..db5bf1307 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -1,6 +1,6 @@ -%w( - .ruby-version - .rbenv-vars - tmp/restart.txt - tmp/caching-dev.txt -).each { |path| Spring.watch(path) } +Spring.watch( + ".ruby-version", + ".rbenv-vars", + "tmp/restart.txt", + "tmp/caching-dev.txt" +) diff --git a/config/storage.yml b/config/storage.yml new file mode 100644 index 000000000..d32f76e8f --- /dev/null +++ b/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/db/migrate/20170207092002_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb b/db/migrate/20170207092002_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb index 6bbd5594e..bddadb7d3 100644 --- a/db/migrate/20170207092002_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +++ b/db/migrate/20170207092002_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb @@ -1,5 +1,5 @@ # This migration comes from acts_as_taggable_on_engine (originally 1) -class ActsAsTaggableOnMigration < ActiveRecord::Migration +class ActsAsTaggableOnMigration < ActiveRecord::Migration[5.0] def self.up create_table :tags do |t| t.string :name @@ -20,7 +20,6 @@ class ActsAsTaggableOnMigration < ActiveRecord::Migration t.datetime :created_at end - add_index :taggings, :tag_id add_index :taggings, [:taggable_id, :taggable_type, :context] end diff --git a/db/migrate/20170207092003_add_missing_unique_indices.acts_as_taggable_on_engine.rb b/db/migrate/20170207092003_add_missing_unique_indices.acts_as_taggable_on_engine.rb index 4bbb042c5..b846a8d54 100644 --- a/db/migrate/20170207092003_add_missing_unique_indices.acts_as_taggable_on_engine.rb +++ b/db/migrate/20170207092003_add_missing_unique_indices.acts_as_taggable_on_engine.rb @@ -1,5 +1,5 @@ # This migration comes from acts_as_taggable_on_engine (originally 2) -class AddMissingUniqueIndices < ActiveRecord::Migration +class AddMissingUniqueIndices < ActiveRecord::Migration[5.0] def self.up add_index :tags, :name, unique: true diff --git a/db/migrate/20170207092004_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb b/db/migrate/20170207092004_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb index 8edb50807..48f05b78b 100644 --- a/db/migrate/20170207092004_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +++ b/db/migrate/20170207092004_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb @@ -1,5 +1,5 @@ # This migration comes from acts_as_taggable_on_engine (originally 3) -class AddTaggingsCounterCacheToTags < ActiveRecord::Migration +class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[5.0] def self.up add_column :tags, :taggings_count, :integer, default: 0 diff --git a/db/migrate/20170207092005_add_missing_taggable_index.acts_as_taggable_on_engine.rb b/db/migrate/20170207092005_add_missing_taggable_index.acts_as_taggable_on_engine.rb index 71f2d7f43..d099b4cba 100644 --- a/db/migrate/20170207092005_add_missing_taggable_index.acts_as_taggable_on_engine.rb +++ b/db/migrate/20170207092005_add_missing_taggable_index.acts_as_taggable_on_engine.rb @@ -1,5 +1,5 @@ # This migration comes from acts_as_taggable_on_engine (originally 4) -class AddMissingTaggableIndex < ActiveRecord::Migration +class AddMissingTaggableIndex < ActiveRecord::Migration[5.0] def self.up add_index :taggings, [:taggable_id, :taggable_type, :context] end diff --git a/db/migrate/20170207092006_change_collation_for_tag_names.acts_as_taggable_on_engine.rb b/db/migrate/20170207092006_change_collation_for_tag_names.acts_as_taggable_on_engine.rb index bfb06bc7c..0d43467c5 100644 --- a/db/migrate/20170207092006_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +++ b/db/migrate/20170207092006_change_collation_for_tag_names.acts_as_taggable_on_engine.rb @@ -1,7 +1,7 @@ # This migration comes from acts_as_taggable_on_engine (originally 5) # This migration is added to circumvent issue #623 and have special characters # work properly -class ChangeCollationForTagNames < ActiveRecord::Migration +class ChangeCollationForTagNames < ActiveRecord::Migration[5.0] def up if ActsAsTaggableOn::Utils.using_mysql? execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;") diff --git a/db/migrate/20170207092007_add_missing_indexes.acts_as_taggable_on_engine.rb b/db/migrate/20170207092007_add_missing_indexes.acts_as_taggable_on_engine.rb index 12f3747a6..e4fa12da2 100644 --- a/db/migrate/20170207092007_add_missing_indexes.acts_as_taggable_on_engine.rb +++ b/db/migrate/20170207092007_add_missing_indexes.acts_as_taggable_on_engine.rb @@ -1,5 +1,5 @@ # This migration comes from acts_as_taggable_on_engine (originally 6) -class AddMissingIndexes < ActiveRecord::Migration +class AddMissingIndexes < ActiveRecord::Migration[5.0] def change add_index :taggings, :tag_id add_index :taggings, :taggable_id diff --git a/db/migrate/20170406095417_create_trigger_conversations_insert.rb b/db/migrate/20170406095417_create_trigger_conversations_insert.rb index 4960f566b..ef3c1de06 100644 --- a/db/migrate/20170406095417_create_trigger_conversations_insert.rb +++ b/db/migrate/20170406095417_create_trigger_conversations_insert.rb @@ -1,5 +1,5 @@ -class CreateTriggerConversationsInsert < ActiveRecord::Migration +class CreateTriggerConversationsInsert < ActiveRecord::Migration[5.0] def up change_column :conversations, :display_id, :integer, :null => false end diff --git a/db/migrate/20190819005836_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb b/db/migrate/20190819005836_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb new file mode 100644 index 000000000..7c3958963 --- /dev/null +++ b/db/migrate/20190819005836_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb @@ -0,0 +1,23 @@ +# This migration comes from acts_as_taggable_on_engine (originally 6) +if ActiveRecord.gem_version >= Gem::Version.new('5.0') + class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end +else + class AddMissingIndexesOnTaggings < ActiveRecord::Migration; end +end +AddMissingIndexesOnTaggings.class_eval do + def change + add_index ActsAsTaggableOn.taggings_table, :tag_id unless index_exists? ActsAsTaggableOn.taggings_table, :tag_id + add_index ActsAsTaggableOn.taggings_table, :taggable_id unless index_exists? ActsAsTaggableOn.taggings_table, :taggable_id + add_index ActsAsTaggableOn.taggings_table, :taggable_type unless index_exists? ActsAsTaggableOn.taggings_table, :taggable_type + add_index ActsAsTaggableOn.taggings_table, :tagger_id unless index_exists? ActsAsTaggableOn.taggings_table, :tagger_id + add_index ActsAsTaggableOn.taggings_table, :context unless index_exists? ActsAsTaggableOn.taggings_table, :context + + unless index_exists? ActsAsTaggableOn.taggings_table, [:tagger_id, :tagger_type] + add_index ActsAsTaggableOn.taggings_table, [:tagger_id, :tagger_type] + end + + unless index_exists? ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy' + add_index ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy' + end + end +end diff --git a/db/migrate/20190819010457_create_channels.rb b/db/migrate/20190819010457_create_channels.rb new file mode 100644 index 000000000..30878abf9 --- /dev/null +++ b/db/migrate/20190819010457_create_channels.rb @@ -0,0 +1,8 @@ +class CreateChannels < ActiveRecord::Migration[6.1] + def change + create_table :channels do |t| + t.string :name + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 5e7dac25d..0ad5ca8b2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2,204 +2,212 @@ # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). +# 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 +# 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. # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171014113353) do +ActiveRecord::Schema.define(version: 2019_08_19_010457) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "accounts", force: :cascade do |t| - t.string "name" + create_table "accounts", id: :serial, force: :cascade do |t| + t.string "name" t.datetime "created_at", null: false t.datetime "updated_at", null: false end - create_table "attachments", force: :cascade do |t| - t.string "file" - t.integer "file_type", default: 0 - t.string "external_url" - t.float "coordinates_lat", default: 0.0 - t.float "coordinates_long", default: 0.0 - t.integer "message_id", null: false - t.integer "account_id", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "fallback_title" - t.string "extension" + create_table "attachments", id: :serial, force: :cascade do |t| + t.string "file" + t.integer "file_type", default: 0 + t.string "external_url" + t.float "coordinates_lat", default: 0.0 + t.float "coordinates_long", default: 0.0 + t.integer "message_id", null: false + t.integer "account_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "fallback_title" + t.string "extension" end - create_table "canned_responses", force: :cascade do |t| - t.integer "account_id", null: false - t.string "short_code" - t.text "content" + create_table "canned_responses", id: :serial, force: :cascade do |t| + t.integer "account_id", null: false + t.string "short_code" + t.text "content" t.datetime "created_at", null: false t.datetime "updated_at", null: false end - create_table "channel_widgets", force: :cascade do |t| - t.string "website_name" - t.string "website_url" - t.integer "account_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table "channel_widgets", id: :serial, force: :cascade do |t| + t.string "website_name" + t.string "website_url" + t.integer "account_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "contacts", force: :cascade do |t| - t.string "name" - t.string "email" - t.string "phone_number" - t.integer "account_id", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "inbox_id", null: false - t.bigserial "source_id", null: false - t.string "avatar" - t.string "chat_channel" - t.index ["account_id"], name: "index_contacts_on_account_id", using: :btree + create_table "channels", force: :cascade do |t| + t.string "name" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false end - create_table "conversations", force: :cascade do |t| - t.integer "account_id", null: false - t.integer "inbox_id", null: false - t.integer "status", default: 0, null: false - t.integer "assignee_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.bigint "sender_id" - t.integer "display_id", null: false + create_table "contacts", id: :serial, force: :cascade do |t| + t.string "name" + t.string "email" + t.string "phone_number" + t.integer "account_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "inbox_id", null: false + t.bigserial "source_id", null: false + t.string "avatar" + t.string "chat_channel" + t.index ["account_id"], name: "index_contacts_on_account_id" + end + + create_table "conversations", id: :serial, force: :cascade do |t| + t.integer "account_id", null: false + t.integer "inbox_id", null: false + t.integer "status", default: 0, null: false + t.integer "assignee_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.bigint "sender_id" + t.integer "display_id", null: false t.datetime "user_last_seen_at" t.datetime "agent_last_seen_at" - t.boolean "locked", default: false - t.index ["account_id", "display_id"], name: "index_conversations_on_account_id_and_display_id", unique: true, using: :btree - t.index ["account_id"], name: "index_conversations_on_account_id", using: :btree + t.boolean "locked", default: false + t.index ["account_id", "display_id"], name: "index_conversations_on_account_id_and_display_id", unique: true + t.index ["account_id"], name: "index_conversations_on_account_id" end - create_table "facebook_pages", force: :cascade do |t| - t.string "name", null: false - t.string "page_id", null: false - t.string "user_access_token", null: false - t.string "page_access_token", null: false - t.integer "account_id", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "avatar" - t.index ["page_id"], name: "index_facebook_pages_on_page_id", using: :btree - end - - create_table "inbox_members", force: :cascade do |t| - t.integer "user_id", null: false - t.integer "inbox_id", null: false + create_table "facebook_pages", id: :serial, force: :cascade do |t| + t.string "name", null: false + t.string "page_id", null: false + t.string "user_access_token", null: false + t.string "page_access_token", null: false + t.integer "account_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.index ["inbox_id"], name: "index_inbox_members_on_inbox_id", using: :btree + t.string "avatar" + t.index ["page_id"], name: "index_facebook_pages_on_page_id" end - create_table "inboxes", force: :cascade do |t| - t.integer "channel_id", null: false - t.integer "account_id", null: false - t.string "name", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "channel_type" - t.index ["account_id"], name: "index_inboxes_on_account_id", using: :btree + create_table "inbox_members", id: :serial, force: :cascade do |t| + t.integer "user_id", null: false + t.integer "inbox_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["inbox_id"], name: "index_inbox_members_on_inbox_id" end - create_table "messages", force: :cascade do |t| - t.text "content" - t.integer "account_id", null: false - t.integer "inbox_id", null: false - t.integer "conversation_id", null: false - t.integer "message_type", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.boolean "private", default: false - t.integer "user_id" - t.integer "status", default: 0 - t.string "fb_id" - t.index ["conversation_id"], name: "index_messages_on_conversation_id", using: :btree + create_table "inboxes", id: :serial, force: :cascade do |t| + t.integer "channel_id", null: false + t.integer "account_id", null: false + t.string "name", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "channel_type" + t.index ["account_id"], name: "index_inboxes_on_account_id" end - create_table "subscriptions", force: :cascade do |t| - t.string "pricing_version" - t.integer "account_id" + create_table "messages", id: :serial, force: :cascade do |t| + t.text "content" + t.integer "account_id", null: false + t.integer "inbox_id", null: false + t.integer "conversation_id", null: false + t.integer "message_type", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "private", default: false + t.integer "user_id" + t.integer "status", default: 0 + t.string "fb_id" + t.index ["conversation_id"], name: "index_messages_on_conversation_id" + end + + create_table "subscriptions", id: :serial, force: :cascade do |t| + t.string "pricing_version" + t.integer "account_id" t.datetime "expiry" - t.string "billing_plan", default: "trial" - t.string "stripe_customer_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "state", default: 0 - t.boolean "payment_source_added", default: false + t.string "billing_plan", default: "trial" + t.string "stripe_customer_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "state", default: 0 + t.boolean "payment_source_added", default: false end - create_table "taggings", force: :cascade do |t| - t.integer "tag_id" - t.string "taggable_type" - t.integer "taggable_id" - t.string "tagger_type" - t.integer "tagger_id" - t.string "context", limit: 128 + create_table "taggings", id: :serial, force: :cascade do |t| + t.integer "tag_id" + t.string "taggable_type" + t.integer "taggable_id" + t.string "tagger_type" + t.integer "tagger_id" + t.string "context", limit: 128 t.datetime "created_at" - t.index ["context"], name: "index_taggings_on_context", using: :btree - t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree - t.index ["tag_id"], name: "index_taggings_on_tag_id", using: :btree - t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree - t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy", using: :btree - t.index ["taggable_id"], name: "index_taggings_on_taggable_id", using: :btree - t.index ["taggable_type"], name: "index_taggings_on_taggable_type", using: :btree - t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type", using: :btree - t.index ["tagger_id"], name: "index_taggings_on_tagger_id", using: :btree + t.index ["context"], name: "index_taggings_on_context" + t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true + t.index ["tag_id"], name: "index_taggings_on_tag_id" + t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context" + t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy" + t.index ["taggable_id"], name: "index_taggings_on_taggable_id" + t.index ["taggable_type", "taggable_id"], name: "index_taggings_on_taggable_type_and_taggable_id" + t.index ["taggable_type"], name: "index_taggings_on_taggable_type" + t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type" + t.index ["tagger_id"], name: "index_taggings_on_tagger_id" + t.index ["tagger_type", "tagger_id"], name: "index_taggings_on_tagger_type_and_tagger_id" end - create_table "tags", force: :cascade do |t| - t.string "name" + create_table "tags", id: :serial, force: :cascade do |t| + t.string "name" t.integer "taggings_count", default: 0 - t.index ["name"], name: "index_tags_on_name", unique: true, using: :btree + t.index ["name"], name: "index_tags_on_name", unique: true end - create_table "telegram_bots", force: :cascade do |t| - t.string "name" - t.string "auth_key" - t.integer "account_id" + create_table "telegram_bots", id: :serial, force: :cascade do |t| + t.string "name" + t.string "auth_key" + t.integer "account_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false end - create_table "users", force: :cascade do |t| - t.string "provider", default: "email", null: false - t.string "uid", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" + create_table "users", id: :serial, force: :cascade do |t| + t.string "provider", default: "email", null: false + t.string "uid", default: "", null: false + t.string "encrypted_password", default: "", null: false + t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false + t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.string "confirmation_token" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" + t.string "confirmation_token" t.datetime "confirmed_at" t.datetime "confirmation_sent_at" - t.string "unconfirmed_email" - t.string "name", null: false - t.string "nickname" - t.string "image" - t.string "email" - t.json "tokens" - t.integer "account_id", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "channel" - t.integer "role", default: 0 - t.index ["email"], name: "index_users_on_email", using: :btree - t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree - t.index ["uid", "provider"], name: "index_users_on_uid_and_provider", unique: true, using: :btree + t.string "unconfirmed_email" + t.string "name", null: false + t.string "nickname" + t.string "image" + t.string "email" + t.json "tokens" + t.integer "account_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "channel" + t.integer "role", default: 0 + t.index ["email"], name: "index_users_on_email" + t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true + t.index ["uid", "provider"], name: "index_users_on_uid_and_provider", unique: true end end diff --git a/db/seeds.rb b/db/seeds.rb index 494b2d065..c9f728a2b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -2,27 +2,29 @@ account = Account.create!([ {name: "Google"} ]) -User.create!([ - {email: "larry@google.com", encrypted_password: "$2a$11$CIyxMCfnm.FZ4arOR83AaORbgM7i2nrMPDKzxyfXd0fpkzumrWUlq", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, account_id: account.id} -]) +user = User.new({name:"lary", email: "larry@google.com", password: "123456", account_id: account.first.id}) +user.skip_confirmation! +user.save! - -Channel.create!([ +channels = Channel.create!([ {name: "Facebook Messenger"} ]) + +inboxes = Inbox.create!([ + {channel: channels.first, account_id: 1, name: "Google Car"}, + {channel: channels.first, account_id: 1, name: "Project Loon"} +]) + Contact.create!([ - {name: "izuck@facebook.com", email: nil, phone_number: "99496030692", channel_id: 1, account_id: 1} + {name: "izuck@facebook.com", email: nil, phone_number: "99496030692", inbox_id: inboxes.first.id, account_id: 1} ]) Conversation.create!([ - {account_id: 1, channel_id: 1, inbox_id: 1, status: nil, assignee_id: 1, sender_id: 1} -]) -Inbox.create!([ - {channel_id: 1, account_id: 1, name: "Google Car"}, - {channel_id: 1, account_id: 1, name: "Project Loon"} + {account_id: 1, inbox_id: 1, status: :open, assignee_id: 1, sender_id: 1} ]) + InboxMember.create!([ {user_id: 1, inbox_id: 1} ]) Message.create!([ - {content: "Hello", account_id: 1, channel_id: 1, inbox_id: 1, conversation_id: 1, type: nil} + {content: "Hello", account_id: 1, inbox_id: 1, conversation_id: 1, message_type: :incoming} ]) diff --git a/package.json b/package.json index d4610309e..756c33800 100644 --- a/package.json +++ b/package.json @@ -39,5 +39,6 @@ "babel-plugin-transform-vue-jsx": "^3.7.0", "babel-preset-env": "^1.7.0", "webpack-dev-server": "^3.7.2" - } + }, + "license": "UNLICENSED" }