Skip to content

Audio object support

I have a software who will federate Audio Objects and I would like Pleroma to support them.

As seen with @lanodan I have made this quick and dirty hack just to validate federation.

Currently pleroma-fe shows only a link to the mp3/url, mastofe shows a link to the activity url, I haven't investigated further.

I will create respective issue for pleroma-fe to add an audio player if wanted.

diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex
index f733ae7e..d8296f7b 100644
--- a/lib/pleroma/web/activity_pub/transmogrifier.ex
+++ b/lib/pleroma/web/activity_pub/transmogrifier.ex
@@ -432,7 +432,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
   # - tags
   # - emoji
   def handle_incoming(%{"type" => "Create", "object" => %{"type" => objtype} = object} = data)
-      when objtype in ["Article", "Note", "Video", "Page"] do
+      when objtype in ["Article", "Note", "Video", "Page", "Audio"] do
     actor = get_actor(data)
 
     data =
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex
index 1ca8338c..8c64832f 100644
--- a/lib/pleroma/web/mastodon_api/views/status_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/status_view.ex
@@ -316,6 +316,14 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
     end
   end
 
+  def render_content(%{"type" => "Audio"} = object) do
+    with name when not is_nil(name) and name != "" <- object["name"] do
+      "<p><a href=\"#{object["id"]}\">#{name}</a></p>#{object["content"]}"
+    else
+      _ -> object["content"] || ""
+    end
+  end
+
   def render_content(%{"type" => object_type} = object)
       when object_type in ["Article", "Page"] do
     with summary when not is_nil(summary) and summary != "" <- object["name"],
diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex
index aa1d41fa..09f35212 100644
--- a/lib/pleroma/web/twitter_api/views/activity_view.ex
+++ b/lib/pleroma/web/twitter_api/views/activity_view.ex
@@ -335,7 +335,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
   end
 
   def render_content(%{"type" => object_type} = object)
-      when object_type in ["Article", "Page", "Video"] do
+      when object_type in ["Article", "Page", "Video", "Audio"] do
     summary = object["name"] || object["summary"]
 
     content =