Return "audio" info in mastodon api.
[akkoma] / lib / pleroma / web / activity_pub / utils.ex
index 919cd0bd5141bbda3ffdb8c0b6e7a6efe3803695..a25b27aabde0b3035c57693aaeadf4ca1962bcf3 100644 (file)
@@ -5,6 +5,26 @@ defmodule Pleroma.Web.ActivityPub.Utils do
   alias Ecto.{Changeset, UUID}
   import Ecto.Query
 
+  def make_json_ld_header do
+    %{
+      "@context" => [
+        "https://www.w3.org/ns/activitystreams",
+        "https://w3id.org/security/v1",
+        %{
+          "manuallyApprovesFollowers" => "as:manuallyApprovesFollowers",
+          "sensitive" => "as:sensitive",
+          "Hashtag" => "as:Hashtag",
+          "ostatus" => "http://ostatus.org#",
+          "atomUri" => "ostatus:atomUri",
+          "inReplyToAtomUri" => "ostatus:inReplyToAtomUri",
+          "conversation" => "ostatus:conversation",
+          "toot" => "http://joinmastodon.org/ns#",
+          "Emoji" => "toot:Emoji"
+        }
+      ]
+    }
+  end
+
   def make_date do
     DateTime.utc_now() |> DateTime.to_iso8601
   end
@@ -68,7 +88,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do
   @doc """
   Inserts a full object if it is contained in an activity.
   """
-  def insert_full_object(%{"object" => object_data}) when is_map(object_data) do
+  def insert_full_object(%{"object" => %{"type" => type} = object_data}) when is_map(object_data) and type in ["Note"] do
     with {:ok, _} <- Object.create(object_data) do
       :ok
     end