Linkify custom fields values in ActivityPub.UserViewx
authorEgor Kislitsyn <egor@kislitsyn.com>
Mon, 29 Jul 2019 12:17:09 +0000 (19:17 +0700)
committerEgor Kislitsyn <egor@kislitsyn.com>
Wed, 14 Aug 2019 07:52:54 +0000 (14:52 +0700)
lib/pleroma/web/activity_pub/views/user_view.ex
test/web/activity_pub/views/user_view_test.exs

index 7b4bc998bfe8e21178ad6e47f0b50fedfda972f9..b2a22478d882b6696fe06d89d0c120845965088d 100644 (file)
@@ -84,6 +84,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
       user.info
       |> User.Info.fields()
       |> Enum.map(&Map.put(&1, "type", "PropertyValue"))
+      |> Enum.map(fn f -> Map.update!(f, "value", &AutoLinker.link(&1)) end)
 
     %{
       "id" => user.ap_id,
index 48a522c6ceaa5ce3c060bd281db7a01da2d963e2..a2aa5238126ba2bc519092d000be941f23aa52c0 100644 (file)
@@ -33,7 +33,11 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do
     assert %{
              "attachment" => [
                %{"name" => "foo", "type" => "PropertyValue", "value" => "bar"},
-               %{"name" => "website", "type" => "PropertyValue", "value" => "cofe.my"}
+               %{
+                 "name" => "website",
+                 "type" => "PropertyValue",
+                 "value" => "<a href=\"http://cofe.my\">cofe.my</a>"
+               }
              ]
            } = UserView.render("user.json", %{user: user})
   end