Add unrepeat functionality
[akkoma] / lib / pleroma / web / activity_pub / activity_pub.ex
index 04b50c1cc0fc32870dad268d569648c6e8d60263..b3154ea99b5ad65edc57e710b09fcd9963883019 100644 (file)
@@ -140,6 +140,16 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     end
   end
 
+  def unannounce(%User{} = actor, %Object{} = object) do
+    with %Activity{} = activity <- get_existing_announce(actor.ap_id, object),
+         {:ok, _activity} <- Repo.delete(activity),
+         {:ok, object} <- remove_announce_from_object(activity, object) do
+      {:ok, object}
+    else
+      _e -> {:ok, object}
+    end
+  end
+
   def follow(follower, followed, activity_id \\ nil, local \\ true) do
     with data <- make_follow_data(follower, followed, activity_id),
          {:ok, activity} <- insert(data, local),