diff --git a/app/helpers/statuses_helper.rb b/app/helpers/statuses_helper.rb index 286c53d834..74ebe3dabc 100644 --- a/app/helpers/statuses_helper.rb +++ b/app/helpers/statuses_helper.rb @@ -18,7 +18,7 @@ module StatusesHelper end end - def media_summary(status) + def attachment_types(status) attachments = { image: 0, video: 0, audio: 0 } status.ordered_media_attachments.each do |media| @@ -31,6 +31,12 @@ module StatusesHelper end end + attachments + end + + def media_summary(status) + attachments = attachment_types(status) + text = attachments.to_a.reject { |_, value| value.zero? }.map { |key, value| I18n.t("statuses.attached.#{key}", count: value) }.join(' ยท ') return if text.blank? diff --git a/app/serializers/oembed_serializer.rb b/app/serializers/oembed_serializer.rb index d6261d7242..0ccb7cba5a 100644 --- a/app/serializers/oembed_serializer.rb +++ b/app/serializers/oembed_serializer.rb @@ -2,6 +2,7 @@ class OEmbedSerializer < ActiveModel::Serializer include RoutingHelper + include StatusesHelper include ActionView::Helpers::TagHelper attributes :type, :version, :author_name, @@ -17,7 +18,7 @@ class OEmbedSerializer < ActiveModel::Serializer end def author_name - object.account.display_name.presence || object.account.username + (attachment_types(object)[:video]).positive? ? status_description(object) : (object.account.display_name.presence || object.account.username) end def author_url