ObjectValidator.stringify_keys: filter out nil values
[akkoma] / test / pleroma / web / activity_pub / transmogrifier / video_handling_test.exs
index c00df6a04ff1fe2188e415165f3ef153555f5307..fc3ec7450f880c750259cc7972a15ee07441e250 100644 (file)
@@ -53,8 +53,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.VideoHandlingTest do
              %{
                "type" => "Link",
                "mediaType" => "video/mp4",
-               "name" => nil,
-               "blurhash" => nil,
                "url" => [
                  %{
                    "href" =>
@@ -76,8 +74,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.VideoHandlingTest do
              %{
                "type" => "Link",
                "mediaType" => "video/mp4",
-               "name" => nil,
-               "blurhash" => nil,
                "url" => [
                  %{
                    "href" =>
@@ -92,4 +88,32 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.VideoHandlingTest do
     assert object.data["url"] ==
              "https://framatube.org/videos/watch/6050732a-8a7a-43d4-a6cd-809525a1d206"
   end
+
+  test "it works for peertube videos with only their mpegURL map" do
+    data =
+      File.read!("test/fixtures/peertube/video-object-mpegURL-only.json")
+      |> Jason.decode!()
+
+    {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
+
+    assert object = Object.normalize(activity, fetch: false)
+
+    assert object.data["attachment"] == [
+             %{
+               "type" => "Link",
+               "mediaType" => "video/mp4",
+               "url" => [
+                 %{
+                   "href" =>
+                     "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/abece3c3-b9c6-47f4-8040-f3eed8c602e6-1080-fragmented.mp4",
+                   "mediaType" => "video/mp4",
+                   "type" => "Link"
+                 }
+               ]
+             }
+           ]
+
+    assert object.data["url"] ==
+             "https://peertube.stream/videos/watch/abece3c3-b9c6-47f4-8040-f3eed8c602e6"
+  end
 end