From 3f340cbc43948f3ce0e8bca23142be9cd2454960 Mon Sep 17 00:00:00 2001 From: sadposter Date: Wed, 29 Mar 2023 03:31:56 +0100 Subject: [PATCH 1/2] Only even attempt to fetch local activities by object_id TODO: PLEASE FOR THE LOVE OF KANATAN CACHE THIS --- lib/pleroma/activity.ex | 8 ++++++++ lib/pleroma/web/o_status/o_status_controller.ex | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index c5b514742..0a376be04 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -277,6 +277,14 @@ defmodule Pleroma.Activity do def get_create_by_object_ap_id_with_object(_), do: nil + def get_local_create_by_object_ap_id_with_object(ap_id) when is_binary(ap_id) do + ap_id + |> create_by_object_ap_id_with_object() + |> where(local: true) + |> Repo.one() + end + + @spec create_by_id_with_object(String.t()) :: t() | nil def create_by_id_with_object(id) do get_by_id_with_opts(id, preload: [:object], filter: [type: "Create"]) diff --git a/lib/pleroma/web/o_status/o_status_controller.ex b/lib/pleroma/web/o_status/o_status_controller.ex index 7731d847f..79db112df 100644 --- a/lib/pleroma/web/o_status/o_status_controller.ex +++ b/lib/pleroma/web/o_status/o_status_controller.ex @@ -36,7 +36,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do def object(conn, _params) do with id <- Endpoint.url() <> conn.request_path, {_, %Activity{} = activity} <- - {:activity, Activity.get_create_by_object_ap_id_with_object(id)}, + {:activity, Activity.get_local_create_by_object_ap_id_with_object(id)}, {_, true} <- {:public?, Visibility.is_public?(activity)}, {_, false} <- {:local_public?, Visibility.is_local_public?(activity)} do redirect(conn, to: "/notice/#{activity.id}") From 0151ca1d52d383e4fa7a510a810975fbb09ee6f3 Mon Sep 17 00:00:00 2001 From: sadposter Date: Wed, 29 Mar 2023 03:32:30 +0100 Subject: [PATCH 2/2] Revert "Remove indexer plugin" This reverts commit 1d94f2a424e64082854c9ccf1e2086e314e07852. --- config/config.exs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/config.exs b/config/config.exs index ffb62a28f..e216caf9d 100644 --- a/config/config.exs +++ b/config/config.exs @@ -572,7 +572,8 @@ config :pleroma, Oban, database_prune: 1 ], plugins: [ - Oban.Plugins.Pruner + Oban.Plugins.Pruner, + {Oban.Plugins.Reindexer, schedule: "@weekly"} ], crontab: [ {"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker},