Only even attempt to fetch local activities by object_id
authorsadposter <hannah+pleroma@coffee-and-dreams.uk>
Wed, 29 Mar 2023 02:31:56 +0000 (03:31 +0100)
committersadposter <hannah+pleroma@coffee-and-dreams.uk>
Wed, 29 Mar 2023 02:32:24 +0000 (03:32 +0100)
TODO: PLEASE FOR THE LOVE OF KANATAN CACHE THIS

lib/pleroma/activity.ex
lib/pleroma/web/o_status/o_status_controller.ex

index c5b51474269fb7afd76494cdf003c512db472752..0a376be04a6a34f32a743c675065e54193d41dd8 100644 (file)
@@ -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"])
index 7731d847f6e0a3f9570266d574dd69e57debcfa9..79db112dfda8bea60d03a651cb4ec515886f1b59 100644 (file)
@@ -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}")