From 29c9c8d93b263e57915158d09761bc6586826798 Mon Sep 17 00:00:00 2001 From: eal Date: Wed, 6 Jun 2018 21:13:40 +0300 Subject: [PATCH] Extract host from ap_id, add index --- lib/pleroma/web/activity_pub/activity_pub.ex | 2 +- .../20180606173637_create_apid_host_extraction_index.exs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 priv/repo/migrations/20180606173637_create_apid_host_extraction_index.exs diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 5c61920e5..a5e42d9d0 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -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 index 000000000..9831a1b82 --- /dev/null +++ b/priv/repo/migrations/20180606173637_create_apid_host_extraction_index.exs @@ -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