From 194971da19de564cb9c4112f3caf2be477b4d7ab Mon Sep 17 00:00:00 2001 From: rubic0n Date: Sun, 10 Jan 2021 23:04:54 -0600 Subject: [PATCH 1/8] Install Redis 4+ since Sidekiq 5 needs that --- Vagrantfile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index 5e4d15b3..4ca75ecf 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -14,6 +14,12 @@ sudo apt-add-repository 'deb https://dl.yarnpkg.com/debian/ stable main' # Add repo for NodeJS curl -sL https://deb.nodesource.com/setup_10.x | sudo bash - +# Add repo for Redis (so we can have a newer version than 3.0.6) +# Sidekiq 5+ requires Redis 4+ +sudo add-apt-repository ppa:redislabs/redis + +sudo apt-get update + # Add firewall rule to redirect 80 to PORT and save sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port #{ENV["PORT"]} echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections @@ -29,7 +35,7 @@ sudo apt-get install \ libxslt1-dev \ imagemagick \ nodejs \ - redis-server \ + redis \ redis-tools \ postgresql \ postgresql-contrib \ @@ -42,6 +48,9 @@ sudo apt-get install \ libpam0g-dev \ -y +# Start Redis Server +sudo service redis-server start + # Install rvm read RUBY_VERSION < .ruby-version From 4f4f248fa1898d5f72e0bf5e35d9be578396eb94 Mon Sep 17 00:00:00 2001 From: rubic0n Date: Sun, 10 Jan 2021 23:05:57 -0600 Subject: [PATCH 2/8] postgresql_makara adapter is Postgres, not MySQL --- lib/gabsocial/migration_helpers.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/gabsocial/migration_helpers.rb b/lib/gabsocial/migration_helpers.rb index 5451ffca..67da012d 100644 --- a/lib/gabsocial/migration_helpers.rb +++ b/lib/gabsocial/migration_helpers.rb @@ -43,7 +43,9 @@ module GabSocial module MigrationHelpers # Stub for Database.postgresql? from GitLab def self.postgresql? - ActiveRecord::Base.configurations[Rails.env]['adapter'].casecmp('postgresql').zero? + %w[postgresql postgresql_makara].any? do |adapter| + ActiveRecord::Base.configurations[Rails.env]['adapter'].casecmp(adapter).zero? + end end # Stub for Database.mysql? from GitLab From 590dfc97e1a6cb5380c037489bc178cbbdcc6d2f Mon Sep 17 00:00:00 2001 From: rubic0n Date: Sun, 10 Jan 2021 23:14:20 -0600 Subject: [PATCH 3/8] Run pending migrations --- app/models/account.rb | 10 ++++----- app/models/backup.rb | 2 +- app/models/chat_conversation_account.rb | 2 +- app/models/custom_emoji.rb | 2 +- app/models/group.rb | 4 ++-- app/models/list_account.rb | 2 +- app/models/media_attachment.rb | 4 ++-- app/models/preview_card.rb | 2 +- app/models/site_upload.rb | 2 +- db/schema.rb | 27 ++++++++++++------------- 10 files changed, 28 insertions(+), 29 deletions(-) diff --git a/app/models/account.rb b/app/models/account.rb index 2fb330c0..70533165 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -3,7 +3,6 @@ # # Table name: accounts # -# id :bigint(8) not null, primary key # username :string default(""), not null # domain :string # secret :string default(""), not null @@ -20,11 +19,11 @@ # url :string # avatar_file_name :string # avatar_content_type :string -# avatar_file_size :integer +# avatar_file_size :bigint(8) # avatar_updated_at :datetime # header_file_name :string # header_content_type :string -# header_file_size :integer +# header_file_size :bigint(8) # header_updated_at :datetime # avatar_remote_url :string # subscription_expires_at :datetime @@ -36,6 +35,7 @@ # shared_inbox_url :string default(""), not null # followers_url :string default(""), not null # protocol :integer default(0), not null +# id :bigint(8) not null, primary key # memorial :boolean default(FALSE), not null # moved_to_account_id :bigint(8) # featured_collection_url :string @@ -43,10 +43,10 @@ # actor_type :string # discoverable :boolean # also_known_as :string is an Array -# silenced_at :datetime -# suspended_at :datetime # is_pro :boolean default(FALSE), not null # pro_expires_at :datetime +# silenced_at :datetime +# suspended_at :datetime # is_verified :boolean default(FALSE), not null # is_donor :boolean default(FALSE), not null # is_investor :boolean default(FALSE), not null diff --git a/app/models/backup.rb b/app/models/backup.rb index c2651313..82ca0340 100644 --- a/app/models/backup.rb +++ b/app/models/backup.rb @@ -7,7 +7,7 @@ # user_id :bigint(8) # dump_file_name :string # dump_content_type :string -# dump_file_size :integer +# dump_file_size :bigint(8) # dump_updated_at :datetime # processed :boolean default(FALSE), not null # created_at :datetime not null diff --git a/app/models/chat_conversation_account.rb b/app/models/chat_conversation_account.rb index dad54cac..b2ac7bda 100644 --- a/app/models/chat_conversation_account.rb +++ b/app/models/chat_conversation_account.rb @@ -12,7 +12,7 @@ # is_approved :boolean default(FALSE), not null # created_at :datetime not null # updated_at :datetime not null -# unread_count :bigint(8) default(0), not null +# unread_count :bigint(8) default(0) # chat_message_expiration_policy :string # is_muted :boolean default(FALSE), not null # diff --git a/app/models/custom_emoji.rb b/app/models/custom_emoji.rb index 9cfdc168..9b0ef516 100644 --- a/app/models/custom_emoji.rb +++ b/app/models/custom_emoji.rb @@ -8,7 +8,7 @@ # domain :string # image_file_name :string # image_content_type :string -# image_file_size :integer +# image_file_size :bigint(8) # image_updated_at :datetime # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/group.rb b/app/models/group.rb index a7bb71aa..d241399a 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -8,7 +8,7 @@ # description :string not null # cover_image_file_name :string # cover_image_content_type :string -# cover_image_file_size :integer +# cover_image_file_size :bigint(8) # cover_image_updated_at :datetime # is_nsfw :boolean default(FALSE), not null # is_featured :boolean default(FALSE), not null @@ -18,7 +18,7 @@ # member_count :integer default(0) # slug :text # is_private :boolean default(FALSE) -# is_visible :boolean default(FALSE) +# is_visible :boolean default(TRUE) # tags :string default([]), is an Array # password :string # group_category_id :integer diff --git a/app/models/list_account.rb b/app/models/list_account.rb index f26ba277..a93d1efc 100644 --- a/app/models/list_account.rb +++ b/app/models/list_account.rb @@ -6,7 +6,7 @@ # id :bigint(8) not null, primary key # list_id :bigint(8) not null # account_id :bigint(8) not null -# follow_id :bigint(8) default(1) +# follow_id :bigint(8) # class ListAccount < ApplicationRecord diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index 239329c4..4fbe14d7 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -3,11 +3,10 @@ # # Table name: media_attachments # -# id :bigint(8) not null, primary key # status_id :bigint(8) # file_file_name :string # file_content_type :string -# file_file_size :integer +# file_file_size :bigint(8) # file_updated_at :datetime # remote_url :string default(""), not null # created_at :datetime not null @@ -16,6 +15,7 @@ # type :integer default("image"), not null # file_meta :json # account_id :bigint(8) +# id :bigint(8) not null, primary key # description :text # scheduled_status_id :bigint(8) # blurhash :string diff --git a/app/models/preview_card.rb b/app/models/preview_card.rb index 36f9de5d..ea808578 100644 --- a/app/models/preview_card.rb +++ b/app/models/preview_card.rb @@ -9,7 +9,7 @@ # description :string default(""), not null # image_file_name :string # image_content_type :string -# image_file_size :integer +# image_file_size :bigint(8) # image_updated_at :datetime # type :integer default("link"), not null # html :text default(""), not null diff --git a/app/models/site_upload.rb b/app/models/site_upload.rb index cf10b30f..108115e3 100644 --- a/app/models/site_upload.rb +++ b/app/models/site_upload.rb @@ -7,7 +7,7 @@ # var :string default(""), not null # file_file_name :string # file_content_type :string -# file_file_size :integer +# file_file_size :bigint(8) # file_updated_at :datetime # meta :json # created_at :datetime not null diff --git a/db/schema.rb b/db/schema.rb index d5d48b48..32e23867 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -13,7 +13,6 @@ ActiveRecord::Schema.define(version: 2021_01_17_210100) do # These are extensions that must be enabled in order to support this database - enable_extension "pg_stat_statements" enable_extension "plpgsql" create_table "account_conversations", force: :cascade do |t| @@ -113,11 +112,11 @@ ActiveRecord::Schema.define(version: 2021_01_17_210100) do t.string "url" t.string "avatar_file_name" t.string "avatar_content_type" - t.integer "avatar_file_size" + t.bigint "avatar_file_size" t.datetime "avatar_updated_at" t.string "header_file_name" t.string "header_content_type" - t.integer "header_file_size" + t.bigint "header_file_size" t.datetime "header_updated_at" t.string "avatar_remote_url" t.datetime "subscription_expires_at" @@ -136,10 +135,10 @@ ActiveRecord::Schema.define(version: 2021_01_17_210100) do t.string "actor_type" t.boolean "discoverable" t.string "also_known_as", array: true - t.datetime "silenced_at" - t.datetime "suspended_at" t.boolean "is_pro", default: false, null: false t.datetime "pro_expires_at" + t.datetime "silenced_at" + t.datetime "suspended_at" t.boolean "is_verified", default: false, null: false t.boolean "is_donor", default: false, null: false t.boolean "is_investor", default: false, null: false @@ -180,7 +179,7 @@ ActiveRecord::Schema.define(version: 2021_01_17_210100) do t.bigint "user_id" t.string "dump_file_name" t.string "dump_content_type" - t.integer "dump_file_size" + t.bigint "dump_file_size" t.datetime "dump_updated_at" t.boolean "processed", default: false, null: false t.datetime "created_at", null: false @@ -223,7 +222,7 @@ ActiveRecord::Schema.define(version: 2021_01_17_210100) do t.boolean "is_approved", default: false, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.bigint "unread_count", default: 0, null: false + t.bigint "unread_count", default: 0 t.string "chat_message_expiration_policy" t.boolean "is_muted", default: false, null: false t.index ["account_id"], name: "index_chat_conversation_accounts_on_account_id" @@ -258,7 +257,7 @@ ActiveRecord::Schema.define(version: 2021_01_17_210100) do t.string "domain" t.string "image_file_name" t.string "image_content_type" - t.integer "image_file_size" + t.bigint "image_file_size" t.datetime "image_updated_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false @@ -372,7 +371,7 @@ ActiveRecord::Schema.define(version: 2021_01_17_210100) do t.string "description", null: false t.string "cover_image_file_name" t.string "cover_image_content_type" - t.integer "cover_image_file_size" + t.bigint "cover_image_file_size" t.datetime "cover_image_updated_at" t.boolean "is_nsfw", default: false, null: false t.boolean "is_featured", default: false, null: false @@ -382,7 +381,7 @@ ActiveRecord::Schema.define(version: 2021_01_17_210100) do t.integer "member_count", default: 0 t.text "slug" t.boolean "is_private", default: false - t.boolean "is_visible", default: false + t.boolean "is_visible", default: true t.string "tags", default: [], array: true t.string "password" t.integer "group_category_id" @@ -409,7 +408,7 @@ ActiveRecord::Schema.define(version: 2021_01_17_210100) do create_table "list_accounts", force: :cascade do |t| t.bigint "list_id", null: false t.bigint "account_id", null: false - t.bigint "follow_id", default: 1 + t.bigint "follow_id" t.index ["account_id", "list_id"], name: "index_list_accounts_on_account_id_and_list_id", unique: true t.index ["follow_id"], name: "index_list_accounts_on_follow_id" t.index ["list_id", "account_id"], name: "index_list_accounts_on_list_id_and_account_id" @@ -439,7 +438,7 @@ ActiveRecord::Schema.define(version: 2021_01_17_210100) do t.bigint "status_id" t.string "file_file_name" t.string "file_content_type" - t.integer "file_file_size" + t.bigint "file_file_size" t.datetime "file_updated_at" t.string "remote_url", default: "", null: false t.datetime "created_at", null: false @@ -581,7 +580,7 @@ ActiveRecord::Schema.define(version: 2021_01_17_210100) do t.string "description", default: "", null: false t.string "image_file_name" t.string "image_content_type" - t.integer "image_file_size" + t.bigint "image_file_size" t.datetime "image_updated_at" t.integer "type", default: 0, null: false t.text "html", default: "", null: false @@ -684,7 +683,7 @@ ActiveRecord::Schema.define(version: 2021_01_17_210100) do t.string "var", default: "", null: false t.string "file_file_name" t.string "file_content_type" - t.integer "file_file_size" + t.bigint "file_file_size" t.datetime "file_updated_at" t.json "meta" t.datetime "created_at", null: false From 70c29c6cbd505d1b7b9162b9d932267e7a508b8b Mon Sep 17 00:00:00 2001 From: rubic0n Date: Sun, 10 Jan 2021 23:17:12 -0600 Subject: [PATCH 4/8] Fix "ERR! error: password authentication failed for user "vagrant"" --- .env.vagrant | 1 + config/database.yml | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.env.vagrant b/.env.vagrant index 5fdcc11e..28c347c4 100644 --- a/.env.vagrant +++ b/.env.vagrant @@ -1,2 +1,3 @@ VAGRANT=true LOCAL_DOMAIN=gabsocial.local +DB_HOST=/var/run/postgresql/ diff --git a/config/database.yml b/config/database.yml index ef536a3c..01e761af 100644 --- a/config/database.yml +++ b/config/database.yml @@ -5,6 +5,13 @@ default: &default encoding: unicode sslmode: <%= ENV['DB_SSLMODE'] || "prefer" %> +dev_connection: &dev_connection + database: <%= ENV['DB_NAME'] || 'gabsocial_development' %> + username: <%= ENV['DB_USER'] %> + password: <%= ENV['DB_PASS'] %> + host: <%= ENV['DB_HOST'] %> + port: <%= ENV['DB_PORT'] %> + development: <<: *default adapter: postgresql_makara @@ -14,10 +21,10 @@ development: sticky: true connections: - role: master + <<: *dev_connection blacklist_duration: 0 - url: postgresql://<%= ENV['DB_USER']%>:<%= ENV['DB_PASS'] %>@<%= ENV['DB_HOST'] %>:<%= ENV['DB_PORT'] %>/<%= ENV['DB_NAME'] || 'gabsocial_development' %> - role: slave - url: postgresql://<%= ENV['DB_USER']%>:<%= ENV['DB_PASS'] %>@<%= ENV['DB_HOST'] %>:<%= ENV['DB_PORT'] %>/<%= ENV['DB_NAME'] || 'gabsocial_development' %> + <<: *dev_connection # database: <%= ENV['DB_NAME'] || 'gabsocial_development' %> # username: <%= ENV['DB_USER'] %> From 28beb28a785a47f78806fc79cbbbac2a5dea6c88 Mon Sep 17 00:00:00 2001 From: rubic0n Date: Sat, 23 Jan 2021 00:19:47 -0600 Subject: [PATCH 5/8] Upgrade to Rails 6 - Added listen gem because rails app:update failed without it - Removes nsa gem because it requires activesupport < 6 Oddly, there's a newer version per GitHub that's not on RubyGems that raises the requirement to < 7. But, we need a new release before we can use that. - Upgrade rails-i18n to v6, for Rails 6 compatibility - Remove redis-rails since it requires Rails < 6, but we can just use the regular Rails :redis_cache_store that was introduced in 5.2. - Run `rails app:update` - Had to weed through the `config/environments` changes to pick up newly added settings, while not losing settings that were intentionally configured - This generated config/initializers/new_framework_defaults_6_0.rb. The goal is to uncomment all of the settings in that file. Once they're all uncommented, delete the file and edit config/application.rb's load_defaults to be 6.0. - force_ssl controller method is deprecated in favor of a Rails config setting. - bin/setup was generated by Rails - Verbose query logging in development is really helpful. It shows you what line of code caused a query to execute. - Calling establish_connection after worker boot isn't necessary with ActiveRecord anymore. ActiveRecord handles it gracefully. - Rails generated a migration to add a foreign key for ActiveStorage. Gab currently doesn't use ActiveStorage, and instead uses Paperclip (since ActiveStorage didn't exist when Mastadon started). So, this change isn't relevant to Gab. - Added ` || ''` in the profiles controller, because I was unable to save a change to a newly created profile. (This probably explains the 500 error I received on prod Gab recently.) --- Gemfile | 8 +- Gemfile.lock | 265 +++++++++--------- app/controllers/application_controller.rb | 6 - .../settings/profiles_controller.rb | 2 +- bin/setup | 14 +- config/cable.yml | 10 + config/environments/development.rb | 10 +- config/environments/production.rb | 34 ++- config/environments/test.rb | 3 + .../new_framework_defaults_6_0.rb | 53 ++++ config/initializers/statsd.rb | 2 +- config/puma.rb | 6 - config/storage.yml | 34 +++ ..._attachments_for_blob_id.active_storage.rb | 10 + db/schema.rb | 12 +- 15 files changed, 306 insertions(+), 163 deletions(-) create mode 100644 config/cable.yml create mode 100644 config/initializers/new_framework_defaults_6_0.rb create mode 100644 config/storage.yml create mode 100644 db/migrate/20210123050026_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.active_storage.rb diff --git a/Gemfile b/Gemfile index 0de8faf1..3b85f197 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ ruby '>= 2.4.0', '< 2.7.0' gem 'pkg-config', '~> 1.3' gem 'puma', '~> 5.0' -gem 'rails', '~> 5.2.3' +gem 'rails', '6.0.3.4' gem 'thor', '~> 0.20' gem 'hamlit-rails', '~> 0.2' @@ -59,7 +59,7 @@ gem 'kaminari', '~> 1.1' gem 'link_header', '~> 0.0' gem 'mime-types', '~> 3.2', require: 'mime/types/columnar' gem 'nokogiri', '~> 1.10' -gem 'nsa', '~> 0.2' +# gem 'nsa', '~> 0.2' gem 'oj', '~> 3.7' gem 'ostatus2', '~> 2.0' gem 'ox', '~> 2.10' @@ -68,7 +68,7 @@ gem 'pundit', '~> 2.0' gem 'premailer-rails' gem 'rack-attack', '~> 6.0' gem 'rack-cors', '~> 1.0', require: 'rack/cors' -gem 'rails-i18n', '~> 5.1' +gem 'rails-i18n', '~> 6.0.0' gem 'rails-settings-cached', '~> 0.6' gem 'redis', '~> 4.2', require: ['redis', 'redis/connection/hiredis'] gem 'mario-redis-lock', '~> 1.2', require: 'redis_lock' @@ -127,6 +127,7 @@ group :development do gem 'better_errors', '~> 2.5' gem 'binding_of_caller', '~> 0.7' gem 'bullet', '~> 6.0' + gem 'listen' gem 'letter_opener', '~> 1.7' gem 'letter_opener_web', '~> 1.3' gem 'memory_profiler' @@ -146,7 +147,6 @@ end group :production do gem 'lograge', '~> 0.11' - gem 'redis-rails', '~> 5.0' end gem 'concurrent-ruby', require: false diff --git a/Gemfile.lock b/Gemfile.lock index e8dff848..e61f0d49 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,53 +15,67 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (5.2.4.4) - actionpack (= 5.2.4.4) + actioncable (6.0.3.4) + actionpack (= 6.0.3.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.4.4) - actionpack (= 5.2.4.4) - actionview (= 5.2.4.4) - activejob (= 5.2.4.4) + actionmailbox (6.0.3.4) + actionpack (= 6.0.3.4) + activejob (= 6.0.3.4) + activerecord (= 6.0.3.4) + activestorage (= 6.0.3.4) + activesupport (= 6.0.3.4) + mail (>= 2.7.1) + actionmailer (6.0.3.4) + actionpack (= 6.0.3.4) + actionview (= 6.0.3.4) + activejob (= 6.0.3.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.4.4) - actionview (= 5.2.4.4) - activesupport (= 5.2.4.4) + actionpack (6.0.3.4) + actionview (= 6.0.3.4) + activesupport (= 6.0.3.4) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.4.4) - activesupport (= 5.2.4.4) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.0.3.4) + actionpack (= 6.0.3.4) + activerecord (= 6.0.3.4) + activestorage (= 6.0.3.4) + activesupport (= 6.0.3.4) + nokogiri (>= 1.8.5) + actionview (6.0.3.4) + activesupport (= 6.0.3.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - active_model_serializers (0.10.11) - actionpack (>= 4.1, < 6.1) - activemodel (>= 4.1, < 6.1) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + active_model_serializers (0.10.12) + actionpack (>= 4.1, < 6.2) + activemodel (>= 4.1, < 6.2) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) active_record_query_trace (1.8) - activejob (5.2.4.4) - activesupport (= 5.2.4.4) + activejob (6.0.3.4) + activesupport (= 6.0.3.4) globalid (>= 0.3.6) - activemodel (5.2.4.4) - activesupport (= 5.2.4.4) - activerecord (5.2.4.4) - activemodel (= 5.2.4.4) - activesupport (= 5.2.4.4) - arel (>= 9.0) - activestorage (5.2.4.4) - actionpack (= 5.2.4.4) - activerecord (= 5.2.4.4) + activemodel (6.0.3.4) + activesupport (= 6.0.3.4) + activerecord (6.0.3.4) + activemodel (= 6.0.3.4) + activesupport (= 6.0.3.4) + activestorage (6.0.3.4) + actionpack (= 6.0.3.4) + activejob (= 6.0.3.4) + activerecord (= 6.0.3.4) marcel (~> 0.3.1) - activesupport (5.2.4.4) + activesupport (6.0.3.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) + zeitwerk (~> 2.2, >= 2.2.2) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) airbrussh (1.4.0) @@ -69,23 +83,22 @@ GEM annotate (2.7.5) activerecord (>= 3.2, < 7.0) rake (>= 10.4, < 13.0) - arel (9.0.0) ast (2.4.1) attr_encrypted (3.1.0) encryptor (~> 3.0.0) av (0.9.0) cocaine (~> 0.5.3) aws-eventstream (1.1.0) - aws-partitions (1.404.0) - aws-sdk-core (3.110.0) + aws-partitions (1.418.0) + aws-sdk-core (3.111.2) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-kms (1.39.0) + aws-sdk-kms (1.41.0) aws-sdk-core (~> 3, >= 3.109.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.86.0) + aws-sdk-s3 (1.87.0) aws-sdk-core (~> 3, >= 3.109.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.1) @@ -103,17 +116,17 @@ GEM ffi (~> 1.10.0) bootsnap (1.5.1) msgpack (~> 1.0) - brakeman (4.10.0) - browser (5.1.0) + brakeman (4.10.1) + browser (5.3.0) builder (3.2.4) - bullet (6.1.0) + bullet (6.1.3) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) bundler-audit (0.7.0.1) bundler (>= 1.2.0, < 3) thor (>= 0.18, < 2) byebug (11.1.3) - capistrano (3.14.1) + capistrano (3.15.0) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) @@ -143,26 +156,29 @@ GEM activesupport (>= 4.0) elasticsearch (>= 2.0.0) elasticsearch-dsl - chunky_png (1.3.14) + chunky_png (1.4.0) cld3 (3.2.6) ffi (>= 1.1.0, < 1.12.0) climate_control (0.2.0) cocaine (0.5.8) climate_control (>= 0.0.3, < 1.0) coderay (1.1.3) - concurrent-ruby (1.1.7) + concurrent-ruby (1.1.8) connection_pool (2.2.3) - crack (0.4.4) + crack (0.4.5) + rexml crass (1.0.6) - css_parser (1.7.1) + css_parser (1.8.0) addressable - debug_inspector (0.0.3) - derailed_benchmarks (1.8.1) + dead_end (1.1.3) + debug_inspector (1.0.0) + derailed_benchmarks (2.0.0) benchmark-ips (~> 2) + dead_end get_process_mem (~> 0) heapy (~> 0) - memory_profiler (~> 0) - mini_histogram (>= 0.2.1) + memory_profiler (>= 0, < 2) + mini_histogram (>= 0.3.0) rack (>= 1) rake (> 10, < 14) ruby-statistics (>= 2.1) @@ -183,7 +199,7 @@ GEM devise (>= 4.0.0) rpam2 (~> 4.0) diff-lcs (1.4.4) - docile (1.3.2) + docile (1.3.5) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) doorkeeper (5.4.0) @@ -193,13 +209,13 @@ GEM dotenv (= 2.7.6) railties (>= 3.2) e2mmap (0.1.0) - elasticsearch (7.10.0) - elasticsearch-api (= 7.10.0) - elasticsearch-transport (= 7.10.0) - elasticsearch-api (7.10.0) + elasticsearch (7.10.1) + elasticsearch-api (= 7.10.1) + elasticsearch-transport (= 7.10.1) + elasticsearch-api (7.10.1) multi_json elasticsearch-dsl (0.1.9) - elasticsearch-transport (7.10.0) + elasticsearch-transport (7.10.1) faraday (~> 1) multi_json encryptor (3.0.0) @@ -210,11 +226,13 @@ GEM fabrication (2.21.1) faker (1.9.6) i18n (>= 0.7) - faraday (1.1.0) + faraday (1.3.0) + faraday-net_http (~> 1.0) multipart-post (>= 1.2, < 3) ruby2_keywords + faraday-net_http (1.0.1) fast_blank (1.0.0) - fastimage (2.2.0) + fastimage (2.2.1) ffi (1.10.0) fog-core (2.1.0) builder @@ -229,10 +247,10 @@ GEM fog-json (>= 1.0) ipaddress (>= 0.8) formatador (0.2.5) - fugit (1.4.1) + fugit (1.4.2) et-orbi (~> 1.1, >= 1.1.8) raabro (~> 1.4) - fuubar (2.5.0) + fuubar (2.5.1) rspec-core (~> 3.0) ruby-progressbar (~> 1.4) get_process_mem (0.2.7) @@ -244,7 +262,7 @@ GEM http (~> 3.0) nokogiri (~> 1.8) oj (~> 3.0) - hamlit (2.13.0) + hamlit (2.14.2) temple (>= 0.8.2) thor tilt @@ -275,9 +293,9 @@ GEM httplog (1.4.3) rack (>= 1.0) rainbow (>= 2.0.0) - i18n (1.8.5) + i18n (1.8.7) concurrent-ruby (~> 1.0) - i18n-tasks (0.9.31) + i18n-tasks (0.9.33) activesupport (>= 4.0.2) ast (>= 2.1.0) erubi @@ -291,16 +309,16 @@ GEM ipaddress (0.8.3) iso-639 (0.3.5) jmespath (1.4.0) - json (2.3.1) + json (2.5.1) json-canonicalization (0.2.0) - json-ld (3.1.5) + json-ld (3.1.7) htmlentities (~> 4.3) json-canonicalization (~> 0.2) link_header (~> 0.0, >= 0.0.8) multi_json (~> 1.14) rack (~> 2.0) rdf (~> 3.1) - json-ld-preloaded (3.1.3) + json-ld-preloaded (3.1.4) json-ld (~> 3.1) rdf (~> 3.1) jsonapi-renderer (0.2.2) @@ -326,23 +344,26 @@ GEM letter_opener (~> 1.0) railties (>= 3.2) link_header (0.0.8) + listen (3.4.1) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) lograge (0.11.2) actionpack (>= 4) activesupport (>= 4) railties (>= 4) request_store (~> 1.0) - loofah (2.8.0) + loofah (2.9.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - makara (0.4.1) + makara (0.5.0) activerecord (>= 3.0.0) marcel (0.3.3) mimemagic (~> 0.3.2) mario-redis-lock (1.2.1) redis (>= 3.0.5) - memory_profiler (0.9.14) + memory_profiler (1.0.0) method_source (1.0.0) microformats (4.2.1) json (~> 2.2) @@ -353,8 +374,8 @@ GEM mimemagic (0.3.5) mini_histogram (0.3.1) mini_mime (1.0.2) - mini_portile2 (2.4.0) - minitest (5.14.2) + mini_portile2 (2.5.0) + minitest (5.14.3) msgpack (1.3.3) multi_json (1.15.0) multipart-post (2.1.1) @@ -363,16 +384,12 @@ GEM net-ssh (>= 2.6.5, < 7.0.0) net-ssh (6.1.0) nio4r (2.5.4) - nokogiri (1.10.10) - mini_portile2 (~> 2.4.0) + nokogiri (1.11.1) + mini_portile2 (~> 2.5.0) + racc (~> 1.4) nokogumbo (2.0.4) nokogiri (~> 1.8, >= 1.8.4) - nsa (0.2.7) - activesupport (>= 4.2, < 6) - concurrent-ruby (~> 1.0, >= 1.0.2) - sidekiq (>= 3.5) - statsd-ruby (~> 1.4, >= 1.4.0) - oj (3.10.16) + oj (3.11.0) omniauth (1.9.1) hashie (>= 3.4.6) rack (>= 1.6.2, < 3) @@ -388,7 +405,7 @@ GEM addressable (~> 2.5) http (~> 3.0) nokogiri (~> 1.8) - ox (2.13.4) + ox (2.14.1) paperclip (6.1.0) activemodel (>= 4.2.0) activesupport (>= 4.2.0) @@ -401,7 +418,7 @@ GEM parallel (1.20.1) parallel_tests (2.32.0) parallel - parser (2.7.2.0) + parser (3.0.0.0) ast (~> 2.4.1) pastel (0.8.0) tty-color (~> 0.5) @@ -426,11 +443,12 @@ GEM pry-rails (0.3.9) pry (>= 0.10.4) public_suffix (4.0.6) - puma (5.1.0) + puma (5.1.1) nio4r (~> 2.0) pundit (2.1.0) activesupport (>= 3.0.0) raabro (1.4.0) + racc (1.5.2) rack (2.2.3) rack-attack (6.3.1) rack (>= 1.0, < 3) @@ -440,18 +458,20 @@ GEM rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.4.4) - actioncable (= 5.2.4.4) - actionmailer (= 5.2.4.4) - actionpack (= 5.2.4.4) - actionview (= 5.2.4.4) - activejob (= 5.2.4.4) - activemodel (= 5.2.4.4) - activerecord (= 5.2.4.4) - activestorage (= 5.2.4.4) - activesupport (= 5.2.4.4) + rails (6.0.3.4) + actioncable (= 6.0.3.4) + actionmailbox (= 6.0.3.4) + actionmailer (= 6.0.3.4) + actionpack (= 6.0.3.4) + actiontext (= 6.0.3.4) + actionview (= 6.0.3.4) + activejob (= 6.0.3.4) + activemodel (= 6.0.3.4) + activerecord (= 6.0.3.4) + activestorage (= 6.0.3.4) + activesupport (= 6.0.3.4) bundler (>= 1.3.0) - railties (= 5.2.4.4) + railties (= 6.0.3.4) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -462,47 +482,31 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) - rails-i18n (5.1.3) + rails-i18n (6.0.0) i18n (>= 0.7, < 2) - railties (>= 5.0, < 6) + railties (>= 6.0.0, < 7) rails-settings-cached (0.7.2) rails (>= 4.2.0) - railties (5.2.4.4) - actionpack (= 5.2.4.4) - activesupport (= 5.2.4.4) + railties (6.0.3.4) + actionpack (= 6.0.3.4) + activesupport (= 6.0.3.4) method_source rake (>= 0.8.7) - thor (>= 0.19.0, < 2.0) + thor (>= 0.20.3, < 2.0) rainbow (3.0.0) rake (12.3.3) rb-fsevent (0.10.4) rb-inotify (0.10.1) ffi (~> 1.0) - rdf (3.1.7) + rdf (3.1.9) hamster (~> 3.0) link_header (~> 0.0, >= 0.0.8) rdf-normalize (0.4.0) rdf (~> 3.1) - redcarpet (3.5.0) + redcarpet (3.5.1) redis (4.2.5) - redis-actionpack (5.2.0) - actionpack (>= 5, < 7) - redis-rack (>= 2.1.0, < 3) - redis-store (>= 1.1.0, < 2) - redis-activesupport (5.2.0) - activesupport (>= 3, < 7) - redis-store (>= 1.3, < 2) redis-namespace (1.8.0) redis (>= 3.0.4) - redis-rack (2.1.3) - rack (>= 2.0.8, < 3) - redis-store (>= 1.2, < 2) - redis-rails (5.0.2) - redis-actionpack (>= 5.0, < 6) - redis-activesupport (>= 5.0, < 6) - redis-store (>= 1.2, < 2) - redis-store (1.9.0) - redis (>= 4, < 5) regexp_parser (1.8.2) request_store (1.5.0) rack (>= 1.4) @@ -543,16 +547,16 @@ GEM rubocop-ast (>= 0.6.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (1.3.0) + rubocop-ast (1.4.0) parser (>= 2.7.1.5) - ruby-progressbar (1.10.1) + ruby-progressbar (1.11.0) ruby-saml (1.11.0) nokogiri (>= 1.5.10) ruby-statistics (2.1.2) - ruby2_keywords (0.0.2) - rufus-scheduler (3.6.0) + ruby2_keywords (0.0.4) + rufus-scheduler (3.7.0) fugit (~> 1.1, >= 1.1.6) - sanitize (5.2.1) + sanitize (5.2.3) crass (~> 1.0.2) nokogiri (>= 1.8.0) nokogumbo (~> 2.0) @@ -563,7 +567,7 @@ GEM rb-inotify (~> 0.9, >= 0.9.7) scss_lint (0.59.0) sass (~> 3.5, >= 3.5.5) - sidekiq (6.1.2) + sidekiq (6.1.3) connection_pool (>= 2.2.2) rack (~> 2.0) redis (>= 4.2.0) @@ -585,7 +589,7 @@ GEM simple_form (4.1.0) actionpack (>= 5.0) activemodel (>= 5.0) - simplecov (0.20.0) + simplecov (0.21.2) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) @@ -598,15 +602,14 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sshkit (1.21.1) + sshkit (1.21.2) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) stackprof (0.2.16) - statsd-ruby (1.4.0) stoplight (2.1.3) streamio-ffmpeg (3.0.2) multi_json (~> 1.8) - strong_migrations (0.7.3) + strong_migrations (0.7.6) activerecord (>= 5) temple (0.8.2) terminal-table (2.0.0) @@ -622,7 +625,7 @@ GEM tty-command (0.10.0) pastel (~> 0.8) tty-cursor (0.7.1) - tty-prompt (0.22.0) + tty-prompt (0.23.0) pastel (~> 0.8) tty-reader (~> 0.8) tty-reader (0.9.0) @@ -632,18 +635,18 @@ GEM tty-screen (0.8.1) twitter-text (1.14.7) unf (~> 0.1.0) - tzinfo (1.2.8) + tzinfo (1.2.9) thread_safe (~> 0.1) - tzinfo-data (1.2020.4) + tzinfo-data (1.2020.6) tzinfo (>= 1.0.0) unf (0.1.4) unf_ext unf_ext (0.0.7.7) unicode-display_width (1.7.0) - uniform_notifier (1.13.0) + uniform_notifier (1.13.2) warden (1.2.9) rack (>= 2.0.9) - webmock (3.10.0) + webmock (3.11.1) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) @@ -660,6 +663,7 @@ GEM wisper (2.0.1) xpath (3.2.0) nokogiri (~> 1.8) + zeitwerk (2.4.2) PLATFORMS ruby @@ -718,6 +722,7 @@ DEPENDENCIES letter_opener (~> 1.7) letter_opener_web (~> 1.3) link_header (~> 0.0) + listen lograge (~> 0.11) makara (~> 0.4) mario-redis-lock (~> 1.2) @@ -726,7 +731,6 @@ DEPENDENCIES mime-types (~> 3.2) net-ldap (~> 0.10) nokogiri (~> 1.10) - nsa (~> 0.2) oj (~> 3.7) omniauth (~> 1.9) omniauth-cas (~> 1.1) @@ -748,15 +752,14 @@ DEPENDENCIES pundit (~> 2.0) rack-attack (~> 6.0) rack-cors (~> 1.0) - rails (~> 5.2.3) + rails (= 6.0.3.4) rails-controller-testing (~> 1.0) - rails-i18n (~> 5.1) + rails-i18n (~> 6.0.0) rails-settings-cached (~> 0.6) rdf-normalize (~> 0.3) redcarpet (~> 3.4) redis (~> 4.2) redis-namespace (~> 1.5) - redis-rails (~> 5.0) rqrcode (~> 0.10) rspec-rails (~> 3.8) rspec-sidekiq (~> 3.0) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f621bff5..f1e67e8e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,8 +5,6 @@ class ApplicationController < ActionController::Base # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception - force_ssl if: :https_enabled? - include Localized include UserTrackingConcern include SessionTrackingConcern @@ -31,10 +29,6 @@ class ApplicationController < ActionController::Base private - def https_enabled? - Rails.env.production? - end - def store_current_location store_location_for(:user, request.url) if request.format == :html end diff --git a/app/controllers/settings/profiles_controller.rb b/app/controllers/settings/profiles_controller.rb index 0624f4d5..9e1b3d18 100644 --- a/app/controllers/settings/profiles_controller.rb +++ b/app/controllers/settings/profiles_controller.rb @@ -25,7 +25,7 @@ class Settings::ProfilesController < Settings::BaseController AccountUsernameChange.create!( account: @account, from_username: @account.username, - to_username: params[:account][:username] + to_username: params[:account][:username] || '' ) end diff --git a/bin/setup b/bin/setup index fc77b080..5853b5ea 100755 --- a/bin/setup +++ b/bin/setup @@ -1,6 +1,5 @@ #!/usr/bin/env ruby require 'fileutils' -include FileUtils # path to your application root. APP_ROOT = File.expand_path('..', __dir__) @@ -9,22 +8,25 @@ 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') - system!('yarn 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/config/cable.yml b/config/cable.yml new file mode 100644 index 00000000..7163e4c2 --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: test + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: gab_social_production diff --git a/config/environments/development.rb b/config/environments/development.rb index 0791b82a..2e09fee7 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -17,7 +17,7 @@ Rails.application.configure do if Rails.root.join('tmp/caching-dev.txt').exist? config.action_controller.perform_caching = true - config.cache_store = :redis_store, ENV['REDIS_URL'], REDIS_CACHE_PARAMS + config.cache_store = :redis_cache_store, REDIS_CACHE_PARAMS.merge(url: ENV['REDIS_URL']) config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{2.days.to_i}", @@ -38,6 +38,9 @@ Rails.application.configure do config.x.vapid_private_key = vapid_key.private_key config.x.vapid_public_key = vapid_key.public_key + # 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 @@ -49,6 +52,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. @@ -76,6 +82,8 @@ Rails.application.configure do # Otherwise, use letter_opener, which launches a browser window to view sent mail. config.action_mailer.delivery_method = (ENV['HEROKU'] || ENV['VAGRANT'] || ENV['REMOTE_DEV']) ? :letter_opener_web : :letter_opener + config.file_watcher = ActiveSupport::EventedFileUpdateChecker + config.after_initialize do Bullet.enable = true Bullet.bullet_logger = true diff --git a/config/environments/production.rb b/config/environments/production.rb index a692578b..071543bd 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -41,9 +41,20 @@ 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 + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + # Allow to specify public IP of reverse proxy if it's needed config.action_dispatch.trusted_proxies = ENV['TRUSTED_PROXY_IP'].split.map { |item| IPAddr.new(item) } if ENV['TRUSTED_PROXY_IP'].present? + # 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.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + config.force_ssl = true + # Use the lowest log level to ensure availability of diagnostic information # when problems arise. config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info').to_sym @@ -52,7 +63,7 @@ Rails.application.configure do config.log_tags = [:request_id] # Use a different cache store in production. - config.cache_store = :redis_store, ENV['CACHE_REDIS_URL'], REDIS_CACHE_PARAMS + config.cache_store = :redis_cache_store, REDIS_CACHE_PARAMS.merge(url: ENV['CACHE_REDIS_URL']) # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. @@ -102,4 +113,25 @@ Rails.application.configure do } config.x.otp_secret = ENV.fetch('OTP_SECRET') + + # 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 a35cadcf..6f591d93 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -27,6 +27,9 @@ Rails.application.configure do # and should not be used. config.cache_store = :memory_store + # Store uploaded files on the local file system in a temporary directory. + config.active_storage.service = :test + # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false 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 00000000..d45195a0 --- /dev/null +++ b/config/initializers/new_framework_defaults_6_0.rb @@ -0,0 +1,53 @@ +# 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 + + +# The Rails 6 default autoloader is Zeitwerk. Zeitwerk has specific expectations on where certain +# classes should be defined. It also requires that constants are not autoloaded in initializers. +# Enabling Zeitwerk would be good, but it'll take some work. Using the :classic autoloader gives +# us the same autoloading that Rails 5.2 had. +# Rails.application.config.autoloader = :zeitwerk +Rails.application.config.autoloader = :classic diff --git a/config/initializers/statsd.rb b/config/initializers/statsd.rb index 17f23956..52a0b1f6 100644 --- a/config/initializers/statsd.rb +++ b/config/initializers/statsd.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -if ENV['STATSD_ADDR'].present? +if false && ENV['STATSD_ADDR'].present? host, port = ENV['STATSD_ADDR'].split(':') statsd = ::Statsd.new(host, port) diff --git a/config/puma.rb b/config/puma.rb index 1afdb1c6..e941ae13 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -12,10 +12,4 @@ workers ENV.fetch('WEB_CONCURRENCY') { 2 } preload_app! -on_worker_boot do - ActiveSupport.on_load(:active_record) do - ActiveRecord::Base.establish_connection - end -end - plugin :tmp_restart diff --git a/config/storage.yml b/config/storage.yml new file mode 100644 index 00000000..d32f76e8 --- /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/20210123050026_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.active_storage.rb b/db/migrate/20210123050026_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.active_storage.rb new file mode 100644 index 00000000..ff5d72c7 --- /dev/null +++ b/db/migrate/20210123050026_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.active_storage.rb @@ -0,0 +1,10 @@ +# This migration comes from active_storage (originally 20180723000244) +class AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId < ActiveRecord::Migration[6.0] + def up + return if foreign_key_exists?(:active_storage_attachments, column: :blob_id) + + if table_exists?(:active_storage_blobs) + add_foreign_key :active_storage_attachments, :active_storage_blobs, column: :blob_id + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 32e23867..d5769f47 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2,15 +2,15 @@ # 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: 2021_01_17_210100) do +ActiveRecord::Schema.define(version: 2021_01_23_050026) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" From 2952c9f59d6aafcd12fb1acba5c91cbe23ebb9fd Mon Sep 17 00:00:00 2001 From: rubic0n Date: Sun, 24 Jan 2021 23:57:30 -0600 Subject: [PATCH 6/8] Simplify db config --- config/database.yml | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/config/database.yml b/config/database.yml index 01e761af..a66dc47c 100644 --- a/config/database.yml +++ b/config/database.yml @@ -5,32 +5,22 @@ default: &default encoding: unicode sslmode: <%= ENV['DB_SSLMODE'] || "prefer" %> -dev_connection: &dev_connection - database: <%= ENV['DB_NAME'] || 'gabsocial_development' %> - username: <%= ENV['DB_USER'] %> - password: <%= ENV['DB_PASS'] %> - host: <%= ENV['DB_HOST'] %> - port: <%= ENV['DB_PORT'] %> - development: <<: *default adapter: postgresql_makara prepared_statements: false + database: <%= ENV['DB_NAME'] || 'gabsocial_development' %> + username: <%= ENV['DB_USER'] %> + password: <%= ENV['DB_PASS'] %> + host: <%= ENV['DB_HOST'] %> + port: <%= ENV['DB_PORT'] %> makara: id: postgres sticky: true connections: - role: master - <<: *dev_connection blacklist_duration: 0 - role: slave - <<: *dev_connection - -# database: <%= ENV['DB_NAME'] || 'gabsocial_development' %> -# username: <%= ENV['DB_USER'] %> -# password: <%= ENV['DB_PASS'] %> -# host: <%= ENV['DB_HOST'] %> -# port: <%= ENV['DB_PORT'] %> # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". From a417cdcde6bc2666a1ab0bf49d7b12956097796f Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 27 Jan 2021 16:17:08 -0500 Subject: [PATCH 7/8] merging rails_6 with develop --- .env.development | 20 +++ migrations.sql | 311 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 331 insertions(+) create mode 100644 .env.development create mode 100644 migrations.sql diff --git a/.env.development b/.env.development new file mode 100644 index 00000000..b8beef80 --- /dev/null +++ b/.env.development @@ -0,0 +1,20 @@ +# Generated with gabsocial:setup on 2021-01-26 17:34:03 UTC + +LOCAL_DOMAIN=localhost +SINGLE_USER_MODE=false +SECRET_KEY_BASE=aa97516571e4cda8d27316788bf4a97c484744cb5fbd6d272389c4e6c675f0b40243073ba5cd606f8a0b39cc34c237fa3d66ef1e4a973c0db08ee56f51e70703 +OTP_SECRET=6bf15ce12656771ef4ca95ed86e6a31e2bc1975a1dc3e2387d951b733f5d1f34afd89d4061ca174946080420d37be9b51a207e5d54f8f4631b00ebfc8ef35f3c +VAPID_PRIVATE_KEY=3wqpDPa06BhXMDQB6kQQIMP-0iiCLMH8DfbvSxmXADc= +VAPID_PUBLIC_KEY=BH1-GnuLJLOb_CKzeeSr2oPF05yeNXUyZ5oO2YOS6lJYfFeyG8mGdX_ZCWwKDgfUhwaEWr-mCZJoa7KBBZY-_Ds= +DB_HOST=localhost +DB_PORT=5433 +DB_NAME=postgres +DB_USER=postgres +#DB_PASS= +REDIS_HOST=localhost +REDIS_PORT=6379 +SMTP_SERVER=localhost +SMTP_PORT=25 +SMTP_AUTH_METHOD=none +SMTP_OPENSSL_VERIFY_MODE=none +SMTP_FROM_ADDRESS=Gab Social diff --git a/migrations.sql b/migrations.sql new file mode 100644 index 00000000..39b1ab27 --- /dev/null +++ b/migrations.sql @@ -0,0 +1,311 @@ +insert into schema_migrations (version) values ( +20160220174730), +(20160220211917), +(20160221003140), +(20160221003621), +(20160222122600), +(20160222143943), +(20160223162837), +(20160223164502), +(20160223165723), +(20160223165855), +(20160223171800), +(20160224223247), +(20160227230233), +(20160305115639), +(20160306172223), +(20160312193225), +(20160314164231), +(20160316103650), +(20160322193748), +(20160325130944), +(20160826155805), +(20160905150353), +(20160919221059), +(20160920003904), +(20160926213048), +(20161003142332), +(20161003145426), +(20161006213403), +(20161009120834), +(20161027172456), +(20161104173623), +(20161105130633), +(20161116162355), +(20161119211120), +(20161122163057), +(20161123093447), +(20161128103007), +(20161130142058), +(20161130185319), +(20161202132159), +(20161203164520), +(20161205214545), +(20161221152630), +(20161222201034), +(20161222204147), +(20170105224407), +(20170109120109), +(20170112154826), +(20170114194937), +(20170114203041), +(20170119214911), +(20170123162658), +(20170123203248), +(20170125145934), +(20170127165745), +(20170129000348), +(20170205175257), +(20170209184350), +(20170214110202), +(20170217012631), +(20170301222600), +(20170303212857), +(20170304202101), +(20170317193015), +(20170318214217), +(20170322021028), +(20170322143850), +(20170322162804), +(20170330021336), +(20170330163835), +(20170330164118), +(20170403172249), +(20170405112956), +(20170406215816), +(20170409170753), +(20170414080609), +(20170414132105), +(20170418160728), +(20170423005413), +(20170424003227), +(20170424112722), +(20170425131920), +(20170425202925), +(20170427011934), +(20170506235850), +(20170507000211), +(20170507141759), +(20170508230434), +(20170516072309), +(20170520145338), +(20170601210557), +(20170604144747), +(20170606113804), +(20170609145826), +(20170610000000), +(20170623152212), +(20170624134742), +(20170625140443), +(20170711225116), +(20170713112503), +(20170713175513), +(20170713190709), +(20170714184731), +(20170716191202), +(20170718211102), +(20170720000000), +(20170823162448), +(20170824103029), +(20170829215220), +(20170901141119), +(20170901142658), +(20170905044538), +(20170905165803), +(20170913000752), +(20170917153509), +(20170918125918), +(20170920024819), +(20170920032311), +(20170924022025), +(20170927215609), +(20170928082043), +(20171005102658), +(20171005171936), +(20171006142024), +(20171010023049), +(20171010025614), +(20171020084748), +(20171028221157), +(20171107143332), +(20171107143624), +(20171109012327), +(20171114080328), +(20171114231651), +(20171116161857), +(20171118012443), +(20171119172437), +(20171122120436), +(20171125024930), +(20171125031751), +(20171125185353), +(20171125190735), +(20171129172043), +(20171130000000), +(20171201000000), +(20171212195226), +(20171226094803), +(20180106000232), +(20180109143959), +(20180204034416), +(20180206000000), +(20180211015820), +(20180304013859), +(20180310000000), +(20180402031200), +(20180402040909), +(20180410204633), +(20180416210259), +(20180506221944), +(20180510214435), +(20180510230049), +(20180514130000), +(20180514140000), +(20180528141303), +(20180608213548), +(20180609104432), +(20180615122121), +(20180616192031), +(20180617162849), +(20180628181026), +(20180707154237), +(20180711152640), +(20180808175627), +(20180812123222), +(20180812162710), +(20180812173710), +(20180813113448), +(20180814171349), +(20180820232245), +(20180929222014), +(20181007025445), +(20181010141500), +(20181017170937), +(20181018205649), +(20181024224956), +(20181026034033), +(20181116165755), +(20181116173541), +(20181116184611), +(20181127130500), +(20181203003808), +(20181203021853), +(20181204193439), +(20181204215309), +(20181207011115), +(20181213184704), +(20181213185533), +(20181219235220), +(20181226021420), +(20190103124649), +(20190103124754), +(20190117114553), +(20190201012802), +(20190203180359), +(20190225031541), +(20190225031625), +(20190226003449), +(20190304152020), +(20190306145741), +(20190307234537), +(20190314181829), +(20190316190352), +(20190317135723), +(20190409054914), +(20190420025523), +(20190509164208), +(20190510222844), +(20190510231315), +(20190511134027), +(20190511152737), +(20190512160135), +(20190512225945), +(20190514225311), +(20190515001947), +(20190519130537), +(20190526171044), +(20190529143559), +(20190603162444), +(20190603163444), +(20190607000211), +(20190716173227), +(20190721214831), +(20190721234917), +(20190722003541), +(20190722003649), +(20190804115634), +(20190903162122), +(20190917135359), +(20190917141707), +(20191201204843), +(20191201205006), +(20191201210057), +(20191202004114), +(20200310223351), +(20200310224203), +(20200420223346), +(20200430154012), +(20200510034822), +(20200707212650), +(20200707212832), +(20200707212951), +(20200710130615), +(20200721215336), +(20200722190627), +(20200722190844), +(20200727224633), +(20200801023407), +(20200801023430), +(20200801023518), +(20200806162649), +(20200806174026), +(20200806231714), +(20200808170254), +(20200808170708), +(20200901165533), +(20200908210102), +(20200908210103), +(20200908210104), +(20201109233203), +(20201109233204), +(20201109233205), +(20201109233206), +(20201109233207), +(20201109233208), +(20201109233209), +(20201109233210), +(20201109233211), +(20201109233212), +(20201109233213), +(20201109233214), +(20201109233215), +(20201127051070), +(20201127051071), +(20201127051072), +(20201127051073), +(20201127051074), +(20201130171423), +(20201203211403), +(20201203211419), +(20201203211614), +(20201203213059), +(20201203213108), +(20201203214600), +(20201206060226), +(20201212154128), +(20201214051317), +(20201214051720), +(20201214054428), +(20201214055039), +(20201215203113), +(20201216045306), +(20201216051551), +(20201217003945), +(20201218012018), +(20201222040559), +(20210102225500), +(20210103150000), +(20210108123456), +(20210117111000), +(20210117120100), +(20210117210100); From ef20054f47da222b859cdd677398b94e5e1ae63c Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 27 Jan 2021 21:29:55 +0000 Subject: [PATCH 8/8] Revert "merging rails_6 with develop" This reverts commit a417cdcde6bc2666a1ab0bf49d7b12956097796f --- .env.development | 20 --- migrations.sql | 311 ----------------------------------------------- 2 files changed, 331 deletions(-) delete mode 100644 .env.development delete mode 100644 migrations.sql diff --git a/.env.development b/.env.development deleted file mode 100644 index b8beef80..00000000 --- a/.env.development +++ /dev/null @@ -1,20 +0,0 @@ -# Generated with gabsocial:setup on 2021-01-26 17:34:03 UTC - -LOCAL_DOMAIN=localhost -SINGLE_USER_MODE=false -SECRET_KEY_BASE=aa97516571e4cda8d27316788bf4a97c484744cb5fbd6d272389c4e6c675f0b40243073ba5cd606f8a0b39cc34c237fa3d66ef1e4a973c0db08ee56f51e70703 -OTP_SECRET=6bf15ce12656771ef4ca95ed86e6a31e2bc1975a1dc3e2387d951b733f5d1f34afd89d4061ca174946080420d37be9b51a207e5d54f8f4631b00ebfc8ef35f3c -VAPID_PRIVATE_KEY=3wqpDPa06BhXMDQB6kQQIMP-0iiCLMH8DfbvSxmXADc= -VAPID_PUBLIC_KEY=BH1-GnuLJLOb_CKzeeSr2oPF05yeNXUyZ5oO2YOS6lJYfFeyG8mGdX_ZCWwKDgfUhwaEWr-mCZJoa7KBBZY-_Ds= -DB_HOST=localhost -DB_PORT=5433 -DB_NAME=postgres -DB_USER=postgres -#DB_PASS= -REDIS_HOST=localhost -REDIS_PORT=6379 -SMTP_SERVER=localhost -SMTP_PORT=25 -SMTP_AUTH_METHOD=none -SMTP_OPENSSL_VERIFY_MODE=none -SMTP_FROM_ADDRESS=Gab Social diff --git a/migrations.sql b/migrations.sql deleted file mode 100644 index 39b1ab27..00000000 --- a/migrations.sql +++ /dev/null @@ -1,311 +0,0 @@ -insert into schema_migrations (version) values ( -20160220174730), -(20160220211917), -(20160221003140), -(20160221003621), -(20160222122600), -(20160222143943), -(20160223162837), -(20160223164502), -(20160223165723), -(20160223165855), -(20160223171800), -(20160224223247), -(20160227230233), -(20160305115639), -(20160306172223), -(20160312193225), -(20160314164231), -(20160316103650), -(20160322193748), -(20160325130944), -(20160826155805), -(20160905150353), -(20160919221059), -(20160920003904), -(20160926213048), -(20161003142332), -(20161003145426), -(20161006213403), -(20161009120834), -(20161027172456), -(20161104173623), -(20161105130633), -(20161116162355), -(20161119211120), -(20161122163057), -(20161123093447), -(20161128103007), -(20161130142058), -(20161130185319), -(20161202132159), -(20161203164520), -(20161205214545), -(20161221152630), -(20161222201034), -(20161222204147), -(20170105224407), -(20170109120109), -(20170112154826), -(20170114194937), -(20170114203041), -(20170119214911), -(20170123162658), -(20170123203248), -(20170125145934), -(20170127165745), -(20170129000348), -(20170205175257), -(20170209184350), -(20170214110202), -(20170217012631), -(20170301222600), -(20170303212857), -(20170304202101), -(20170317193015), -(20170318214217), -(20170322021028), -(20170322143850), -(20170322162804), -(20170330021336), -(20170330163835), -(20170330164118), -(20170403172249), -(20170405112956), -(20170406215816), -(20170409170753), -(20170414080609), -(20170414132105), -(20170418160728), -(20170423005413), -(20170424003227), -(20170424112722), -(20170425131920), -(20170425202925), -(20170427011934), -(20170506235850), -(20170507000211), -(20170507141759), -(20170508230434), -(20170516072309), -(20170520145338), -(20170601210557), -(20170604144747), -(20170606113804), -(20170609145826), -(20170610000000), -(20170623152212), -(20170624134742), -(20170625140443), -(20170711225116), -(20170713112503), -(20170713175513), -(20170713190709), -(20170714184731), -(20170716191202), -(20170718211102), -(20170720000000), -(20170823162448), -(20170824103029), -(20170829215220), -(20170901141119), -(20170901142658), -(20170905044538), -(20170905165803), -(20170913000752), -(20170917153509), -(20170918125918), -(20170920024819), -(20170920032311), -(20170924022025), -(20170927215609), -(20170928082043), -(20171005102658), -(20171005171936), -(20171006142024), -(20171010023049), -(20171010025614), -(20171020084748), -(20171028221157), -(20171107143332), -(20171107143624), -(20171109012327), -(20171114080328), -(20171114231651), -(20171116161857), -(20171118012443), -(20171119172437), -(20171122120436), -(20171125024930), -(20171125031751), -(20171125185353), -(20171125190735), -(20171129172043), -(20171130000000), -(20171201000000), -(20171212195226), -(20171226094803), -(20180106000232), -(20180109143959), -(20180204034416), -(20180206000000), -(20180211015820), -(20180304013859), -(20180310000000), -(20180402031200), -(20180402040909), -(20180410204633), -(20180416210259), -(20180506221944), -(20180510214435), -(20180510230049), -(20180514130000), -(20180514140000), -(20180528141303), -(20180608213548), -(20180609104432), -(20180615122121), -(20180616192031), -(20180617162849), -(20180628181026), -(20180707154237), -(20180711152640), -(20180808175627), -(20180812123222), -(20180812162710), -(20180812173710), -(20180813113448), -(20180814171349), -(20180820232245), -(20180929222014), -(20181007025445), -(20181010141500), -(20181017170937), -(20181018205649), -(20181024224956), -(20181026034033), -(20181116165755), -(20181116173541), -(20181116184611), -(20181127130500), -(20181203003808), -(20181203021853), -(20181204193439), -(20181204215309), -(20181207011115), -(20181213184704), -(20181213185533), -(20181219235220), -(20181226021420), -(20190103124649), -(20190103124754), -(20190117114553), -(20190201012802), -(20190203180359), -(20190225031541), -(20190225031625), -(20190226003449), -(20190304152020), -(20190306145741), -(20190307234537), -(20190314181829), -(20190316190352), -(20190317135723), -(20190409054914), -(20190420025523), -(20190509164208), -(20190510222844), -(20190510231315), -(20190511134027), -(20190511152737), -(20190512160135), -(20190512225945), -(20190514225311), -(20190515001947), -(20190519130537), -(20190526171044), -(20190529143559), -(20190603162444), -(20190603163444), -(20190607000211), -(20190716173227), -(20190721214831), -(20190721234917), -(20190722003541), -(20190722003649), -(20190804115634), -(20190903162122), -(20190917135359), -(20190917141707), -(20191201204843), -(20191201205006), -(20191201210057), -(20191202004114), -(20200310223351), -(20200310224203), -(20200420223346), -(20200430154012), -(20200510034822), -(20200707212650), -(20200707212832), -(20200707212951), -(20200710130615), -(20200721215336), -(20200722190627), -(20200722190844), -(20200727224633), -(20200801023407), -(20200801023430), -(20200801023518), -(20200806162649), -(20200806174026), -(20200806231714), -(20200808170254), -(20200808170708), -(20200901165533), -(20200908210102), -(20200908210103), -(20200908210104), -(20201109233203), -(20201109233204), -(20201109233205), -(20201109233206), -(20201109233207), -(20201109233208), -(20201109233209), -(20201109233210), -(20201109233211), -(20201109233212), -(20201109233213), -(20201109233214), -(20201109233215), -(20201127051070), -(20201127051071), -(20201127051072), -(20201127051073), -(20201127051074), -(20201130171423), -(20201203211403), -(20201203211419), -(20201203211614), -(20201203213059), -(20201203213108), -(20201203214600), -(20201206060226), -(20201212154128), -(20201214051317), -(20201214051720), -(20201214054428), -(20201214055039), -(20201215203113), -(20201216045306), -(20201216051551), -(20201217003945), -(20201218012018), -(20201222040559), -(20210102225500), -(20210103150000), -(20210108123456), -(20210117111000), -(20210117120100), -(20210117210100);