forked from AkkomaGang/akkoma
fix for use of published from different entities
This commit is contained in:
parent
2b57f73b77
commit
4d330d9df1
6 changed files with 28 additions and 32 deletions
|
@ -23,7 +23,7 @@ def pub_date(date) when is_binary(date) do
|
||||||
def pub_date(%DateTime{} = date), do: Timex.format!(date, "{RFC822}")
|
def pub_date(%DateTime{} = date), do: Timex.format!(date, "{RFC822}")
|
||||||
|
|
||||||
def prepare_activity(activity, opts \\ []) do
|
def prepare_activity(activity, opts \\ []) do
|
||||||
object = activity_object(activity)
|
object = Object.normalize(activity)
|
||||||
|
|
||||||
actor =
|
actor =
|
||||||
if opts[:actor] do
|
if opts[:actor] do
|
||||||
|
@ -33,7 +33,6 @@ def prepare_activity(activity, opts \\ []) do
|
||||||
%{
|
%{
|
||||||
activity: activity,
|
activity: activity,
|
||||||
data: Map.get(object, :data),
|
data: Map.get(object, :data),
|
||||||
object: object,
|
|
||||||
actor: actor
|
actor: actor
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -68,9 +67,7 @@ def logo(user) do
|
||||||
|
|
||||||
def last_activity(activities), do: List.last(activities)
|
def last_activity(activities), do: List.last(activities)
|
||||||
|
|
||||||
def activity_object(activity), do: Object.normalize(activity)
|
def activity_title(%{"content" => content}, opts \\ %{}) do
|
||||||
|
|
||||||
def activity_title(%{data: %{"content" => content}}, opts \\ %{}) do
|
|
||||||
content
|
content
|
||||||
|> Pleroma.Web.Metadata.Utils.scrub_html()
|
|> Pleroma.Web.Metadata.Utils.scrub_html()
|
||||||
|> Pleroma.Emoji.Formatter.demojify()
|
|> Pleroma.Emoji.Formatter.demojify()
|
||||||
|
@ -78,7 +75,7 @@ def activity_title(%{data: %{"content" => content}}, opts \\ %{}) do
|
||||||
|> escape()
|
|> escape()
|
||||||
end
|
end
|
||||||
|
|
||||||
def activity_content(%{data: %{"content" => content}}) do
|
def activity_content(%{"content" => content}) do
|
||||||
content
|
content
|
||||||
|> String.replace(~r/[\n\r]/, "")
|
|> String.replace(~r/[\n\r]/, "")
|
||||||
|> escape()
|
|> escape()
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
<activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
|
<activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
|
||||||
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||||
<id><%= @data["id"] %></id>
|
<id><%= @data["id"] %></id>
|
||||||
<title><%= activity_title(@object, Keyword.get(@feed_config, :post_title, %{})) %></title>
|
<title><%= activity_title(@data, Keyword.get(@feed_config, :post_title, %{})) %></title>
|
||||||
<content type="html"><%= activity_content(@object) %></content>
|
<content type="html"><%= activity_content(@data) %></content>
|
||||||
<published><%= @data["published"] %></published>
|
<published><%= @activity.data["published"] %></published>
|
||||||
<updated><%= @data["published"] %></updated>
|
<updated><%= @activity.data["published"] %></updated>
|
||||||
<ostatus:conversation ref="<%= activity_context(@activity) %>">
|
<ostatus:conversation ref="<%= activity_context(@activity) %>">
|
||||||
<%= activity_context(@activity) %>
|
<%= activity_context(@activity) %>
|
||||||
</ostatus:conversation>
|
</ostatus:conversation>
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
<activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
|
<activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
|
||||||
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||||
<guid><%= @data["id"] %></guid>
|
<guid><%= @data["id"] %></guid>
|
||||||
<title><%= activity_title(@object, Keyword.get(@feed_config, :post_title, %{})) %></title>
|
<title><%= activity_title(@data, Keyword.get(@feed_config, :post_title, %{})) %></title>
|
||||||
<description><%= activity_content(@object) %></description>
|
<description><%= activity_content(@data) %></description>
|
||||||
<pubDate><%= @data["published"] %></pubDate>
|
<pubDate><%= @activity.data["published"] %></pubDate>
|
||||||
<updated><%= @data["published"] %></updated>
|
<updated><%= @activity.data["published"] %></updated>
|
||||||
<ostatus:conversation ref="<%= activity_context(@activity) %>">
|
<ostatus:conversation ref="<%= activity_context(@activity) %>">
|
||||||
<%= activity_context(@activity) %>
|
<%= activity_context(@activity) %>
|
||||||
</ostatus:conversation>
|
</ostatus:conversation>
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<entry>
|
<entry>
|
||||||
<activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
|
<activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
|
||||||
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||||
|
|
||||||
<%= render @view_module, "_tag_author.atom", assigns %>
|
<%= render @view_module, "_tag_author.atom", assigns %>
|
||||||
|
|
||||||
<id><%= @data["id"] %></id>
|
<id><%= @data["id"] %></id>
|
||||||
<title><%= activity_title(@object, Keyword.get(@feed_config, :post_title, %{})) %></title>
|
<title><%= activity_title(@data, Keyword.get(@feed_config, :post_title, %{})) %></title>
|
||||||
<content type="html"><%= activity_content(@object) %></content>
|
<content type="html"><%= activity_content(@data) %></content>
|
||||||
|
|
||||||
<%= if @activity.local do %>
|
<%= if @activity.local do %>
|
||||||
<link type="application/atom+xml" href='<%= @data["id"] %>' rel="self"/>
|
<link type="application/atom+xml" href='<%= @data["id"] %>' rel="self"/>
|
||||||
|
@ -15,8 +15,8 @@
|
||||||
<link type="text/html" href='<%= @data["external_url"] %>' rel="alternate"/>
|
<link type="text/html" href='<%= @data["external_url"] %>' rel="alternate"/>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<published><%= @data["published"] %></published>
|
<published><%= @activity.data["published"] %></published>
|
||||||
<updated><%= @data["published"] %></updated>
|
<updated><%= @activity.data["published"] %></updated>
|
||||||
|
|
||||||
<ostatus:conversation ref="<%= activity_context(@activity) %>">
|
<ostatus:conversation ref="<%= activity_context(@activity) %>">
|
||||||
<%= activity_context(@activity) %>
|
<%= activity_context(@activity) %>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<%= if @data["summary"] do %>
|
<%= if @data["summary"] do %>
|
||||||
<summary><%= @data["summary"] %></summary>
|
<summary><%= @data["summary"] %></summary>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= for id <- @activity.recipients do %>
|
<%= for id <- @activity.recipients do %>
|
||||||
<%= if id == Pleroma.Constants.as_public() do %>
|
<%= if id == Pleroma.Constants.as_public() do %>
|
||||||
<link rel="mentioned"
|
<link rel="mentioned"
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= for tag <- @data["tag"] || [] do %>
|
<%= for tag <- @data["tag"] || [] do %>
|
||||||
<category term="<%= tag %>"></category>
|
<category term="<%= tag %>"></category>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
<item>
|
<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>
|
<guid isPermalink="true"><%= activity_context(@activity) %></guid>
|
||||||
<link><%= activity_context(@activity) %></link>
|
<link><%= activity_context(@activity) %></link>
|
||||||
<pubDate><%= pub_date(@data["published"]) %></pubDate>
|
<pubDate><%= pub_date(@activity.data["published"]) %></pubDate>
|
||||||
|
|
||||||
<description><%= activity_content(@object) %></description>
|
<description><%= activity_content(@data) %></description>
|
||||||
<%= for attachment <- @data["attachment"] || [] do %>
|
<%= for attachment <- @data["attachment"] || [] do %>
|
||||||
<enclosure url="<%= attachment_href(attachment) %>" type="<%= attachment_type(attachment) %>"/>
|
<enclosure url="<%= attachment_href(attachment) %>" type="<%= attachment_type(attachment) %>"/>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
</item>
|
|
||||||
|
|
||||||
|
</item>
|
||||||
|
|
|
@ -150,8 +150,8 @@ test "gets a feed (RSS)", %{conn: conn} do
|
||||||
obj2 = Object.normalize(activity2)
|
obj2 = Object.normalize(activity2)
|
||||||
|
|
||||||
assert xpath(xml, ~x"//channel/item/description/text()"sl) == [
|
assert xpath(xml, ~x"//channel/item/description/text()"sl) == [
|
||||||
HtmlEntities.decode(FeedView.activity_content(obj2)),
|
HtmlEntities.decode(FeedView.activity_content(obj2.data)),
|
||||||
HtmlEntities.decode(FeedView.activity_content(obj1))
|
HtmlEntities.decode(FeedView.activity_content(obj1.data))
|
||||||
]
|
]
|
||||||
|
|
||||||
response =
|
response =
|
||||||
|
|
Loading…
Reference in a new issue