Merge commit '8ee6cee36e313fcc39763210dfcd3b871b47cacb' into glitch-soc/merge-upstream
This commit is contained in:
commit
3efc857fbc
75 files changed
+1924
-253
No files matched your search
@@ -138,10 +138,7 @@ class Account < ApplicationRecord
|
||||
scope :partitioned, -> { order(Arel.sql('row_number() over (partition by domain)')) }
|
||||
scope :without_instance_actor, -> { where.not(id: INSTANCE_ACTOR_ID) }
|
||||
scope :recent, -> { reorder(id: :desc) }
|
||||
scope :bots, -> { where(actor_type: AUTOMATED_ACTOR_TYPES) }
|
||||
scope :non_automated, -> { where.not(actor_type: AUTOMATED_ACTOR_TYPES) }
|
||||
scope :groups, -> { where(actor_type: 'Group') }
|
||||
scope :alphabetic, -> { order(domain: :asc, username: :asc) }
|
||||
scope :matches_uri_prefix, ->(value) { where(arel_table[:uri].matches("#{sanitize_sql_like(value)}/%", false, true)).or(where(uri: value)) }
|
||||
scope :matches_username, ->(value) { where('lower((username)::text) LIKE lower(?)', "#{value}%") }
|
||||
scope :matches_display_name, ->(value) { where(arel_table[:display_name].matches("#{value}%")) }
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
class Admin::AccountAction
|
||||
include ActiveModel::Model
|
||||
include ActiveModel::Attributes
|
||||
include AccountableConcern
|
||||
include Authorization
|
||||
|
||||
@@ -20,7 +21,10 @@ class Admin::AccountAction
|
||||
:report_id,
|
||||
:warning_preset_id
|
||||
|
||||
attr_reader :warning, :send_email_notification, :include_statuses
|
||||
attr_reader :warning
|
||||
|
||||
attribute :include_statuses, :boolean, default: true
|
||||
attribute :send_email_notification, :boolean, default: true
|
||||
|
||||
alias send_email_notification? send_email_notification
|
||||
alias include_statuses? include_statuses
|
||||
@@ -28,23 +32,8 @@ class Admin::AccountAction
|
||||
validates :type, :target_account, :current_account, presence: true
|
||||
validates :type, inclusion: { in: TYPES }
|
||||
|
||||
def initialize(attributes = {})
|
||||
@send_email_notification = true
|
||||
@include_statuses = true
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
def send_email_notification=(value)
|
||||
@send_email_notification = ActiveModel::Type::Boolean.new.cast(value)
|
||||
end
|
||||
|
||||
def include_statuses=(value)
|
||||
@include_statuses = ActiveModel::Type::Boolean.new.cast(value)
|
||||
end
|
||||
|
||||
def save!
|
||||
raise ActiveRecord::RecordInvalid, self unless valid?
|
||||
def save
|
||||
return false unless valid?
|
||||
|
||||
ApplicationRecord.transaction do
|
||||
process_action!
|
||||
@@ -54,6 +43,12 @@ class Admin::AccountAction
|
||||
|
||||
process_notification!
|
||||
process_queue!
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
def save!
|
||||
raise ActiveRecord::RecordInvalid, self unless save
|
||||
end
|
||||
|
||||
def report
|
||||
@@ -185,7 +180,7 @@ class Admin::AccountAction
|
||||
@reports ||= if type == 'none'
|
||||
with_report? ? [report] : []
|
||||
else
|
||||
Report.where(target_account: target_account).unresolved
|
||||
target_account.targeted_reports.unresolved
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
class Admin::StatusBatchAction
|
||||
include ActiveModel::Model
|
||||
include ActiveModel::Attributes
|
||||
include AccountableConcern
|
||||
include Authorization
|
||||
|
||||
@@ -9,11 +10,7 @@ class Admin::StatusBatchAction
|
||||
:status_ids, :report_id,
|
||||
:text
|
||||
|
||||
attr_reader :send_email_notification
|
||||
|
||||
def send_email_notification=(value)
|
||||
@send_email_notification = ActiveModel::Type::Boolean.new.cast(value)
|
||||
end
|
||||
attribute :send_email_notification, :boolean
|
||||
|
||||
def save!
|
||||
process_action!
|
||||
|
||||
@@ -128,7 +128,7 @@ class Form::AccountBatch
|
||||
|
||||
# Suspending a single account closes their associated reports, so
|
||||
# mass-suspending would be consistent.
|
||||
Report.where(target_account: account).unresolved.find_each do |report|
|
||||
account.targeted_reports.unresolved.find_each do |report|
|
||||
authorize(report, :update?)
|
||||
log_action(:resolve, report)
|
||||
report.resolve!(current_account)
|
||||
|
||||
Reference in new issue
Block a user