format
[akkoma] / lib / pleroma / web / activity_pub / side_effects.ex
index 913b664ca94c22ef99bfec70fc53bfeeda52f4ee..9b17eba953382a2d5d9c215900b4fab8d07240b7 100644 (file)
@@ -199,8 +199,9 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
          %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do
       {:ok, notifications} = Notification.create_notifications(activity, do_send: false)
       {:ok, _user} = ActivityPub.increase_note_count_if_public(user, object)
+      {:ok, _user} = ActivityPub.update_last_status_at_if_public(user, object)
 
-      if in_reply_to = object.data["inReplyTo"] && object.data["type"] != "Answer" do
+      if in_reply_to = object.data["type"] != "Answer" && object.data["inReplyTo"] do
         Object.increase_replies_count(in_reply_to)
       end
 
@@ -537,9 +538,22 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
   end
 
   @impl true
-  @impl true
-  def handle_after_transaction(%{data: %{"type" => "Create"}} = activity) do
-    Elasticsearch.put_by_id(activity.id)
+  def handle_after_transaction(%Pleroma.Activity{data: %{"type" => "Create"}} = activity) do
+    Pleroma.Elasticsearch.put_by_id(:activity, activity.id)
+  end
+
+  def handle_after_transaction(%Pleroma.Activity{
+        data: %{"type" => "Delete", "deleted_activity_id" => id}
+      }) do
+    Pleroma.Elasticsearch.delete_by_id(:activity, id)
+  end
+
+  def handle_after_transaction(%Pleroma.Activity{}) do
+    :ok
+  end
+
+  def handle_after_transaction(%Pleroma.Object{}) do
+    :ok
   end
 
   def handle_after_transaction(meta) do
@@ -547,6 +561,4 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
     |> send_notifications()
     |> send_streamables()
   end
-
-  def handle_after_transaction(_), do: :ok
 end