Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - `app/javascript/packs/public.js`: Upstream removed an unused function in code that has been refactored a bit. Removed that function in the corresponding places.
This commit is contained in:
@@ -1,6 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AccountFilter
|
||||
KEYS = %i(
|
||||
local
|
||||
remote
|
||||
by_domain
|
||||
active
|
||||
pending
|
||||
silenced
|
||||
suspended
|
||||
username
|
||||
display_name
|
||||
email
|
||||
ip
|
||||
staff
|
||||
).freeze
|
||||
|
||||
attr_reader :params
|
||||
|
||||
def initialize(params)
|
||||
@@ -50,7 +65,7 @@ class AccountFilter
|
||||
when 'email'
|
||||
accounts_with_users.merge User.matches_email(value)
|
||||
when 'ip'
|
||||
valid_ip?(value) ? accounts_with_users.where('users.current_sign_in_ip <<= ?', value) : Account.none
|
||||
valid_ip?(value) ? accounts_with_users.merge(User.matches_ip(value)) : Account.none
|
||||
when 'staff'
|
||||
accounts_with_users.merge User.staff
|
||||
else
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CustomEmojiFilter
|
||||
KEYS = %i(
|
||||
local
|
||||
remote
|
||||
by_domain
|
||||
shortcode
|
||||
).freeze
|
||||
|
||||
attr_reader :params
|
||||
|
||||
def initialize(params)
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class InstanceFilter
|
||||
KEYS = %i(
|
||||
limited
|
||||
by_domain
|
||||
).freeze
|
||||
|
||||
attr_reader :params
|
||||
|
||||
def initialize(params)
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class InviteFilter
|
||||
KEYS = %i(
|
||||
available
|
||||
expired
|
||||
).freeze
|
||||
|
||||
attr_reader :params
|
||||
|
||||
def initialize(params)
|
||||
|
||||
11
app/models/relationship_filter.rb
Normal file
11
app/models/relationship_filter.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RelationshipFilter
|
||||
KEYS = %i(
|
||||
relationship
|
||||
status
|
||||
by_domain
|
||||
activity
|
||||
order
|
||||
).freeze
|
||||
end
|
||||
@@ -1,6 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ReportFilter
|
||||
KEYS = %i(
|
||||
resolved
|
||||
account_id
|
||||
target_account_id
|
||||
by_target_domain
|
||||
).freeze
|
||||
|
||||
attr_reader :params
|
||||
|
||||
def initialize(params)
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class TagFilter
|
||||
KEYS = %i(
|
||||
directory
|
||||
reviewed
|
||||
unreviewed
|
||||
pending_review
|
||||
popular
|
||||
active
|
||||
name
|
||||
).freeze
|
||||
|
||||
attr_reader :params
|
||||
|
||||
def initialize(params)
|
||||
|
||||
@@ -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
|
||||
@@ -290,6 +291,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(&:first).uniq(&:last).reverse!
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def send_devise_notification(notification, *args)
|
||||
|
||||
Reference in New Issue
Block a user