1 # Fix legacy tags set by AdminFE that don't align with TagPolicy MRF
3 defmodule Pleroma.Repo.Migrations.FixLegacyTags do
10 "force_nsfw" => "mrf_tag:media-force-nsfw",
11 "strip_media" => "mrf_tag:media-strip",
12 "force_unlisted" => "mrf_tag:force-unlisted",
13 "sandbox" => "mrf_tag:sandbox",
14 "disable_remote_subscription" => "mrf_tag:disable-remote-subscription",
15 "disable_any_subscription" => "mrf_tag:disable-any-subscription"
19 legacy_tags = Map.keys(@old_new_map)
22 where: fragment("? && ?", u.tags, ^legacy_tags),
23 select: struct(u, [:tags, :id])
25 |> Repo.chunk_stream(100)
26 |> Enum.each(fn user ->
27 fix_tags_changeset(user)
32 defp fix_tags_changeset(%User{tags: tags} = user) do
34 Enum.map(tags, fn tag ->
35 Map.get(@old_new_map, tag, tag)
38 Ecto.Changeset.change(user, tags: new_tags)