diff options
author | lain <lain@soykaf.club> | 2020-05-30 12:30:31 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-05-30 12:30:31 +0200 |
commit | 8bdf18d7c10f0e740b2f5e0fa5063c522b8b3872 (patch) | |
tree | 4d33c221c91a6df4d451ebaa0291319959806f73 /test | |
parent | 2c9465cc51160546ae054d1a1912fbb8e9add8e8 (diff) | |
download | pleroma-8bdf18d7c10f0e740b2f5e0fa5063c522b8b3872.tar.gz |
CommonAPI: Linkify chat messages.
Diffstat (limited to 'test')
-rw-r--r-- | test/web/common_api/common_api_test.exs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 9e129e5a7..41c6909de 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -50,6 +50,29 @@ defmodule Pleroma.Web.CommonAPITest do assert activity end + test "it linkifies" do + author = insert(:user) + recipient = insert(:user) + + other_user = insert(:user) + + {:ok, activity} = + CommonAPI.post_chat_message( + author, + recipient, + "https://example.org is the site of @#{other_user.nickname} #2hu" + ) + + assert other_user.ap_id not in activity.recipients + + object = Object.normalize(activity, false) + + assert object.data["content"] == + "<a href=\"https://example.org\" rel=\"ugc\">https://example.org</a> is the site of <span class=\"h-card\"><a class=\"u-url mention\" data-user=\"#{ + other_user.id + }\" href=\"#{other_user.ap_id}\" rel=\"ugc\">@<span>#{other_user.nickname}</span></a></span> <a class=\"hashtag\" data-tag=\"2hu\" href=\"http://localhost:4001/tag/2hu\">#2hu</a>" + end + test "it posts a chat message" do author = insert(:user) recipient = insert(:user) |