From 720e8ab0f53d4e1befc545aa25e39da906bdd1e6 Mon Sep 17 00:00:00 2001 From: Jeong Arm Date: Tue, 21 Dec 2021 08:17:14 +0900 Subject: Fix duplicate record on admin/accounts when searching with IP (#17150) --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/user.rb b/app/models/user.rb index c4dec4813..374b82d05 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -107,7 +107,7 @@ class User < ApplicationRecord scope :inactive, -> { where(arel_table[:current_sign_in_at].lt(ACTIVE_DURATION.ago)) } scope :active, -> { confirmed.where(arel_table[:current_sign_in_at].gteq(ACTIVE_DURATION.ago)).joins(:account).where(accounts: { suspended_at: nil }) } scope :matches_email, ->(value) { where(arel_table[:email].matches("#{value}%")) } - scope :matches_ip, ->(value) { left_joins(:session_activations).where('users.current_sign_in_ip <<= ?', value).or(left_joins(:session_activations).where('users.sign_up_ip <<= ?', value)).or(left_joins(:session_activations).where('users.last_sign_in_ip <<= ?', value)).or(left_joins(:session_activations).where('session_activations.ip <<= ?', value)) } + scope :matches_ip, ->(value) { where('current_sign_in_ip <<= ?', value).or(where('users.sign_up_ip <<= ?', value)).or(where('users.last_sign_in_ip <<= ?', value)).or(where(id: SessionActivation.select(:user_id).where('ip <<= ?', value))) } scope :emailable, -> { confirmed.enabled.joins(:account).merge(Account.searchable) } before_validation :sanitize_languages -- cgit From e65080181af82c14d3441a0890f2ba0a6fb9cd7e Mon Sep 17 00:00:00 2001 From: Rens Groothuijsen Date: Sun, 26 Dec 2021 19:22:05 +0100 Subject: Fix tag rendering error in hashtag column settings (#17184) * Flatten tags in configuration to regular array before converting to JSON * Render filter tags using toJS instead of toJSON --- .../mastodon/features/hashtag_timeline/components/column_settings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/javascript/mastodon/features/hashtag_timeline/components/column_settings.js b/app/javascript/mastodon/features/hashtag_timeline/components/column_settings.js index de1127b0d..142118cef 100644 --- a/app/javascript/mastodon/features/hashtag_timeline/components/column_settings.js +++ b/app/javascript/mastodon/features/hashtag_timeline/components/column_settings.js @@ -33,8 +33,8 @@ class ColumnSettings extends React.PureComponent { tags (mode) { let tags = this.props.settings.getIn(['tags', mode]) || []; - if (tags.toJSON) { - return tags.toJSON(); + if (tags.toJS) { + return tags.toJS(); } else { return tags; } -- cgit From fe71548844715d796b9a6d2dd5234f70cf080f13 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 27 Dec 2021 00:47:20 +0100 Subject: Fix warnings on Rails boot (#16946) --- app/lib/sidekiq_error_handler.rb | 26 -------------------------- config/environments/development.rb | 2 +- config/initializers/sidekiq.rb | 2 ++ lib/sidekiq_error_handler.rb | 24 ++++++++++++++++++++++++ 4 files changed, 27 insertions(+), 27 deletions(-) delete mode 100644 app/lib/sidekiq_error_handler.rb create mode 100644 lib/sidekiq_error_handler.rb (limited to 'app') diff --git a/app/lib/sidekiq_error_handler.rb b/app/lib/sidekiq_error_handler.rb deleted file mode 100644 index ab555b1be..000000000 --- a/app/lib/sidekiq_error_handler.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -class SidekiqErrorHandler - BACKTRACE_LIMIT = 3 - - def call(*) - yield - rescue Mastodon::HostValidationError - # Do not retry - rescue => e - limit_backtrace_and_raise(e) - ensure - socket = Thread.current[:statsd_socket] - socket&.close - Thread.current[:statsd_socket] = nil - end - - private - - # rubocop:disable Naming/MethodParameterName - def limit_backtrace_and_raise(e) - e.set_backtrace(e.backtrace.first(BACKTRACE_LIMIT)) - raise e - end - # rubocop:enable Naming/MethodParameterName -end diff --git a/config/environments/development.rb b/config/environments/development.rb index d76361c60..de8762ff7 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -81,7 +81,7 @@ Rails.application.configure do Bullet.bullet_logger = true Bullet.rails_logger = false - Bullet.add_whitelist type: :n_plus_one_query, class_name: 'User', association: :account + Bullet.add_safelist type: :n_plus_one_query, class_name: 'User', association: :account end config.x.otp_secret = ENV.fetch('OTP_SECRET', '1fc2b87989afa6351912abeebe31ffc5c476ead9bf8b3d74cbc4a302c7b69a45b40b1bbef3506ddad73e942e15ed5ca4b402bf9a66423626051104f4b5f05109') diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 219554df4..19a705ce8 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require_relative '../../lib/sidekiq_error_handler' + Sidekiq.configure_server do |config| config.redis = REDIS_SIDEKIQ_PARAMS diff --git a/lib/sidekiq_error_handler.rb b/lib/sidekiq_error_handler.rb new file mode 100644 index 000000000..358afd540 --- /dev/null +++ b/lib/sidekiq_error_handler.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class SidekiqErrorHandler + BACKTRACE_LIMIT = 3 + + def call(*) + yield + rescue Mastodon::HostValidationError + # Do not retry + rescue => e + limit_backtrace_and_raise(e) + ensure + socket = Thread.current[:statsd_socket] + socket&.close + Thread.current[:statsd_socket] = nil + end + + private + + def limit_backtrace_and_raise(exception) + exception.set_backtrace(exception.backtrace.first(BACKTRACE_LIMIT)) + raise exception + end +end -- cgit From f011787003bcb801b487ad3f5229e324a37c9e1d Mon Sep 17 00:00:00 2001 From: Rens Groothuijsen Date: Sun, 26 Dec 2021 19:22:05 +0100 Subject: [Glitch] Fix tag rendering error in hashtag column settings Port e65080181af82c14d3441a0890f2ba0a6fb9cd7e to glitch-soc Signed-off-by: Claire --- .../glitch/features/hashtag_timeline/components/column_settings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/javascript/flavours/glitch/features/hashtag_timeline/components/column_settings.js b/app/javascript/flavours/glitch/features/hashtag_timeline/components/column_settings.js index de1127b0d..142118cef 100644 --- a/app/javascript/flavours/glitch/features/hashtag_timeline/components/column_settings.js +++ b/app/javascript/flavours/glitch/features/hashtag_timeline/components/column_settings.js @@ -33,8 +33,8 @@ class ColumnSettings extends React.PureComponent { tags (mode) { let tags = this.props.settings.getIn(['tags', mode]) || []; - if (tags.toJSON) { - return tags.toJSON(); + if (tags.toJS) { + return tags.toJS(); } else { return tags; } -- cgit