fix for use of published from different entities
authorAlexander Strizhakov <alex.strizhakov@gmail.com>
Thu, 16 Apr 2020 15:05:36 +0000 (18:05 +0300)
committerAlexander Strizhakov <alex.strizhakov@gmail.com>
Thu, 16 Apr 2020 15:05:36 +0000 (18:05 +0300)
lib/pleroma/web/feed/feed_view.ex
lib/pleroma/web/templates/feed/feed/_activity.atom.eex
lib/pleroma/web/templates/feed/feed/_activity.rss.eex
lib/pleroma/web/templates/feed/feed/_tag_activity.atom.eex
lib/pleroma/web/templates/feed/feed/_tag_activity.xml.eex
test/web/feed/tag_controller_test.exs

index e18adaea898bacabda588a85a90a563070d3ba11..1ae03e7e28d2d3651cb91a9134168e7f50beb2b9 100644 (file)
@@ -23,7 +23,7 @@ defmodule Pleroma.Web.Feed.FeedView do
   def pub_date(%DateTime{} = date), do: Timex.format!(date, "{RFC822}")
 
   def prepare_activity(activity, opts \\ []) do
-    object = activity_object(activity)
+    object = Object.normalize(activity)
 
     actor =
       if opts[:actor] do
@@ -33,7 +33,6 @@ defmodule Pleroma.Web.Feed.FeedView do
     %{
       activity: activity,
       data: Map.get(object, :data),
-      object: object,
       actor: actor
     }
   end
@@ -68,9 +67,7 @@ defmodule Pleroma.Web.Feed.FeedView do
 
   def last_activity(activities), do: List.last(activities)
 
-  def activity_object(activity), do: Object.normalize(activity)
-
-  def activity_title(%{data: %{"content" => content}}, opts \\ %{}) do
+  def activity_title(%{"content" => content}, opts \\ %{}) do
     content
     |> Pleroma.Web.Metadata.Utils.scrub_html()
     |> Pleroma.Emoji.Formatter.demojify()
@@ -78,7 +75,7 @@ defmodule Pleroma.Web.Feed.FeedView do
     |> escape()
   end
 
-  def activity_content(%{data: %{"content" => content}}) do
+  def activity_content(%{"content" => content}) do
     content
     |> String.replace(~r/[\n\r]/, "")
     |> escape()
index ac8a75009de834a7e97d422c1a9002121879b39a..78350f2aa194c8ca311a6db733155a55027871d4 100644 (file)
@@ -2,10 +2,10 @@
   <activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
   <activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
   <id><%= @data["id"] %></id>
-  <title><%= activity_title(@object, Keyword.get(@feed_config, :post_title, %{})) %></title>
-  <content type="html"><%= activity_content(@object) %></content>
-  <published><%= @data["published"] %></published>
-  <updated><%= @data["published"] %></updated>
+  <title><%= activity_title(@data, Keyword.get(@feed_config, :post_title, %{})) %></title>
+  <content type="html"><%= activity_content(@data) %></content>
+  <published><%= @activity.data["published"] %></published>
+  <updated><%= @activity.data["published"] %></updated>
   <ostatus:conversation ref="<%= activity_context(@activity) %>">
     <%= activity_context(@activity) %>
   </ostatus:conversation>
index a4dbed6382aaeabde389221a9206c84555665665..a304a16afecec2827062775909c9c97d17a4de6e 100644 (file)
@@ -2,10 +2,10 @@
   <activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
   <activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
   <guid><%= @data["id"] %></guid>
-  <title><%= activity_title(@object, Keyword.get(@feed_config, :post_title, %{})) %></title>
-  <description><%= activity_content(@object) %></description>
-  <pubDate><%= @data["published"] %></pubDate>
-  <updated><%= @data["published"] %></updated>
+  <title><%= activity_title(@data, Keyword.get(@feed_config, :post_title, %{})) %></title>
+  <description><%= activity_content(@data) %></description>
+  <pubDate><%= @activity.data["published"] %></pubDate>
+  <updated><%= @activity.data["published"] %></updated>
   <ostatus:conversation ref="<%= activity_context(@activity) %>">
     <%= activity_context(@activity) %>
   </ostatus:conversation>
index da4fa6d6c76109fa81f501f6f97bd7a621540fcd..cf5874a91341cb8108631829aa150ec9fd70e15b 100644 (file)
@@ -1,12 +1,12 @@
 <entry>
     <activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
     <activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
-    
+
     <%= render @view_module, "_tag_author.atom", assigns %>
-    
+
     <id><%= @data["id"] %></id>
-    <title><%= activity_title(@object, Keyword.get(@feed_config, :post_title, %{})) %></title>
-    <content type="html"><%= activity_content(@object) %></content>
+    <title><%= activity_title(@data, Keyword.get(@feed_config, :post_title, %{})) %></title>
+    <content type="html"><%= activity_content(@data) %></content>
 
   <%= if @activity.local do %>
     <link type="application/atom+xml" href='<%= @data["id"] %>' rel="self"/>
@@ -15,8 +15,8 @@
     <link type="text/html" href='<%= @data["external_url"] %>' rel="alternate"/>
   <% end %>
 
-    <published><%= @data["published"] %></published>
-    <updated><%= @data["published"] %></updated>
+    <published><%= @activity.data["published"] %></published>
+    <updated><%= @activity.data["published"] %></updated>
 
     <ostatus:conversation ref="<%= activity_context(@activity) %>">
       <%= activity_context(@activity) %>
@@ -26,7 +26,7 @@
    <%= if @data["summary"] do %>
     <summary><%= @data["summary"] %></summary>
    <% end %>
-  
+
     <%= for id <- @activity.recipients do %>
       <%= if id == Pleroma.Constants.as_public() do %>
         <link rel="mentioned"
@@ -40,7 +40,7 @@
         <% end %>
       <% end %>
     <% end %>
-  
+
     <%= for tag <- @data["tag"] || [] do %>
       <category term="<%= tag %>"></category>
     <% end %>
index 295574df1c1f5a57ddbb33bc7e0ebe965da3fa20..2334e24a21715bc8e00ad86d2fca66355553c1cd 100644 (file)
@@ -1,15 +1,14 @@
 <item>
-  <title><%= activity_title(@object, Keyword.get(@feed_config, :post_title, %{})) %></title>
-  
-  
+  <title><%= activity_title(@data, Keyword.get(@feed_config, :post_title, %{})) %></title>
+
+
   <guid isPermalink="true"><%= activity_context(@activity) %></guid>
   <link><%= activity_context(@activity) %></link>
-  <pubDate><%= pub_date(@data["published"]) %></pubDate>
-  
-  <description><%= activity_content(@object) %></description>
+  <pubDate><%= pub_date(@activity.data["published"]) %></pubDate>
+
+  <description><%= activity_content(@data) %></description>
   <%= for attachment <- @data["attachment"] || [] do %>
     <enclosure url="<%= attachment_href(attachment) %>" type="<%= attachment_type(attachment) %>"/>
   <% end %>
-  
-</item>
 
+</item>
index e863df86b0c7fa987a02149b98e5c99f40586696..d95aac108620ae31cccef07f94fc7e17817cc51d 100644 (file)
@@ -150,8 +150,8 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
     obj2 = Object.normalize(activity2)
 
     assert xpath(xml, ~x"//channel/item/description/text()"sl) == [
-             HtmlEntities.decode(FeedView.activity_content(obj2)),
-             HtmlEntities.decode(FeedView.activity_content(obj1))
+             HtmlEntities.decode(FeedView.activity_content(obj2.data)),
+             HtmlEntities.decode(FeedView.activity_content(obj1.data))
            ]
 
     response =