Merge remote-tracking branch 'upstream/develop' into restrict-origin
[akkoma] / lib / pleroma / web / activity_pub / activity_pub.ex
index eb44cffec14eddb5634a3973a1f6625fbcd14acb..42064b51f30df8cc1b50569c3d45746df7634b62 100644 (file)
@@ -930,16 +930,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
 
   defp restrict_muted_reblogs(query, _), do: query
 
-  defp restrict_instance(query, %{instance: instance}) do
-    users =
-      from(
-        u in User,
-        select: u.ap_id,
-        where: fragment("? LIKE ?", u.nickname, ^"%@#{instance}")
-      )
-      |> Repo.all()
-
-    from(activity in query, where: activity.actor in ^users)
+  defp restrict_instance(query, %{instance: instance}) when is_binary(instance) do
+    from(
+      activity in query,
+      where: fragment("split_part(actor::text, '/'::text, 3) = ?", ^instance)
+    )
   end
 
   defp restrict_instance(query, _), do: query