Ensure deletes are handled after everything else
authorFloatingGhost <hannah@coffee-and-dreams.uk>
Tue, 11 Oct 2022 13:30:08 +0000 (14:30 +0100)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Tue, 11 Oct 2022 13:30:08 +0000 (14:30 +0100)
CHANGELOG.md
config/config.exs
lib/mix/tasks/pleroma/user.ex
lib/pleroma/web/activity_pub/side_effects.ex
lib/pleroma/web/federator.ex
lib/pleroma/web/mastodon_api/mastodon_api.ex

index 8a675a32eafd70eaf2bb58b484e508aaaad7d02a..cbe09d5984c086b9a8a4abe02efe07e475e5ea70 100644 (file)
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 
 ## Changes
 - Follows no longer override domain blocks, a domain block is final
+- Deletes are now the lowest priority to publish and will be handled after creates
 
 ## 2022.10
 
index d7005770eda673edcce61d6bf48326e8285a7503..5eb82cd3305537c9bd76a103baf756f8d4a2447e 100644 (file)
@@ -569,7 +569,10 @@ config :pleroma, Oban,
     mute_expire: 5,
     search_indexing: 10
   ],
-  plugins: [Oban.Plugins.Pruner],
+  plugins: [
+    Oban.Plugins.Pruner,
+    {Oban.Plugins.Reindexer, schedule: "@weekly"}
+  ],
   crontab: [
     {"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker},
     {"0 0 * * *", Pleroma.Workers.Cron.NewUsersDigestWorker}
index f420d68bbe2acc3bc11cc9df4af586b83cf7f2ea..50c3fd7ce5e9d9288e3a1e32731ada86f6446979 100644 (file)
@@ -538,6 +538,12 @@ defmodule Mix.Tasks.Pleroma.User do
     end
   end
 
+  def run(["convert_id", id]) do
+    {:ok, uuid} = FlakeId.Ecto.Type.dump(id)
+    {:ok, raw_id} = Ecto.UUID.load(uuid)
+    shell_info(raw_id)
+  end
+
   defp refetch_public_keys(query) do
     query
     |> Pleroma.Repo.chunk_stream(50, :batches)
index 43b1b089b6e938496e325973f3d7a11133f6c391..c3258c75ba7be9db7e9a53ffefdf108342b75857 100644 (file)
@@ -323,8 +323,6 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
       end
 
     if result == :ok do
-      Notification.create_notifications(object)
-
       # Only remove from index when deleting actual objects, not users or anything else
       with %Pleroma.Object{} <- deleted_object do
         Pleroma.Search.remove_from_index(deleted_object)
index bc61130f1ef7aa322ddc7dca8a02af2493ec442b..770044de26bbe38566053df5dd99886c3c28bd9b 100644 (file)
@@ -53,12 +53,19 @@ defmodule Pleroma.Web.Federator do
 
   @impl true
   def publish(%{data: %{"object" => object}} = activity) when is_map(object) or is_list(object) do
-    PublisherWorker.enqueue("publish", %{
-      "activity_id" => activity.id,
-      "object_data" => Jason.encode!(object)
-    })
+    PublisherWorker.enqueue(
+      "publish",
+      %{
+        "activity_id" => activity.id,
+        "object_data" => Jason.encode!(object)
+      },
+      priority: publish_priority(activity)
+    )
   end
 
+  defp publish_priority(%{type: "Delete"}), do: 3
+  defp publish_priority(_), do: 0
+
   # Job Worker Callbacks
 
   @spec perform(atom(), module(), any()) :: {:ok, any()} | {:error, any()}
index 69bc2f0d6e49227b461a3f7f39ad92beee9eba97..23846b36a0a3101784b2e27358b5de14407c26c3 100644 (file)
@@ -63,16 +63,11 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do
   def get_notifications(user, params \\ %{}) do
     options = cast_params(params)
 
-    query =
-      user
-      |> Notification.for_user_query(options)
-      |> restrict(:include_types, options)
-      |> restrict(:exclude_types, options)
-      |> restrict(:account_ap_id, options)
-
-    IO.inspect(Pleroma.Repo.to_sql(:all, query))
-
-    query
+    user
+    |> Notification.for_user_query(options)
+    |> restrict(:include_types, options)
+    |> restrict(:exclude_types, options)
+    |> restrict(:account_ap_id, options)
     |> Pagination.fetch_paginated(params)
   end