1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
7 # alias Pleroma.Web.ActivityPub.Transmogrifier
10 defmodule Pleroma.SpcFixes do
14 where: fragment("? like ?", u.ap_id, "https://shitposter.club/user/%")
17 {:ok, file} = File.read("lib/pleroma/spc_fixes/users_conversion.txt")
23 |> Enum.map(fn line ->
27 |> Enum.reduce(%{}, fn [_id, old_ap_id, new_ap_id], acc ->
28 Map.put(acc, old_ap_id, String.trim(new_ap_id))
31 # First, refetch all the old users.
35 |> Enum.each(fn user ->
36 with ap_id when is_binary(ap_id) <- mapping[user.ap_id] do
37 # This fetches and updates the user.
38 User.get_or_fetch_by_ap_id(ap_id)
42 # Now, fix follow relationships.
45 where: fragment("? like ?", u.ap_id, "https://shitposter.club/users/%")
50 |> Enum.each(fn user ->
51 old_follower_address = User.ap_followers(user)
55 where: ^old_follower_address in u.following,
57 push: [following: ^user.follower_address]
61 Repo.update_all(query, [])