1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.Transmogrifier.AudioHandlingTest do
6 use Oban.Testing, repo: Pleroma.Repo
11 alias Pleroma.Web.ActivityPub.Transmogrifier
13 import Pleroma.Factory
15 test "it works for incoming listens" do
16 _user = insert(:user, ap_id: "http://mastodon.example.org/users/admin")
19 "@context" => "https://www.w3.org/ns/activitystreams",
20 "to" => ["https://www.w3.org/ns/activitystreams#Public"],
23 "id" => "http://mastodon.example.org/users/admin/listens/1234/activity",
24 "actor" => "http://mastodon.example.org/users/admin",
27 "id" => "http://mastodon.example.org/users/admin/listens/1234",
28 "attributedTo" => "http://mastodon.example.org/users/admin",
29 "title" => "lain radio episode 1",
31 "album" => "lain radio",
36 {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
38 object = Object.normalize(activity, fetch: false)
40 assert object.data["title"] == "lain radio episode 1"
41 assert object.data["artist"] == "lain"
42 assert object.data["album"] == "lain radio"
43 assert object.data["length"] == 180_000
46 test "Funkwhale Audio object" do
48 %{url: "https://channels.tests.funkwhale.audio/federation/actors/compositions"} ->
51 body: File.read!("test/fixtures/tesla_mock/funkwhale_channel.json"),
52 headers: HttpRequestMock.activitypub_object_headers()
56 data = File.read!("test/fixtures/tesla_mock/funkwhale_create_audio.json") |> Jason.decode!()
58 {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
60 assert object = Object.normalize(activity, fetch: false)
62 assert object.data["to"] == ["https://www.w3.org/ns/activitystreams#Public"]
64 assert object.data["cc"] == []
66 assert object.data["url"] == "https://channels.tests.funkwhale.audio/library/tracks/74"
68 assert object.data["attachment"] == [
70 "mediaType" => "audio/ogg",
77 "https://channels.tests.funkwhale.audio/api/v1/listen/3901e5d8-0445-49d5-9711-e096cf32e515/?upload=42342395-0208-4fee-a38d-259a6dae0871&download=false",
78 "mediaType" => "audio/ogg",