Merge remote-tracking branch 'tootsuite/master' into glitchsoc/master
This commit is contained in:
@@ -126,6 +126,7 @@ class Account < ApplicationRecord
|
||||
scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) }
|
||||
|
||||
delegate :email,
|
||||
:unconfirmed_email,
|
||||
:current_sign_in_ip,
|
||||
:current_sign_in_at,
|
||||
:confirmed?,
|
||||
|
@@ -35,6 +35,11 @@ class Admin::ActionLog < ApplicationRecord
|
||||
self.recorded_changes = target.attributes
|
||||
when :update, :promote, :demote
|
||||
self.recorded_changes = target.previous_changes
|
||||
when :change_email
|
||||
self.recorded_changes = ActiveSupport::HashWithIndifferentAccess.new(
|
||||
email: [target.email, nil],
|
||||
unconfirmed_email: [nil, target.unconfirmed_email]
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -15,16 +15,12 @@ module StatusThreadingConcern
|
||||
|
||||
def ancestor_ids
|
||||
Rails.cache.fetch("ancestors:#{id}") do
|
||||
ancestors_without_self.pluck(:id)
|
||||
ancestor_statuses.pluck(:id)
|
||||
end
|
||||
end
|
||||
|
||||
def ancestors_without_self
|
||||
ancestor_statuses - [self]
|
||||
end
|
||||
|
||||
def ancestor_statuses
|
||||
Status.find_by_sql([<<-SQL.squish, id: id])
|
||||
Status.find_by_sql([<<-SQL.squish, id: in_reply_to_id])
|
||||
WITH RECURSIVE search_tree(id, in_reply_to_id, path)
|
||||
AS (
|
||||
SELECT id, in_reply_to_id, ARRAY[id]
|
||||
@@ -43,11 +39,7 @@ module StatusThreadingConcern
|
||||
end
|
||||
|
||||
def descendant_ids
|
||||
descendants_without_self.pluck(:id)
|
||||
end
|
||||
|
||||
def descendants_without_self
|
||||
descendant_statuses - [self]
|
||||
descendant_statuses.pluck(:id)
|
||||
end
|
||||
|
||||
def descendant_statuses
|
||||
@@ -56,7 +48,7 @@ module StatusThreadingConcern
|
||||
AS (
|
||||
SELECT id, ARRAY[id]
|
||||
FROM statuses
|
||||
WHERE id = :id
|
||||
WHERE in_reply_to_id = :id
|
||||
UNION ALL
|
||||
SELECT statuses.id, path || statuses.id
|
||||
FROM search_tree
|
||||
|
@@ -58,5 +58,9 @@ class CustomEmoji < ApplicationRecord
|
||||
|
||||
where(shortcode: shortcodes, domain: domain, disabled: false)
|
||||
end
|
||||
|
||||
def search(shortcode)
|
||||
where('"custom_emojis"."shortcode" ILIKE ?', "%#{shortcode}%")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -28,7 +28,7 @@ class CustomEmojiFilter
|
||||
when 'by_domain'
|
||||
CustomEmoji.where(domain: value)
|
||||
when 'shortcode'
|
||||
CustomEmoji.where(shortcode: value)
|
||||
CustomEmoji.search(value)
|
||||
else
|
||||
raise "Unknown filter: #{key}"
|
||||
end
|
||||
|
@@ -150,8 +150,9 @@ class MediaAttachment < ApplicationRecord
|
||||
'pix_fmt' => 'yuv420p',
|
||||
'vf' => 'scale=\'trunc(iw/2)*2:trunc(ih/2)*2\'',
|
||||
'vsync' => 'cfr',
|
||||
'b:v' => '1300K',
|
||||
'maxrate' => '500K',
|
||||
'c:v' => 'h264',
|
||||
'b:v' => '500K',
|
||||
'maxrate' => '1300K',
|
||||
'bufsize' => '1300K',
|
||||
'crf' => 18,
|
||||
},
|
||||
|
@@ -39,4 +39,50 @@ class Report < ApplicationRecord
|
||||
def media_attachments
|
||||
MediaAttachment.where(status_id: status_ids)
|
||||
end
|
||||
|
||||
def assign_to_self!(current_account)
|
||||
update!(assigned_account_id: current_account.id)
|
||||
end
|
||||
|
||||
def unassign!
|
||||
update!(assigned_account_id: nil)
|
||||
end
|
||||
|
||||
def resolve!(acting_account)
|
||||
update!(action_taken: true, action_taken_by_account_id: acting_account.id)
|
||||
end
|
||||
|
||||
def unresolve!
|
||||
update!(action_taken: false, action_taken_by_account_id: nil)
|
||||
end
|
||||
|
||||
def unresolved?
|
||||
!action_taken?
|
||||
end
|
||||
|
||||
def history
|
||||
time_range = created_at..updated_at
|
||||
|
||||
sql = [
|
||||
Admin::ActionLog.where(
|
||||
target_type: 'Report',
|
||||
target_id: id,
|
||||
created_at: time_range
|
||||
).unscope(:order),
|
||||
|
||||
Admin::ActionLog.where(
|
||||
target_type: 'Account',
|
||||
target_id: target_account_id,
|
||||
created_at: time_range
|
||||
).unscope(:order),
|
||||
|
||||
Admin::ActionLog.where(
|
||||
target_type: 'Status',
|
||||
target_id: status_ids,
|
||||
created_at: time_range
|
||||
).unscope(:order),
|
||||
].map { |query| "(#{query.to_sql})" }.join(' UNION ALL ')
|
||||
|
||||
Admin::ActionLog.from("(#{sql}) AS admin_action_logs")
|
||||
end
|
||||
end
|
||||
|
@@ -13,7 +13,7 @@
|
||||
|
||||
class ReportNote < ApplicationRecord
|
||||
belongs_to :account
|
||||
belongs_to :report, inverse_of: :notes
|
||||
belongs_to :report, inverse_of: :notes, touch: true
|
||||
|
||||
scope :latest, -> { reorder('created_at ASC') }
|
||||
|
||||
|
Reference in New Issue
Block a user