mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-31 02:57:57 +00:00 
			
		
		
		
	chore: Minor Housekeeping tasks (#3169)
- Limit Rack attack to production environments - Make the long-running data migration optional
This commit is contained in:
		| @@ -17,7 +17,6 @@ defaults: &defaults | |||||||
|   environment: |   environment: | ||||||
|       - CC_TEST_REPORTER_ID: b1b5c4447bf93f6f0b06a64756e35afd0810ea83649f03971cbf303b4449456f |       - CC_TEST_REPORTER_ID: b1b5c4447bf93f6f0b06a64756e35afd0810ea83649f03971cbf303b4449456f | ||||||
|       - RAILS_LOG_TO_STDOUT: false |       - RAILS_LOG_TO_STDOUT: false | ||||||
|       - ENABLE_RACK_ATTACK: false |  | ||||||
| jobs: | jobs: | ||||||
|   build: |   build: | ||||||
|     <<: *defaults |     <<: *defaults | ||||||
|   | |||||||
| @@ -85,4 +85,4 @@ ActiveSupport::Notifications.subscribe('throttle.rack_attack') do |_name, _start | |||||||
|   Rails.logger.info "[Rack::Attack][Blocked] remote_ip: \"#{payload[:request].remote_ip}\", path: \"#{payload[:request].path}\"" |   Rails.logger.info "[Rack::Attack][Blocked] remote_ip: \"#{payload[:request].remote_ip}\", path: \"#{payload[:request].path}\"" | ||||||
| end | end | ||||||
|  |  | ||||||
| Rack::Attack.enabled = ActiveModel::Type::Boolean.new.cast(ENV.fetch('ENABLE_RACK_ATTACK', true)) | Rack::Attack.enabled = Rails.env.production? ? ActiveModel::Type::Boolean.new.cast(ENV.fetch('ENABLE_RACK_ATTACK', true)) : false | ||||||
|   | |||||||
| @@ -4,12 +4,9 @@ class AddOnlineStatusToAccountUsers < ActiveRecord::Migration[6.1] | |||||||
|       t.integer :availability, default: 0, null: false |       t.integer :availability, default: 0, null: false | ||||||
|       t.boolean :auto_offline, default: true, null: false |       t.boolean :auto_offline, default: true, null: false | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     update_existing_user_availability |  | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   private |   # run as a seperate data migration if you want to migrate the user statuses | ||||||
|  |  | ||||||
|   def update_existing_user_availability |   def update_existing_user_availability | ||||||
|     User.find_in_batches do |user_batch| |     User.find_in_batches do |user_batch| | ||||||
|       user_batch.each do |user| |       user_batch.each do |user| | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sojan Jose
					Sojan Jose