diff options
author | Alex Gleason <alex@alexgleason.me> | 2021-12-30 17:48:05 -0600 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2021-12-30 17:58:02 -0600 |
commit | 15e6b4089959238eb497137c4eb18f0fc0983082 (patch) | |
tree | 3937c0ec6c5e06cb888f16a2098b0fb2146781b4 | |
parent | 5d89a0ff83aab5cd439a94cff5921c2b42065e2d (diff) | |
download | pleroma-15e6b4089959238eb497137c4eb18f0fc0983082.tar.gz |
CombineActivitiesAndObjects: deal with AP ID conflicts differently
-rw-r--r-- | priv/repo/migrations/20211218181647_combine_activities_and_objects.exs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/priv/repo/migrations/20211218181647_combine_activities_and_objects.exs b/priv/repo/migrations/20211218181647_combine_activities_and_objects.exs index 478ee5a57..153ac9718 100644 --- a/priv/repo/migrations/20211218181647_combine_activities_and_objects.exs +++ b/priv/repo/migrations/20211218181647_combine_activities_and_objects.exs @@ -5,12 +5,14 @@ defmodule Pleroma.Repo.Migrations.CombineActivitiesAndObjects do @trigger_name "status_visibility_counter_cache_trigger" def up do + # Add missing fields to objects table alter table(:objects) do add(:local, :boolean) add(:actor, :string) add(:recipients, {:array, :string}) end + # Add missing indexes to objects create_if_not_exists(index(:objects, [:local])) create_if_not_exists(index(:objects, [:actor, "id DESC NULLS LAST"])) create_if_not_exists(index(:objects, [:recipients], using: :gin)) @@ -23,8 +25,15 @@ defmodule Pleroma.Repo.Migrations.CombineActivitiesAndObjects do index(:objects, ["(data->'cc')"], name: :activities_cc_index, using: :gin) ) + # Some obscure Fediverse backends (WordPress, Juick) send a Create and a Note + # with the exact same ActivityPub ID. This violates the spec and doesn't + # work in the new system. WordPress devs were notified. + execute( + "DELETE FROM activities USING objects WHERE activities.data->>'id' = objects.data->>'id'" + ) + # Copy all activities into the newly formatted objects table - execute("INSERT INTO objects (SELECT * FROM activities) ON CONFLICT DO NOTHING") + execute("INSERT INTO objects (SELECT * FROM activities)") # Update notifications foreign key execute("alter table notifications drop constraint notifications_activity_id_fkey") |