From b41f3eff84e9ec496f0049cdd4fa9388a0fb7b5c Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 16 Apr 2017 11:51:00 +0200 Subject: [PATCH] Preserve newlines in messages. --- lib/pleroma/web/twitter_api/twitter_api.ex | 1 + test/web/twitter_api/twitter_api_test.exs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index 557faf454..735d88832 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -13,6 +13,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do context = ActivityPub.generate_context_id content = HtmlSanitizeEx.strip_tags(data["status"]) + |> String.replace("\n", "
") mentions = parse_mentions(content) diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index eb5f8ec26..b8bfb4cf9 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -27,13 +27,13 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do object = Repo.insert!(%Object{data: object_data}) input = %{ - "status" => "Hello again, @shp.", + "status" => "Hello again, @shp.\nThis is on another line.", "media_ids" => [object.id] } { :ok, activity = %Activity{} } = TwitterAPI.create_status(user, input) - assert get_in(activity.data, ["object", "content"]) == "Hello again, @shp." + assert get_in(activity.data, ["object", "content"]) == "Hello again, @shp.
This is on another line." assert get_in(activity.data, ["object", "type"]) == "Note" assert get_in(activity.data, ["object", "actor"]) == user.ap_id assert get_in(activity.data, ["actor"]) == user.ap_id