Limit attachments to MEDIA_ATTACHMENTS_LIMIT
when returning posts through the API (#30932)
This commit is contained in:
parent
fd3bfc0710
commit
d41b43ed4f
3 changed files with 44 additions and 7 deletions
|
@ -288,7 +288,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
|
||||
end.take(MEDIA_ATTACHMENTS_LIMIT)
|
||||
end
|
||||
|
||||
def replies_count
|
||||
|
|
|
@ -53,12 +53,14 @@ class StatusEdit < ApplicationRecord
|
|||
def ordered_media_attachments
|
||||
return @ordered_media_attachments if defined?(@ordered_media_attachments)
|
||||
|
||||
@ordered_media_attachments = if ordered_media_attachment_ids.nil?
|
||||
[]
|
||||
else
|
||||
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
|
||||
@ordered_media_attachments = begin
|
||||
if ordered_media_attachment_ids.nil?
|
||||
[]
|
||||
else
|
||||
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
|
||||
|
||||
def proper
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue