Merge tag 'v3.1.1' into instance_only_statuses
This commit is contained in:
@ -93,6 +93,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.last_sign_in_ip <<= ?', value)).or(left_joins(:session_activations).where('session_activations.ip <<= ?', value)) }
|
||||
scope :emailable, -> { confirmed.enabled.joins(:account).merge(Account.searchable) }
|
||||
|
||||
before_validation :sanitize_languages
|
||||
@ -108,7 +109,7 @@ class User < ApplicationRecord
|
||||
delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :delete_modal,
|
||||
:reduce_motion, :system_font_ui, :noindex, :theme, :display_media, :hide_network,
|
||||
:expand_spoilers, :default_language, :aggregate_reblogs, :show_application,
|
||||
:advanced_layout, :use_blurhash, :use_pending_items, :trends, :default_federation,
|
||||
:advanced_layout, :use_blurhash, :use_pending_items, :trends, :crop_images, :default_federation,
|
||||
to: :settings, prefix: :setting, allow_nil: false
|
||||
|
||||
attr_reader :invite_code
|
||||
@ -127,9 +128,7 @@ class User < ApplicationRecord
|
||||
end
|
||||
|
||||
def disable!
|
||||
update!(disabled: true,
|
||||
last_sign_in_at: current_sign_in_at,
|
||||
current_sign_in_at: nil)
|
||||
update!(disabled: true)
|
||||
end
|
||||
|
||||
def enable!
|
||||
@ -246,7 +245,7 @@ class User < ApplicationRecord
|
||||
ip: request.remote_ip).session_id
|
||||
end
|
||||
|
||||
def exclusive_session(id)
|
||||
def clear_other_sessions(id)
|
||||
session_activations.exclusive(id)
|
||||
end
|
||||
|
||||
@ -289,6 +288,21 @@ class User < ApplicationRecord
|
||||
setting_display_media == 'hide_all'
|
||||
end
|
||||
|
||||
def recent_ips
|
||||
@recent_ips ||= begin
|
||||
arr = []
|
||||
|
||||
session_activations.each do |session_activation|
|
||||
arr << [session_activation.updated_at, session_activation.ip]
|
||||
end
|
||||
|
||||
arr << [current_sign_in_at, current_sign_in_ip] if current_sign_in_ip.present?
|
||||
arr << [last_sign_in_at, last_sign_in_ip] if last_sign_in_ip.present?
|
||||
|
||||
arr.sort_by { |pair| pair.first || Time.now.utc }.uniq(&:last).reverse!
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def send_devise_notification(notification, *args)
|
||||
|
||||
Reference in New Issue
Block a user