Merge branch 'feature/list-streaming' into 'develop'
[akkoma] / lib / pleroma / web / common_api / common_api.ex
index 21225c3b7d8a95b908b2820a795433dec25fdf0a..8845419c2461081e7c2a04b2f34eef99ecdc604d 100644 (file)
@@ -1,5 +1,5 @@
 defmodule Pleroma.Web.CommonAPI do
-  alias Pleroma.{Repo, Activity, Object, User}
+  alias Pleroma.{Repo, Activity, Object}
   alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Formatter
 
@@ -24,6 +24,16 @@ defmodule Pleroma.Web.CommonAPI do
     end
   end
 
+  def unrepeat(id_or_ap_id, user) do
+    with %Activity{} = activity <- get_by_id_or_ap_id(id_or_ap_id),
+         object <- Object.get_by_ap_id(activity.data["object"]["id"]) do
+      ActivityPub.unannounce(user, object)
+    else
+      _ ->
+        {:error, "Could not unrepeat"}
+    end
+  end
+
   def favorite(id_or_ap_id, user) do
     with %Activity{} = activity <- get_by_id_or_ap_id(id_or_ap_id),
          false <- activity.data["actor"] == user.ap_id,
@@ -103,7 +113,6 @@ defmodule Pleroma.Web.CommonAPI do
           additional: %{"cc" => cc}
         })
 
-      User.increase_note_count(user)
       res
     end
   end