Remote Timeline: add Streaming support
[akkoma] / test / web / activity_pub / transmogrifier / audio_handling_test.exs
index c74a9c45d32dbeb7d4709df42d9fca7d417aaeec..0636d00c5bd5b9cf646dee332df67388459cc286 100644 (file)
@@ -42,4 +42,42 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AudioHandlingTest do
     assert object.data["album"] == "lain radio"
     assert object.data["length"] == 180_000
   end
+
+  test "Funkwhale Audio object" do
+    Tesla.Mock.mock(fn
+      %{url: "https://channels.tests.funkwhale.audio/federation/actors/compositions"} ->
+        %Tesla.Env{
+          status: 200,
+          body: File.read!("test/fixtures/tesla_mock/funkwhale_channel.json")
+        }
+    end)
+
+    data = File.read!("test/fixtures/tesla_mock/funkwhale_create_audio.json") |> Poison.decode!()
+
+    {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
+
+    assert object = Object.normalize(activity, false)
+
+    assert object.data["to"] == ["https://www.w3.org/ns/activitystreams#Public"]
+
+    assert object.data["cc"] == []
+
+    assert object.data["url"] == "https://channels.tests.funkwhale.audio/library/tracks/74"
+
+    assert object.data["attachment"] == [
+             %{
+               "mediaType" => "audio/ogg",
+               "type" => "Link",
+               "name" => nil,
+               "url" => [
+                 %{
+                   "href" =>
+                     "https://channels.tests.funkwhale.audio/api/v1/listen/3901e5d8-0445-49d5-9711-e096cf32e515/?upload=42342395-0208-4fee-a38d-259a6dae0871&download=false",
+                   "mediaType" => "audio/ogg",
+                   "type" => "Link"
+                 }
+               ]
+             }
+           ]
+  end
 end