diff options
author | rinpatch <rinpatch@sdf.org> | 2019-10-29 11:24:07 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-10-29 11:24:07 +0000 |
commit | 07c7f16356d5fe0ce15554a5981c4adee7294f13 (patch) | |
tree | 84cdfe178614a4ab331642d70067c7b64f2089d6 /priv | |
parent | e80f90e9dbdb6955e355d6a06eb69ee7051ba6df (diff) | |
parent | 5334190056b853dda57f16cbbaa230e8947821c6 (diff) | |
download | pleroma-07c7f16356d5fe0ce15554a5981c4adee7294f13.tar.gz |
Merge branch 'fix-follow-requests' into 'develop'
FIx follow requests
Closes #1357
See merge request pleroma/pleroma!1918
Diffstat (limited to 'priv')
-rw-r--r-- | priv/repo/migrations/20191029101340_migrate_missing_follow_requests.exs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/priv/repo/migrations/20191029101340_migrate_missing_follow_requests.exs b/priv/repo/migrations/20191029101340_migrate_missing_follow_requests.exs new file mode 100644 index 000000000..1b2666f3a --- /dev/null +++ b/priv/repo/migrations/20191029101340_migrate_missing_follow_requests.exs @@ -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 |