Merge branch 'main' into glitch-soc/merge-upstream

Conflicts:
- `README.md`:
  Our README is completely different.
  Discarded upstream changes.
This commit is contained in:
Claire
2022-11-28 11:33:34 +01:00
246 changed files with 17637 additions and 6738 deletions

View File

@ -43,13 +43,13 @@ class AccountFilter
when 'status'
status_scope(value)
when 'by_domain'
Account.where(domain: value.to_s)
Account.where(domain: value.to_s.strip)
when 'username'
Account.matches_username(value.to_s)
Account.matches_username(value.to_s.strip)
when 'display_name'
Account.matches_display_name(value.to_s)
Account.matches_display_name(value.to_s.strip)
when 'email'
accounts_with_users.merge(User.matches_email(value.to_s))
accounts_with_users.merge(User.matches_email(value.to_s.strip))
when 'ip'
valid_ip?(value) ? accounts_with_users.merge(User.matches_ip(value).group('users.id, accounts.id')) : Account.none
when 'invited_by'

View File

@ -104,6 +104,7 @@ class MediaAttachment < ApplicationRecord
'c:v' => 'h264',
'maxrate' => '1300K',
'bufsize' => '1300K',
'b:v' => '1300K',
'frames:v' => 60 * 60 * 3,
'crf' => 18,
'map_metadata' => '-1',

View File

@ -85,6 +85,7 @@ class Poll < ApplicationRecord
def reset_votes!
self.cached_tallies = options.map { 0 }
self.votes_count = 0
self.voters_count = 0
votes.delete_all unless new_record?
end

View File

@ -68,6 +68,7 @@ class Status < ApplicationRecord
has_many :reblogged_by_accounts, through: :reblogs, class_name: 'Account', source: :account
has_many :replies, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :thread
has_many :mentions, dependent: :destroy, inverse_of: :status
has_many :mentioned_accounts, through: :mentions, source: :account, class_name: 'Account'
has_many :active_mentions, -> { active }, class_name: 'Mention', inverse_of: :status
has_many :media_attachments, dependent: :nullify
@ -146,11 +147,11 @@ class Status < ApplicationRecord
ids << account_id if local?
if preloaded.nil?
ids += mentions.where(account: Account.local, silent: false).pluck(:account_id)
ids += favourites.where(account: Account.local).pluck(:account_id)
ids += reblogs.where(account: Account.local).pluck(:account_id)
ids += bookmarks.where(account: Account.local).pluck(:account_id)
ids += poll.votes.where(account: Account.local).pluck(:account_id) if poll.present?
ids += mentions.joins(:account).merge(Account.local).active.pluck(:account_id)
ids += favourites.joins(:account).merge(Account.local).pluck(:account_id)
ids += reblogs.joins(:account).merge(Account.local).pluck(:account_id)
ids += bookmarks.joins(:account).merge(Account.local).pluck(:account_id)
ids += poll.votes.joins(:account).merge(Account.local).pluck(:account_id) if poll.present?
else
ids += preloaded.mentions[id] || []
ids += preloaded.favourites[id] || []
@ -590,8 +591,8 @@ class Status < ApplicationRecord
def unlink_from_conversations
return unless direct_visibility?
mentioned_accounts = (association(:mentions).loaded? ? mentions : mentions.includes(:account)).map(&:account)
inbox_owners = mentioned_accounts.select(&:local?) + (account.local? ? [account] : [])
inbox_owners = mentioned_accounts.local
inbox_owners += [account] if account.local?
inbox_owners.each do |inbox_owner|
AccountConversation.remove_status(inbox_owner, self)