1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
9 defmodule Pleroma.SpcFixes do
13 where: fragment("? like ?", u.ap_id, "https://shitposter.club/user/%")
16 {:ok, file} = File.read("lib/pleroma/spc_fixes/users_conversion.txt")
22 |> Enum.map(fn line ->
26 |> Enum.reduce(%{}, fn [_id, old_ap_id, new_ap_id], acc ->
27 Map.put(acc, old_ap_id, String.trim(new_ap_id))
30 # First, refetch all the old users.
34 |> Enum.each(fn user ->
35 with ap_id when is_binary(ap_id) <- mapping[user.ap_id] do
36 # This fetches and updates the user.
37 User.get_or_fetch_by_ap_id(ap_id)
41 # Now, fix follow relationships.
44 where: fragment("? like ?", u.ap_id, "https://shitposter.club/users/%")
49 |> Enum.each(fn user ->
50 old_follower_address = User.ap_followers(user)
54 where: ^old_follower_address in u.following,
56 push: [following: ^user.follower_address]
60 Repo.update_all(query, [])