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 AccountsHelper
  5. include RoutingHelper
  6. def render(account, statuses, tag)
  7. builder = RSSBuilder.new
  8. builder.title("#{display_name(account)} (@#{account.local_username_and_domain})")
  9. .description(account_description(account))
  10. .link(tag.present? ? short_account_tag_url(account, tag) : short_account_url(account))
  11. .logo(full_pack_url('media/images/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(ActivityPub::TagManager.instance.url_for(status))
  19. .pub_date(status.created_at)
  20. .description(status.spoiler_text.presence || Formatter.instance.format(status, inline_poll_options: true).to_str)
  21. status.media_attachments.each do |media|
  22. item.enclosure(full_asset_url(media.file.url(:original, false)), media.file.content_type, media.file.size)
  23. end
  24. end
  25. end
  26. builder.to_xml
  27. end
  28. def self.render(account, statuses, tag)
  29. new.render(account, statuses, tag)
  30. end
  31. end