forked from AkkomaGang/akkoma
twitter api: use ActivityView.render_content() where appropriate instead of duplicating the logic
This commit is contained in:
parent
ea982e7503
commit
66819ea784
2 changed files with 3 additions and 10 deletions
|
@ -4,7 +4,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
|
||||||
use Pleroma.Web.TwitterAPI.Representers.BaseRepresenter
|
use Pleroma.Web.TwitterAPI.Representers.BaseRepresenter
|
||||||
alias Pleroma.Web.TwitterAPI.Representers.ObjectRepresenter
|
alias Pleroma.Web.TwitterAPI.Representers.ObjectRepresenter
|
||||||
alias Pleroma.{Activity, User}
|
alias Pleroma.{Activity, User}
|
||||||
alias Pleroma.Web.TwitterAPI.{TwitterAPI, UserView}
|
alias Pleroma.Web.TwitterAPI.{TwitterAPI, UserView, ActivityView}
|
||||||
alias Pleroma.Web.CommonAPI.Utils
|
alias Pleroma.Web.CommonAPI.Utils
|
||||||
alias Pleroma.Formatter
|
alias Pleroma.Formatter
|
||||||
|
|
||||||
|
@ -164,14 +164,7 @@ def to_map(
|
||||||
|
|
||||||
tags = if possibly_sensitive, do: Enum.uniq(["nsfw" | tags]), else: tags
|
tags = if possibly_sensitive, do: Enum.uniq(["nsfw" | tags]), else: tags
|
||||||
|
|
||||||
summary = activity.data["object"]["summary"]
|
{summary, content} = ActivityView.render_content(object)
|
||||||
|
|
||||||
content =
|
|
||||||
if !!summary and summary != "" do
|
|
||||||
"<span>#{activity.data["object"]["summary"]}</span><br />#{content}</span>"
|
|
||||||
else
|
|
||||||
content
|
|
||||||
end
|
|
||||||
|
|
||||||
html =
|
html =
|
||||||
HtmlSanitizeEx.basic_html(content)
|
HtmlSanitizeEx.basic_html(content)
|
||||||
|
|
|
@ -126,7 +126,7 @@ test "an activity" do
|
||||||
}
|
}
|
||||||
|
|
||||||
expected_html =
|
expected_html =
|
||||||
"<span>2hu</span><br />alert('YAY')Some <img height='32px' width='32px' alt='2hu' title='2hu' src='corndog.png' /> content mentioning <a href=\"#{
|
"<p>2hu</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>"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue