From ee9a40bec0f7c942b67a0cae3760fc3c5edc47a6 Mon Sep 17 00:00:00 2001 From: Jeong Arm Date: Tue, 9 Jul 2024 09:14:01 +0900 Subject: [PATCH] Follow #30932 --- app/models/status.rb | 6 +++++- app/models/status_edit.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/status.rb b/app/models/status.rb index 88233585ae..27befeb7df 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -281,6 +281,10 @@ class Status < ApplicationRecord @emojis = CustomEmoji.from_text(fields.join(' '), account.domain) end + def media_attachments_limit + local? ? MEDIA_ATTACHMENTS_LIMIT : REMOTE_MEDIA_ATTACHMENTS_LIMIT + end + def ordered_media_attachments if ordered_media_attachment_ids.nil? # NOTE: sort Ruby-side to avoid hitting the database when the status is @@ -289,7 +293,7 @@ class Status < ApplicationRecord else map = media_attachments.index_by(&:id) ordered_media_attachment_ids.filter_map { |media_attachment_id| map[media_attachment_id] } - end.take(MEDIA_ATTACHMENTS_LIMIT) + end.take(media_attachments_limit) end def replies_count diff --git a/app/models/status_edit.rb b/app/models/status_edit.rb index 6e25a6f3bb..5bbdea004f 100644 --- a/app/models/status_edit.rb +++ b/app/models/status_edit.rb @@ -60,7 +60,7 @@ class StatusEdit < ApplicationRecord map = status.media_attachments.index_by(&:id) ordered_media_attachment_ids.map.with_index { |media_attachment_id, index| PreservedMediaAttachment.new(media_attachment: map[media_attachment_id], description: media_descriptions[index]) } end - end.take(Status::MEDIA_ATTACHMENTS_LIMIT) + end.take(status.media_attachments_limit) end def proper