CommonAPI: Newlines -> br for chat messages.
This commit is contained in:
parent
8ff3425828
commit
af9090238e
|
@ -54,6 +54,9 @@ defp format_chat_content(content) do
|
|||
content
|
||||
|> Formatter.html_escape("text/plain")
|
||||
|> Formatter.linkify()
|
||||
|> (fn {text, mentions, tags} ->
|
||||
{String.replace(text, ~r/\r?\n/, "<br>"), mentions, tags}
|
||||
end).()
|
||||
|
||||
text
|
||||
end
|
||||
|
|
|
@ -50,6 +50,26 @@ test "it posts a chat message without content but with an attachment" do
|
|||
assert activity
|
||||
end
|
||||
|
||||
test "it adds html newlines" do
|
||||
author = insert(:user)
|
||||
recipient = insert(:user)
|
||||
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post_chat_message(
|
||||
author,
|
||||
recipient,
|
||||
"uguu\nuguuu"
|
||||
)
|
||||
|
||||
assert other_user.ap_id not in activity.recipients
|
||||
|
||||
object = Object.normalize(activity, false)
|
||||
|
||||
assert object.data["content"] == "uguu<br/>uguuu"
|
||||
end
|
||||
|
||||
test "it linkifies" do
|
||||
author = insert(:user)
|
||||
recipient = insert(:user)
|
||||
|
|
Loading…
Reference in New Issue