You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3 KiB

  1. # frozen_string_literal: true
  2. class RSS::AccountSerializer
  3. include ActionView::Helpers::NumberHelper
  4. include StreamEntriesHelper
  5. include RoutingHelper
  6. def render(account, statuses)
  7. builder = RSSBuilder.new
  8. builder.title("#{display_name(account)} (@#{account.local_username_and_domain})")
  9. .description(account_description(account))
  10. .link(TagManager.instance.url_for(account))
  11. .logo(full_asset_url(asset_pack_path('logo.svg')))
  12. .accent_color('2b90d9')
  13. builder.image(full_asset_url(account.avatar.url(:original))) if account.avatar?
  14. builder.cover(full_asset_url(account.header.url(:original))) if account.header?
  15. statuses.each do |status|
  16. builder.item do |item|
  17. item.title(status.title)
  18. .link(TagManager.instance.url_for(status))
  19. .pub_date(status.created_at)
  20. .description(status.spoiler_text.presence || Formatter.instance.format(status).to_str)
  21. status.media_attachments.each do |media|
  22. item.enclosure(full_asset_url(media.file.url(:original, false)), media.file.content_type, length: media.file.size)
  23. end
  24. end
  25. end
  26. builder.to_xml
  27. end
  28. def self.render(account, statuses)
  29. new.render(account, statuses)
  30. end
  31. end