Merge pull request #686 from kmycode/upstream-20240401

Upstream 20240401
This commit is contained in:
KMY(雪あすか) 2024-04-01 09:21:13 +09:00 committed by GitHub
commit 7b02596f1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
111 changed files with 989 additions and 720 deletions

View file

@ -28,6 +28,8 @@ class AccountWarning < ApplicationRecord
suspend: 4_000,
}, suffix: :action
RECENT_PERIOD = 3.months.freeze
normalizes :text, with: ->(text) { text.to_s }, apply_to_nil: true
belongs_to :account, inverse_of: :account_warnings
@ -38,7 +40,7 @@ class AccountWarning < ApplicationRecord
scope :latest, -> { order(id: :desc) }
scope :custom, -> { where.not(text: '') }
scope :recent, -> { where('account_warnings.created_at >= ?', 3.months.ago) }
scope :recent, -> { where(created_at: RECENT_PERIOD.ago..) }
def statuses
Status.with_discarded.where(id: status_ids || [])

View file

@ -142,7 +142,7 @@ class Status < ApplicationRecord
scope :with_public_search_visibility, -> { merge(where(visibility: [:public, :public_unlisted, :login]).or(Status.where(searchability: [:public, :public_unlisted]))) }
scope :tagged_with, ->(tag_ids) { joins(:statuses_tags).where(statuses_tags: { tag_id: tag_ids }) }
scope :not_excluded_by_account, ->(account) { where.not(account_id: account.excluded_from_timeline_account_ids) }
scope :not_domain_blocked_by_account, ->(account) { account.excluded_from_timeline_domains.blank? ? left_outer_joins(:account) : left_outer_joins(:account).where('accounts.domain IS NULL OR accounts.domain NOT IN (?)', account.excluded_from_timeline_domains) }
scope :not_domain_blocked_by_account, ->(account) { account.excluded_from_timeline_domains.blank? ? left_outer_joins(:account) : left_outer_joins(:account).merge(Account.not_domain_blocked_by_account(account)) }
scope :tagged_with_all, lambda { |tag_ids|
Array(tag_ids).map(&:to_i).reduce(self) do |result, id|
result.where(<<~SQL.squish, tag_id: id)