Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

26 lines
627B

  1. defmodule Pleroma.Repo.Migrations.PopulateUserRawBio do
  2. use Ecto.Migration
  3. import Ecto.Query
  4. alias Pleroma.User
  5. alias Pleroma.Repo
  6. def change do
  7. {:ok, _} = Application.ensure_all_started(:fast_sanitize)
  8. User.Query.build(%{local: true})
  9. |> select([u], struct(u, [:id, :ap_id, :bio]))
  10. |> Repo.stream()
  11. |> Enum.each(fn %{bio: bio} = user ->
  12. if bio do
  13. raw_bio =
  14. bio
  15. |> String.replace(~r(<br */?>), "\n")
  16. |> Pleroma.HTML.strip_tags()
  17. Ecto.Changeset.cast(user, %{raw_bio: raw_bio}, [:raw_bio])
  18. |> Repo.update()
  19. end
  20. end)
  21. end
  22. end