Merge branch 'feature/add-roles-to-users-admin-api' into 'develop'
[akkoma] / lib / pleroma / activity.ex
index 66854dc2dd2920208261f4da1849420bd60c874a..18d5b70deb2425aeb40c384948dc0dfc4d526ad7 100644 (file)
@@ -107,6 +107,18 @@ defmodule Pleroma.Activity do
 
   def get_in_reply_to_activity(_), do: nil
 
+  def delete_by_ap_id(id) when is_binary(id) do
+    by_object_ap_id(id)
+    |> Repo.delete_all(returning: true)
+    |> elem(1)
+    |> Enum.find(fn
+      %{data: %{"type" => "Create", "object" => %{"id" => ap_id}}} -> ap_id == id
+      _ -> nil
+    end)
+  end
+
+  def delete_by_ap_id(_), do: nil
+
   for {ap_type, type} <- @mastodon_notification_types do
     def mastodon_notification_type(%Activity{data: %{"type" => unquote(ap_type)}}),
       do: unquote(type)