FIX: handle missing user for posts

This commit is contained in:
Sam Saffron 2016-05-17 09:35:30 +10:00
parent 3f0abb7c17
commit 54cfba56dc
1 changed files with 6 additions and 2 deletions

View File

@ -12,12 +12,16 @@
<atom:link href="<%= @atom_link %>" rel="self" type="application/rss+xml" /> <atom:link href="<%= @atom_link %>" rel="self" type="application/rss+xml" />
<% @topic_list.topics.each do |topic| %> <% @topic_list.topics.each do |topic| %>
<% topic_url = topic.url -%> <% topic_url = topic.url -%>
<% username = topic.user ? topic.user.username : "" %>
<% name = topic.user ? topic.user.name : "" %>
<item> <item>
<title><%= topic.title %></title> <title><%= topic.title %></title>
<dc:creator><![CDATA[<%= "@#{topic.user.username}#{" #{topic.user.name}" if (topic.user.name.present? && SiteSetting.enable_names?)}" -%>]]></dc:creator> <dc:creator><![CDATA[<%= "@#{username}#{" #{name}" if (name.present? && SiteSetting.enable_names?)}" -%>]]></dc:creator>
<category><%= topic.category.name %></category> <category><%= topic.category.name %></category>
<description><![CDATA[ <description><![CDATA[
<p><%= t('author_wrote', author: link_to("@#{topic.user.username}", "#{Discourse.base_url}/users/#{topic.user.username_lower}")).html_safe %></p> <% if username.present? %>
<p><%= t('author_wrote', author: link_to("@#{username}", "#{Discourse.base_url}/users/#{topic.user.username_lower}")).html_safe %></p>
<% end %>
<blockquote> <blockquote>
<%= topic.posts.first.cooked.html_safe %> <%= topic.posts.first.cooked.html_safe %>
</blockquote> </blockquote>