Merge branch 'scarlett/pleroma-summary-html-api' into 'develop'
Scarlett/pleroma summary html api See merge request pleroma/pleroma!647
This commit is contained in:
commit
1881680e28
|
@ -181,6 +181,8 @@ def to_map(
|
||||||
|
|
||||||
reply_user = reply_parent && User.get_cached_by_ap_id(reply_parent.actor)
|
reply_user = reply_parent && User.get_cached_by_ap_id(reply_parent.actor)
|
||||||
|
|
||||||
|
summary = HTML.strip_tags(object["summary"])
|
||||||
|
|
||||||
%{
|
%{
|
||||||
"id" => activity.id,
|
"id" => activity.id,
|
||||||
"uri" => activity.data["object"]["id"],
|
"uri" => activity.data["object"]["id"],
|
||||||
|
@ -207,7 +209,8 @@ def to_map(
|
||||||
"activity_type" => "post",
|
"activity_type" => "post",
|
||||||
"possibly_sensitive" => possibly_sensitive,
|
"possibly_sensitive" => possibly_sensitive,
|
||||||
"visibility" => Pleroma.Web.MastodonAPI.StatusView.get_visibility(object),
|
"visibility" => Pleroma.Web.MastodonAPI.StatusView.get_visibility(object),
|
||||||
"summary" => HTML.strip_tags(object["summary"]) |> Formatter.emojify(object["emoji"])
|
"summary" => summary,
|
||||||
|
"summary_html" => summary |> Formatter.emojify(object["emoji"])
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -279,6 +279,8 @@ def render(
|
||||||
|
|
||||||
reply_user = reply_parent && User.get_cached_by_ap_id(reply_parent.actor)
|
reply_user = reply_parent && User.get_cached_by_ap_id(reply_parent.actor)
|
||||||
|
|
||||||
|
summary = HTML.strip_tags(summary)
|
||||||
|
|
||||||
%{
|
%{
|
||||||
"id" => activity.id,
|
"id" => activity.id,
|
||||||
"uri" => activity.data["object"]["id"],
|
"uri" => activity.data["object"]["id"],
|
||||||
|
@ -305,7 +307,8 @@ def render(
|
||||||
"activity_type" => "post",
|
"activity_type" => "post",
|
||||||
"possibly_sensitive" => possibly_sensitive,
|
"possibly_sensitive" => possibly_sensitive,
|
||||||
"visibility" => Pleroma.Web.MastodonAPI.StatusView.get_visibility(object),
|
"visibility" => Pleroma.Web.MastodonAPI.StatusView.get_visibility(object),
|
||||||
"summary" => HTML.strip_tags(summary) |> Formatter.emojify(object["emoji"])
|
"summary" => summary,
|
||||||
|
"summary_html" => summary |> Formatter.emojify(object["emoji"])
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ test "an activity" do
|
||||||
"published" => date,
|
"published" => date,
|
||||||
"type" => "Note",
|
"type" => "Note",
|
||||||
"content" => content_html,
|
"content" => content_html,
|
||||||
"summary" => "2hu",
|
"summary" => "2hu :2hu:",
|
||||||
"inReplyToStatusId" => 213_123,
|
"inReplyToStatusId" => 213_123,
|
||||||
"attachment" => [
|
"attachment" => [
|
||||||
object
|
object
|
||||||
|
@ -129,7 +129,7 @@ test "an activity" do
|
||||||
}
|
}
|
||||||
|
|
||||||
expected_html =
|
expected_html =
|
||||||
"<p>2hu</p>alert('YAY')Some <img height=\"32px\" width=\"32px\" alt=\"2hu\" title=\"2hu\" src=\"corndog.png\" /> content mentioning <a href=\"#{
|
"<p>2hu <img height=\"32px\" width=\"32px\" alt=\"2hu\" title=\"2hu\" src=\"corndog.png\" /></p>alert('YAY')Some <img height=\"32px\" width=\"32px\" alt=\"2hu\" title=\"2hu\" src=\"corndog.png\" /> content mentioning <a href=\"#{
|
||||||
mentioned_user.ap_id
|
mentioned_user.ap_id
|
||||||
}\">@shp</a>"
|
}\">@shp</a>"
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ test "an activity" do
|
||||||
"user" => UserView.render("show.json", %{user: user, for: follower}),
|
"user" => UserView.render("show.json", %{user: user, for: follower}),
|
||||||
"is_local" => false,
|
"is_local" => false,
|
||||||
"statusnet_html" => expected_html,
|
"statusnet_html" => expected_html,
|
||||||
"text" => "2hu" <> content,
|
"text" => "2hu :2hu:" <> content,
|
||||||
"is_post_verb" => true,
|
"is_post_verb" => true,
|
||||||
"created_at" => "Tue May 24 13:26:08 +0000 2016",
|
"created_at" => "Tue May 24 13:26:08 +0000 2016",
|
||||||
"in_reply_to_status_id" => 213_123,
|
"in_reply_to_status_id" => 213_123,
|
||||||
|
@ -163,7 +163,9 @@ test "an activity" do
|
||||||
"possibly_sensitive" => true,
|
"possibly_sensitive" => true,
|
||||||
"uri" => activity.data["object"]["id"],
|
"uri" => activity.data["object"]["id"],
|
||||||
"visibility" => "direct",
|
"visibility" => "direct",
|
||||||
"summary" => "2hu"
|
"summary" => "2hu :2hu:",
|
||||||
|
"summary_html" =>
|
||||||
|
"2hu <img height=\"32px\" width=\"32px\" alt=\"2hu\" title=\"2hu\" src=\"corndog.png\" />"
|
||||||
}
|
}
|
||||||
|
|
||||||
assert ActivityRepresenter.to_map(activity, %{
|
assert ActivityRepresenter.to_map(activity, %{
|
||||||
|
|
|
@ -81,10 +81,13 @@ test "a create activity with a summary containing emoji" do
|
||||||
|
|
||||||
result = ActivityView.render("activity.json", activity: activity)
|
result = ActivityView.render("activity.json", activity: activity)
|
||||||
|
|
||||||
expected =
|
expected = ":woollysocks: meow"
|
||||||
|
|
||||||
|
expected_html =
|
||||||
"<img height=\"32px\" width=\"32px\" alt=\"woollysocks\" title=\"woollysocks\" src=\"http://localhost:4001/finmoji/128px/woollysocks-128.png\" /> meow"
|
"<img height=\"32px\" width=\"32px\" alt=\"woollysocks\" title=\"woollysocks\" src=\"http://localhost:4001/finmoji/128px/woollysocks-128.png\" /> meow"
|
||||||
|
|
||||||
assert result["summary"] == expected
|
assert result["summary"] == expected
|
||||||
|
assert result["summary_html"] == expected_html
|
||||||
end
|
end
|
||||||
|
|
||||||
test "a create activity with a summary containing invalid HTML" do
|
test "a create activity with a summary containing invalid HTML" do
|
||||||
|
@ -99,6 +102,7 @@ test "a create activity with a summary containing invalid HTML" do
|
||||||
expected = "meow"
|
expected = "meow"
|
||||||
|
|
||||||
assert result["summary"] == expected
|
assert result["summary"] == expected
|
||||||
|
assert result["summary_html"] == expected
|
||||||
end
|
end
|
||||||
|
|
||||||
test "a create activity with a note" do
|
test "a create activity with a note" do
|
||||||
|
@ -134,6 +138,7 @@ test "a create activity with a note" do
|
||||||
"repeated" => false,
|
"repeated" => false,
|
||||||
"statusnet_conversation_id" => convo_id,
|
"statusnet_conversation_id" => convo_id,
|
||||||
"summary" => "",
|
"summary" => "",
|
||||||
|
"summary_html" => "",
|
||||||
"statusnet_html" =>
|
"statusnet_html" =>
|
||||||
"Hey <span><a data-user=\"#{other_user.id}\" href=\"#{other_user.ap_id}\">@<span>shp</span></a></span>!",
|
"Hey <span><a data-user=\"#{other_user.id}\" href=\"#{other_user.ap_id}\">@<span>shp</span></a></span>!",
|
||||||
"tags" => [],
|
"tags" => [],
|
||||||
|
|
Loading…
Reference in New Issue