forked from AkkomaGang/akkoma
Migrate missing follow requests
This commit is contained in:
parent
c2f2d7bcf6
commit
5334190056
1 changed files with 35 additions and 0 deletions
|
@ -0,0 +1,35 @@
|
||||||
|
defmodule Pleroma.Repo.Migrations.MigrateFollowingRelationships do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
execute(import_pending_follows_from_activities(), "")
|
||||||
|
end
|
||||||
|
|
||||||
|
defp import_pending_follows_from_activities do
|
||||||
|
"""
|
||||||
|
INSERT INTO
|
||||||
|
following_relationships (
|
||||||
|
follower_id,
|
||||||
|
following_id,
|
||||||
|
state,
|
||||||
|
inserted_at,
|
||||||
|
updated_at
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
followers.id,
|
||||||
|
following.id,
|
||||||
|
activities.data ->> 'state',
|
||||||
|
(activities.data ->> 'published') :: timestamp,
|
||||||
|
now()
|
||||||
|
FROM
|
||||||
|
activities
|
||||||
|
JOIN users AS followers ON (activities.actor = followers.ap_id)
|
||||||
|
JOIN users AS following ON (activities.data ->> 'object' = following.ap_id)
|
||||||
|
WHERE
|
||||||
|
activities.data ->> 'type' = 'Follow'
|
||||||
|
AND activities.data ->> 'state' = 'pending'
|
||||||
|
ORDER BY activities.updated_at DESC
|
||||||
|
ON CONFLICT DO NOTHING
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue