[media] Force media attachments query from master on status post, change home query

This commit is contained in:
Fosco Marotto 2020-12-06 11:16:04 -08:00
parent d1eb3d09e4
commit 95d326936b
2 changed files with 3 additions and 2 deletions

View File

@ -302,13 +302,13 @@ class Status < ApplicationRecord
end end
def as_home_timeline(account) def as_home_timeline(account)
query = where('updated_at > ?', 5.days.ago) query = where('created_at > ?', 5.days.ago)
query.where(visibility: [:public, :unlisted, :private]) query.where(visibility: [:public, :unlisted, :private])
query.where(account: [account] + account.following).without_replies query.where(account: [account] + account.following).without_replies
end end
def as_group_timeline(group) def as_group_timeline(group)
query = where('updated_at > ?', 5.days.ago) query = where('created_at > ?', 5.days.ago)
query.where(group: group).without_replies query.where(group: group).without_replies
end end

View File

@ -120,6 +120,7 @@ class PostStatusService < BaseService
raise GabSocial::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > 4 || @options[:poll].present? raise GabSocial::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > 4 || @options[:poll].present?
@account.media_attachments.connection.stick_to_master!
@media = @account.media_attachments.where(status_id: nil).where(id: @options[:media_ids].take(4).map(&:to_i)) @media = @account.media_attachments.where(status_id: nil).where(id: @options[:media_ids].take(4).map(&:to_i))
hasVideoOrGif = @media.find(&:video?) || @media.find(&:gifv?) hasVideoOrGif = @media.find(&:video?) || @media.find(&:gifv?)