Extract host from ap_id, add index
authoreal <eal@waifu.club>
Wed, 6 Jun 2018 18:13:40 +0000 (21:13 +0300)
committereal <eal@waifu.club>
Wed, 6 Jun 2018 18:13:40 +0000 (21:13 +0300)
lib/pleroma/web/activity_pub/activity_pub.ex
priv/repo/migrations/20180606173637_create_apid_host_extraction_index.exs [new file with mode: 0644]

index 5c61920e532092b79eba071e1d1967b15461434a..a5e42d9d0f52c30e21238ae038e09656f6a26f77 100644 (file)
@@ -445,7 +445,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
       activity in query,
       where: fragment("not (? = ANY(?))", activity.actor, ^blocks),
       where: fragment("not (?->'to' \\?| ?)", activity.data, ^blocks),
-      where: fragment("not (? ~ ANY(?))", activity.actor, ^domain_blocks)
+      where: fragment("not (split_part(?, '/', 3) = ANY(?))", activity.actor, ^domain_blocks)
     )
   end
 
diff --git a/priv/repo/migrations/20180606173637_create_apid_host_extraction_index.exs b/priv/repo/migrations/20180606173637_create_apid_host_extraction_index.exs
new file mode 100644 (file)
index 0000000..9831a1b
--- /dev/null
@@ -0,0 +1,8 @@
+defmodule Pleroma.Repo.Migrations.CreateApidHostExtractionIndex do
+  use Ecto.Migration
+  @disable_ddl_transaction true
+
+  def change do
+    create index(:activities, ["(split_part(actor, '/', 3))"], concurrently: true, name: :activities_hosts)
+  end
+end