fix(feed): format RSS build dates
This commit is contained in:
parent
d0c8ca92a5
commit
96f471a291
3 changed files with 33 additions and 2 deletions
|
|
@ -38,6 +38,20 @@ defmodule Pleroma.Web.Feed.FeedView do
|
|||
end
|
||||
end
|
||||
|
||||
def most_recent_update([], :rss), do: nil
|
||||
|
||||
def most_recent_update(activities, :rss) do
|
||||
activities
|
||||
|> Enum.map(fn activity ->
|
||||
case Object.normalize(activity, fetch: false) do
|
||||
%Object{updated_at: updated_at} -> updated_at
|
||||
_ -> activity.updated_at
|
||||
end
|
||||
end)
|
||||
|> Enum.max_by(&NaiveDateTime.to_erl/1)
|
||||
|> to_rfc2822()
|
||||
end
|
||||
|
||||
def most_recent_update(activities, user, :atom) do
|
||||
(List.first(activities) || user).updated_at
|
||||
|> to_rfc3339()
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@
|
|||
<webfeeds:logo><%= feed_logo() %></webfeeds:logo>
|
||||
<webfeeds:icon><%= feed_logo() %></webfeeds:icon>
|
||||
<webfeeds:accentColor>2b90d9</webfeeds:accentColor>
|
||||
<lastBuildDate><%= most_recent_update(@activities) || to_rfc2822(NaiveDateTime.utc_now()) %></lastBuildDate>
|
||||
<%= with last_build_date when not is_nil(last_build_date) <- most_recent_update(@activities, :rss) do %>
|
||||
<lastBuildDate><%= last_build_date %></lastBuildDate>
|
||||
<% end %>
|
||||
<generator><%= Pleroma.Application.named_version() %></generator>
|
||||
<%= for activity <- @activities do %>
|
||||
<%= render Phoenix.Controller.view_module(@conn), "_tag_activity.xml", Map.merge(assigns, prepare_activity(activity)) %>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue