Preserve newlines in messages.
authorRoger Braun <roger@rogerbraun.net>
Sun, 16 Apr 2017 09:51:00 +0000 (11:51 +0200)
committerRoger Braun <roger@rogerbraun.net>
Sun, 16 Apr 2017 09:51:00 +0000 (11:51 +0200)
lib/pleroma/web/twitter_api/twitter_api.ex
test/web/twitter_api/twitter_api_test.exs

index 557faf4543683d663e5fe4ba9c922d9f349f8c71..735d88832e5bf962c7e46c1cc4d44fca78dd7047 100644 (file)
@@ -13,6 +13,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
     context = ActivityPub.generate_context_id
 
     content = HtmlSanitizeEx.strip_tags(data["status"])
+    |> String.replace("\n", "<br>")
 
     mentions = parse_mentions(content)
 
index eb5f8ec26ece74e3167369d4462989b7658da180..b8bfb4cf92676136796eac3b0a48c749603df94f 100644 (file)
@@ -27,13 +27,13 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
     object = Repo.insert!(%Object{data: object_data})
 
     input = %{
-      "status" => "Hello again, @shp.<script></script>",
+      "status" => "Hello again, @shp.<script></script>\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, <a href='shp'>@shp</a>."
+    assert get_in(activity.data, ["object", "content"]) == "Hello again, <a href='shp'>@shp</a>.<br>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