Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into issue/2115
[akkoma] / test / web / activity_pub / transmogrifier_test.exs
index f7b7d1a9f2b89063495a584705ff0293da8a495e..561674f010c1e6c748f0c9faca171beb267bec7a 100644 (file)
@@ -8,7 +8,6 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
 
   alias Pleroma.Activity
   alias Pleroma.Object
-  alias Pleroma.Object.Fetcher
   alias Pleroma.Tests.ObanHelpers
   alias Pleroma.User
   alias Pleroma.Web.ActivityPub.Transmogrifier
@@ -45,15 +44,6 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       assert "test" in object.data["tag"]
     end
 
-    test "it works for incoming notices with url not being a string (prismo)" do
-      data = File.read!("test/fixtures/prismo-url-map.json") |> Poison.decode!()
-
-      {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
-      object = Object.normalize(data["object"])
-
-      assert object.data["url"] == "https://prismo.news/posts/83"
-    end
-
     test "it cleans up incoming notices which are not really DMs" do
       user = insert(:user)
       other_user = insert(:user)
@@ -105,7 +95,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
 
       object =
         data["object"]
-        |> Map.put("inReplyTo", "https://shitposter.club/notice/2827873")
+        |> Map.put("inReplyTo", "https://mstdn.io/users/mayuutann/statuses/99568293732299394")
 
       data = Map.put(data, "object", object)
       {:ok, returned_activity} = Transmogrifier.handle_incoming(data)
@@ -113,10 +103,11 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
 
       assert activity =
                Activity.get_create_by_object_ap_id(
-                 "tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
+                 "https://mstdn.io/users/mayuutann/statuses/99568293732299394"
                )
 
-      assert returned_object.data["inReplyToAtomUri"] == "https://shitposter.club/notice/2827873"
+      assert returned_object.data["inReplyTo"] ==
+               "https://mstdn.io/users/mayuutann/statuses/99568293732299394"
     end
 
     test "it does not fetch reply-to activities beyond max replies depth limit" do
@@ -140,8 +131,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
                  "tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
                )
 
-        assert returned_object.data["inReplyToAtomUri"] ==
-                 "https://shitposter.club/notice/2827873"
+        assert returned_object.data["inReplyTo"] == "https://shitposter.club/notice/2827873"
       end
     end
 
@@ -160,7 +150,15 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
 
       assert capture_log(fn ->
                {:ok, _returned_activity} = Transmogrifier.handle_incoming(data)
-             end) =~ "[error] Couldn't fetch \"https://404.site/whatever\", error: nil"
+             end) =~ "[warn] Couldn't fetch \"https://404.site/whatever\", error: nil"
+    end
+
+    test "it does not work for deactivated users" do
+      data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
+
+      insert(:user, ap_id: data["actor"], deactivated: true)
+
+      assert {:error, _} = Transmogrifier.handle_incoming(data)
     end
 
     test "it works for incoming notices" do
@@ -217,84 +215,6 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       assert Enum.at(object.data["tag"], 2) == "moo"
     end
 
-    test "it works for incoming questions" do
-      data = File.read!("test/fixtures/mastodon-question-activity.json") |> Poison.decode!()
-
-      {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
-
-      object = Object.normalize(activity)
-
-      assert Enum.all?(object.data["oneOf"], fn choice ->
-               choice["name"] in [
-                 "Dunno",
-                 "Everyone knows that!",
-                 "25 char limit is dumb",
-                 "I can't even fit a funny"
-               ]
-             end)
-    end
-
-    test "it works for incoming listens" do
-      data = %{
-        "@context" => "https://www.w3.org/ns/activitystreams",
-        "to" => ["https://www.w3.org/ns/activitystreams#Public"],
-        "cc" => [],
-        "type" => "Listen",
-        "id" => "http://mastodon.example.org/users/admin/listens/1234/activity",
-        "actor" => "http://mastodon.example.org/users/admin",
-        "object" => %{
-          "type" => "Audio",
-          "id" => "http://mastodon.example.org/users/admin/listens/1234",
-          "attributedTo" => "http://mastodon.example.org/users/admin",
-          "title" => "lain radio episode 1",
-          "artist" => "lain",
-          "album" => "lain radio",
-          "length" => 180_000
-        }
-      }
-
-      {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
-
-      object = Object.normalize(activity)
-
-      assert object.data["title"] == "lain radio episode 1"
-      assert object.data["artist"] == "lain"
-      assert object.data["album"] == "lain radio"
-      assert object.data["length"] == 180_000
-    end
-
-    test "it rewrites Note votes to Answers and increments vote counters on question activities" do
-      user = insert(:user)
-
-      {:ok, activity} =
-        CommonAPI.post(user, %{
-          status: "suya...",
-          poll: %{options: ["suya", "suya.", "suya.."], expires_in: 10}
-        })
-
-      object = Object.normalize(activity)
-
-      data =
-        File.read!("test/fixtures/mastodon-vote.json")
-        |> Poison.decode!()
-        |> Kernel.put_in(["to"], user.ap_id)
-        |> Kernel.put_in(["object", "inReplyTo"], object.data["id"])
-        |> Kernel.put_in(["object", "to"], user.ap_id)
-
-      {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
-      answer_object = Object.normalize(activity)
-      assert answer_object.data["type"] == "Answer"
-      object = Object.get_by_ap_id(object.data["id"])
-
-      assert Enum.any?(
-               object.data["oneOf"],
-               fn
-                 %{"name" => "suya..", "replies" => %{"totalItems" => 1}} -> true
-                 _ -> false
-               end
-             )
-    end
-
     test "it works for incoming notices with contentMap" do
       data =
         File.read!("test/fixtures/mastodon-post-activity-contentmap.json") |> Poison.decode!()
@@ -400,7 +320,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       refute Map.has_key?(object_data, "reaction_count")
     end
 
-    test "it works for incomming unfollows with an existing follow" do
+    test "it works for incoming unfollows with an existing follow" do
       user = insert(:user)
 
       follow_data =
@@ -425,279 +345,6 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       refute User.following?(User.get_cached_by_ap_id(data["actor"]), user)
     end
 
-    test "it works for incoming follows to locked account" do
-      pending_follower = insert(:user, ap_id: "http://mastodon.example.org/users/admin")
-      user = insert(:user, locked: true)
-
-      data =
-        File.read!("test/fixtures/mastodon-follow-activity.json")
-        |> Poison.decode!()
-        |> Map.put("object", user.ap_id)
-
-      {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
-
-      assert data["type"] == "Follow"
-      assert data["object"] == user.ap_id
-      assert data["state"] == "pending"
-      assert data["actor"] == "http://mastodon.example.org/users/admin"
-
-      assert [^pending_follower] = User.get_follow_requests(user)
-    end
-
-    test "it works for incoming accepts which were pre-accepted" do
-      follower = insert(:user)
-      followed = insert(:user)
-
-      {:ok, follower} = User.follow(follower, followed)
-      assert User.following?(follower, followed) == true
-
-      {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
-
-      accept_data =
-        File.read!("test/fixtures/mastodon-accept-activity.json")
-        |> Poison.decode!()
-        |> Map.put("actor", followed.ap_id)
-
-      object =
-        accept_data["object"]
-        |> Map.put("actor", follower.ap_id)
-        |> Map.put("id", follow_activity.data["id"])
-
-      accept_data = Map.put(accept_data, "object", object)
-
-      {:ok, activity} = Transmogrifier.handle_incoming(accept_data)
-      refute activity.local
-
-      assert activity.data["object"] == follow_activity.data["id"]
-
-      assert activity.data["id"] == accept_data["id"]
-
-      follower = User.get_cached_by_id(follower.id)
-
-      assert User.following?(follower, followed) == true
-    end
-
-    test "it works for incoming accepts which were orphaned" do
-      follower = insert(:user)
-      followed = insert(:user, locked: true)
-
-      {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
-
-      accept_data =
-        File.read!("test/fixtures/mastodon-accept-activity.json")
-        |> Poison.decode!()
-        |> Map.put("actor", followed.ap_id)
-
-      accept_data =
-        Map.put(accept_data, "object", Map.put(accept_data["object"], "actor", follower.ap_id))
-
-      {:ok, activity} = Transmogrifier.handle_incoming(accept_data)
-      assert activity.data["object"] == follow_activity.data["id"]
-
-      follower = User.get_cached_by_id(follower.id)
-
-      assert User.following?(follower, followed) == true
-    end
-
-    test "it works for incoming accepts which are referenced by IRI only" do
-      follower = insert(:user)
-      followed = insert(:user, locked: true)
-
-      {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
-
-      accept_data =
-        File.read!("test/fixtures/mastodon-accept-activity.json")
-        |> Poison.decode!()
-        |> Map.put("actor", followed.ap_id)
-        |> Map.put("object", follow_activity.data["id"])
-
-      {:ok, activity} = Transmogrifier.handle_incoming(accept_data)
-      assert activity.data["object"] == follow_activity.data["id"]
-
-      follower = User.get_cached_by_id(follower.id)
-
-      assert User.following?(follower, followed) == true
-
-      follower = User.get_by_id(follower.id)
-      assert follower.following_count == 1
-
-      followed = User.get_by_id(followed.id)
-      assert followed.follower_count == 1
-    end
-
-    test "it fails for incoming accepts which cannot be correlated" do
-      follower = insert(:user)
-      followed = insert(:user, locked: true)
-
-      accept_data =
-        File.read!("test/fixtures/mastodon-accept-activity.json")
-        |> Poison.decode!()
-        |> Map.put("actor", followed.ap_id)
-
-      accept_data =
-        Map.put(accept_data, "object", Map.put(accept_data["object"], "actor", follower.ap_id))
-
-      :error = Transmogrifier.handle_incoming(accept_data)
-
-      follower = User.get_cached_by_id(follower.id)
-
-      refute User.following?(follower, followed) == true
-    end
-
-    test "it fails for incoming rejects which cannot be correlated" do
-      follower = insert(:user)
-      followed = insert(:user, locked: true)
-
-      accept_data =
-        File.read!("test/fixtures/mastodon-reject-activity.json")
-        |> Poison.decode!()
-        |> Map.put("actor", followed.ap_id)
-
-      accept_data =
-        Map.put(accept_data, "object", Map.put(accept_data["object"], "actor", follower.ap_id))
-
-      :error = Transmogrifier.handle_incoming(accept_data)
-
-      follower = User.get_cached_by_id(follower.id)
-
-      refute User.following?(follower, followed) == true
-    end
-
-    test "it works for incoming rejects which are orphaned" do
-      follower = insert(:user)
-      followed = insert(:user, locked: true)
-
-      {:ok, follower} = User.follow(follower, followed)
-      {:ok, _, _, _follow_activity} = CommonAPI.follow(follower, followed)
-
-      assert User.following?(follower, followed) == true
-
-      reject_data =
-        File.read!("test/fixtures/mastodon-reject-activity.json")
-        |> Poison.decode!()
-        |> Map.put("actor", followed.ap_id)
-
-      reject_data =
-        Map.put(reject_data, "object", Map.put(reject_data["object"], "actor", follower.ap_id))
-
-      {:ok, activity} = Transmogrifier.handle_incoming(reject_data)
-      refute activity.local
-      assert activity.data["id"] == reject_data["id"]
-
-      follower = User.get_cached_by_id(follower.id)
-
-      assert User.following?(follower, followed) == false
-    end
-
-    test "it works for incoming rejects which are referenced by IRI only" do
-      follower = insert(:user)
-      followed = insert(:user, locked: true)
-
-      {:ok, follower} = User.follow(follower, followed)
-      {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
-
-      assert User.following?(follower, followed) == true
-
-      reject_data =
-        File.read!("test/fixtures/mastodon-reject-activity.json")
-        |> Poison.decode!()
-        |> Map.put("actor", followed.ap_id)
-        |> Map.put("object", follow_activity.data["id"])
-
-      {:ok, %Activity{data: _}} = Transmogrifier.handle_incoming(reject_data)
-
-      follower = User.get_cached_by_id(follower.id)
-
-      assert User.following?(follower, followed) == false
-    end
-
-    test "it rejects activities without a valid ID" do
-      user = insert(:user)
-
-      data =
-        File.read!("test/fixtures/mastodon-follow-activity.json")
-        |> Poison.decode!()
-        |> Map.put("object", user.ap_id)
-        |> Map.put("id", "")
-
-      :error = Transmogrifier.handle_incoming(data)
-    end
-
-    test "skip converting the content when it is nil" do
-      object_id = "https://peertube.social/videos/watch/278d2b7c-0f38-4aaa-afe6-9ecc0c4a34fe"
-
-      {:ok, object} = Fetcher.fetch_and_contain_remote_object_from_id(object_id)
-
-      result =
-        Pleroma.Web.ActivityPub.Transmogrifier.fix_object(Map.merge(object, %{"content" => nil}))
-
-      assert result["content"] == nil
-    end
-
-    test "it converts content of object to html" do
-      object_id = "https://peertube.social/videos/watch/278d2b7c-0f38-4aaa-afe6-9ecc0c4a34fe"
-
-      {:ok, %{"content" => content_markdown}} =
-        Fetcher.fetch_and_contain_remote_object_from_id(object_id)
-
-      {:ok, %Pleroma.Object{data: %{"content" => content}} = object} =
-        Fetcher.fetch_object_from_id(object_id)
-
-      assert content_markdown ==
-               "Support this and our other Michigan!/usr/group videos and meetings. Learn more at http://mug.org/membership\n\nTwenty Years in Jail: FreeBSD's Jails, Then and Now\n\nJails started as a limited virtualization system, but over the last two years they've..."
-
-      assert content ==
-               "<p>Support this and our other Michigan!/usr/group videos and meetings. Learn more at <a href=\"http://mug.org/membership\">http://mug.org/membership</a></p><p>Twenty Years in Jail: FreeBSD’s Jails, Then and Now</p><p>Jails started as a limited virtualization system, but over the last two years they’ve…</p>"
-
-      assert object.data["mediaType"] == "text/html"
-    end
-
-    test "it remaps video URLs as attachments if necessary" do
-      {:ok, object} =
-        Fetcher.fetch_object_from_id(
-          "https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3"
-        )
-
-      assert object.data["url"] ==
-               "https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3"
-
-      assert object.data["attachment"] == [
-               %{
-                 "type" => "Link",
-                 "mediaType" => "video/mp4",
-                 "url" => [
-                   %{
-                     "href" =>
-                       "https://peertube.moe/static/webseed/df5f464b-be8d-46fb-ad81-2d4c2d1630e3-480.mp4",
-                     "mediaType" => "video/mp4"
-                   }
-                 ]
-               }
-             ]
-
-      {:ok, object} =
-        Fetcher.fetch_object_from_id(
-          "https://framatube.org/videos/watch/6050732a-8a7a-43d4-a6cd-809525a1d206"
-        )
-
-      assert object.data["attachment"] == [
-               %{
-                 "type" => "Link",
-                 "mediaType" => "video/mp4",
-                 "url" => [
-                   %{
-                     "href" =>
-                       "https://framatube.org/static/webseed/6050732a-8a7a-43d4-a6cd-809525a1d206-1080.mp4",
-                     "mediaType" => "video/mp4"
-                   }
-                 ]
-               }
-             ]
-
-      assert object.data["url"] ==
-               "https://framatube.org/videos/watch/6050732a-8a7a-43d4-a6cd-809525a1d206"
-    end
-
     test "it accepts Flag activities" do
       user = insert(:user)
       other_user = insert(:user)
@@ -710,7 +357,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
         "id" => activity.data["id"],
         "content" => "test post",
         "published" => object.data["published"],
-        "actor" => AccountView.render("show.json", %{user: user})
+        "actor" => AccountView.render("show.json", %{user: user, skip_visibility_check: true})
       }
 
       message = %{
@@ -774,6 +421,29 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       assert [user.follower_address] == activity.data["to"]
     end
 
+    test "it correctly processes messages with weirdness in address fields" do
+      user = insert(:user)
+
+      message = %{
+        "@context" => "https://www.w3.org/ns/activitystreams",
+        "to" => [nil, user.follower_address],
+        "cc" => ["https://www.w3.org/ns/activitystreams#Public", ["¿"]],
+        "type" => "Create",
+        "object" => %{
+          "content" => "…",
+          "type" => "Note",
+          "attributedTo" => user.ap_id,
+          "inReplyTo" => nil
+        },
+        "actor" => user.ap_id
+      }
+
+      assert {:ok, activity} = Transmogrifier.handle_incoming(message)
+
+      assert ["https://www.w3.org/ns/activitystreams#Public"] == activity.data["cc"]
+      assert [user.follower_address] == activity.data["to"]
+    end
+
     test "it accepts Move activities" do
       old_user = insert(:user)
       new_user = insert(:user)
@@ -1238,30 +908,6 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
     end
   end
 
-  test "Rewrites Answers to Notes" do
-    user = insert(:user)
-
-    {:ok, poll_activity} =
-      CommonAPI.post(user, %{
-        status: "suya...",
-        poll: %{options: ["suya", "suya.", "suya.."], expires_in: 10}
-      })
-
-    poll_object = Object.normalize(poll_activity)
-    # TODO: Replace with CommonAPI vote creation when implemented
-    data =
-      File.read!("test/fixtures/mastodon-vote.json")
-      |> Poison.decode!()
-      |> Kernel.put_in(["to"], user.ap_id)
-      |> Kernel.put_in(["object", "inReplyTo"], poll_object.data["id"])
-      |> Kernel.put_in(["object", "to"], user.ap_id)
-
-    {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
-    {:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
-
-    assert data["object"]["type"] == "Note"
-  end
-
   describe "fix_explicit_addressing" do
     setup do
       user = insert(:user)
@@ -1339,7 +985,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       assert Transmogrifier.fix_in_reply_to(data) == data
     end
 
-    test "returns object with inReplyToAtomUri when denied incoming reply", %{data: data} do
+    test "returns object with inReplyTo when denied incoming reply", %{data: data} do
       Pleroma.Config.put([:instance, :federation_incoming_replies_max_depth], 0)
 
       object_with_reply =
@@ -1347,26 +993,22 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
 
       modified_object = Transmogrifier.fix_in_reply_to(object_with_reply)
       assert modified_object["inReplyTo"] == "https://shitposter.club/notice/2827873"
-      assert modified_object["inReplyToAtomUri"] == "https://shitposter.club/notice/2827873"
 
       object_with_reply =
         Map.put(data["object"], "inReplyTo", %{"id" => "https://shitposter.club/notice/2827873"})
 
       modified_object = Transmogrifier.fix_in_reply_to(object_with_reply)
       assert modified_object["inReplyTo"] == %{"id" => "https://shitposter.club/notice/2827873"}
-      assert modified_object["inReplyToAtomUri"] == "https://shitposter.club/notice/2827873"
 
       object_with_reply =
         Map.put(data["object"], "inReplyTo", ["https://shitposter.club/notice/2827873"])
 
       modified_object = Transmogrifier.fix_in_reply_to(object_with_reply)
       assert modified_object["inReplyTo"] == ["https://shitposter.club/notice/2827873"]
-      assert modified_object["inReplyToAtomUri"] == "https://shitposter.club/notice/2827873"
 
       object_with_reply = Map.put(data["object"], "inReplyTo", [])
       modified_object = Transmogrifier.fix_in_reply_to(object_with_reply)
       assert modified_object["inReplyTo"] == []
-      assert modified_object["inReplyToAtomUri"] == ""
     end
 
     @tag capture_log: true
@@ -1375,19 +1017,17 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
         Map.put(
           data["object"],
           "inReplyTo",
-          "https://shitposter.club/notice/2827873"
+          "https://mstdn.io/users/mayuutann/statuses/99568293732299394"
         )
 
       Pleroma.Config.put([:instance, :federation_incoming_replies_max_depth], 5)
       modified_object = Transmogrifier.fix_in_reply_to(object_with_reply)
 
       assert modified_object["inReplyTo"] ==
-               "tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
-
-      assert modified_object["inReplyToAtomUri"] == "https://shitposter.club/notice/2827873"
+               "https://mstdn.io/users/mayuutann/statuses/99568293732299394"
 
       assert modified_object["context"] ==
-               "tag:shitposter.club,2017-05-05:objectType=thread:nonce=3c16e9c2681f6d26"
+               "tag:shitposter.club,2018-02-22:objectType=thread:nonce=e5a7c72d60a9c0e4"
     end
   end
 
@@ -1406,75 +1046,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
              }
     end
 
-    test "fixes data for video object" do
-      object = %{
-        "type" => "Video",
-        "url" => [
-          %{
-            "type" => "Link",
-            "mimeType" => "video/mp4",
-            "href" => "https://peede8d-46fb-ad81-2d4c2d1630e3-480.mp4"
-          },
-          %{
-            "type" => "Link",
-            "mimeType" => "video/mp4",
-            "href" => "https://peertube46fb-ad81-2d4c2d1630e3-240.mp4"
-          },
-          %{
-            "type" => "Link",
-            "mimeType" => "text/html",
-            "href" => "https://peertube.-2d4c2d1630e3"
-          },
-          %{
-            "type" => "Link",
-            "mimeType" => "text/html",
-            "href" => "https://peertube.-2d4c2d16377-42"
-          }
-        ]
-      }
-
-      assert Transmogrifier.fix_url(object) == %{
-               "attachment" => [
-                 %{
-                   "href" => "https://peede8d-46fb-ad81-2d4c2d1630e3-480.mp4",
-                   "mimeType" => "video/mp4",
-                   "type" => "Link"
-                 }
-               ],
-               "type" => "Video",
-               "url" => "https://peertube.-2d4c2d1630e3"
-             }
-    end
-
-    test "fixes url for not Video object" do
-      object = %{
-        "type" => "Text",
-        "url" => [
-          %{
-            "type" => "Link",
-            "mimeType" => "text/html",
-            "href" => "https://peertube.-2d4c2d1630e3"
-          },
-          %{
-            "type" => "Link",
-            "mimeType" => "text/html",
-            "href" => "https://peertube.-2d4c2d16377-42"
-          }
-        ]
-      }
-
-      assert Transmogrifier.fix_url(object) == %{
-               "type" => "Text",
-               "url" => "https://peertube.-2d4c2d1630e3"
-             }
-
-      assert Transmogrifier.fix_url(%{"type" => "Text", "url" => []}) == %{
-               "type" => "Text",
-               "url" => ""
-             }
-    end
-
-    test "retunrs not modified object" do
+    test "returns non-modified object" do
       assert Transmogrifier.fix_url(%{"type" => "Text"}) == %{"type" => "Text"}
     end
   end
@@ -1489,7 +1061,9 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
     @tag capture_log: true
     test "returns {:ok, %Object{}} for success case" do
       assert {:ok, %Object{}} =
-               Transmogrifier.get_obj_helper("https://shitposter.club/notice/2827873")
+               Transmogrifier.get_obj_helper(
+                 "https://mstdn.io/users/mayuutann/statuses/99568293732299394"
+               )
     end
   end
 
@@ -1509,8 +1083,13 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
                "attachment" => [
                  %{
                    "mediaType" => "video/mp4",
+                   "type" => "Document",
                    "url" => [
-                     %{"href" => "https://peertube.moe/stat-480.mp4", "mediaType" => "video/mp4"}
+                     %{
+                       "href" => "https://peertube.moe/stat-480.mp4",
+                       "mediaType" => "video/mp4",
+                       "type" => "Link"
+                     }
                    ]
                  }
                ]
@@ -1527,14 +1106,24 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
                "attachment" => [
                  %{
                    "mediaType" => "video/mp4",
+                   "type" => "Document",
                    "url" => [
-                     %{"href" => "https://pe.er/stat-480.mp4", "mediaType" => "video/mp4"}
+                     %{
+                       "href" => "https://pe.er/stat-480.mp4",
+                       "mediaType" => "video/mp4",
+                       "type" => "Link"
+                     }
                    ]
                  },
                  %{
                    "mediaType" => "video/mp4",
+                   "type" => "Document",
                    "url" => [
-                     %{"href" => "https://pe.er/stat-480.mp4", "mediaType" => "video/mp4"}
+                     %{
+                       "href" => "https://pe.er/stat-480.mp4",
+                       "mediaType" => "video/mp4",
+                       "type" => "Link"
+                     }
                    ]
                  }
                ]