]> cat aescling's git repositories - mastodon.git/commitdiff
Fix errors when rendering RSS feeds (#18531)
authorEugen Rochko <eugen@zeonfederated.com>
Thu, 26 May 2022 21:02:42 +0000 (23:02 +0200)
committersingle-right-quote <11325618-aescling@users.noreply.gitlab.com>
Fri, 27 May 2022 03:55:21 +0000 (23:55 -0400)
app/helpers/formatting_helper.rb
app/helpers/languages_helper.rb
app/lib/rss/media_content.rb

index 526efd766f74cf0361258b96b45a1ac79bfebf0a..448177bec255a2630ef3228f807f25114832a9ed 100644 (file)
@@ -23,7 +23,7 @@ module FormattingHelper
 
     before_html = begin
       if status.spoiler_text?
-        "<p><strong>#{I18n.t('rss.content_warning', locale: valid_locale_or_nil(status.language))}</strong> #{h(status.spoiler_text)}</p><hr />"
+        "<p><strong>#{I18n.t('rss.content_warning', locale: available_locale_or_nil(status.language) || I18n.default_locale)}</strong> #{h(status.spoiler_text)}</p><hr />"
       else
         ''
       end
index d39bb6c930d8208689c2002a8e0c0c31a60788f5..4077e19bdf0052842e3ceedeb2be8b5b5b72a233 100644 (file)
@@ -254,4 +254,8 @@ module LanguagesHelper
   def valid_locale?(locale)
     locale.present? && SUPPORTED_LOCALES.key?(locale.to_sym)
   end
+
+  def available_locale_or_nil(locale_name)
+    locale_name.to_sym if locale_name.present? && I18n.available_locales.include?(locale_name.to_sym)
+  end
 end
index 7aefd8b40b9c5b4fbe556f11eab23dfbe926074e..f281fe29e4027c9af9f1fadb0d4af9b801cf58bb 100644 (file)
@@ -26,4 +26,10 @@ class RSS::MediaContent < RSS::Element
       description['type'] = 'plain'
     end
   end
+
+  def thumbnail(str)
+    append_element('media:thumbnail') do |thumbnail|
+      thumbnail['url'] = str
+    end
+  end
 end