Fix merge conflicts with upstream

This commit is contained in:
Sean King 2021-06-04 14:42:44 -06:00
commit dc4814f0cd
No known key found for this signature in database
GPG key ID: 510C52BACD6E7257
240 changed files with 4616 additions and 1584 deletions

View file

@ -0,0 +1,77 @@
defmodule Pleroma.Repo.Migrations.RenameInstanceChat do
use Ecto.Migration
alias Pleroma.ConfigDB
@instance_params %{group: :pleroma, key: :instance}
@shout_params %{group: :pleroma, key: :shout}
@chat_params %{group: :pleroma, key: :chat}
def up do
instance_updated? = maybe_update_instance_key(:up) != :noop
chat_updated? = maybe_update_chat_key(:up) != :noop
case Enum.any?([instance_updated?, chat_updated?]) do
true -> :ok
false -> :noop
end
end
def down do
instance_updated? = maybe_update_instance_key(:down) != :noop
chat_updated? = maybe_update_chat_key(:down) != :noop
case Enum.any?([instance_updated?, chat_updated?]) do
true -> :ok
false -> :noop
end
end
# pleroma.instance.chat_limit -> pleroma.shout.limit
defp maybe_update_instance_key(:up) do
with %ConfigDB{value: values} <- ConfigDB.get_by_params(@instance_params),
limit when is_integer(limit) <- values[:chat_limit] do
@shout_params |> Map.put(:value, limit: limit) |> ConfigDB.update_or_create()
@instance_params |> Map.put(:subkeys, [":chat_limit"]) |> ConfigDB.delete()
else
_ ->
:noop
end
end
# pleroma.shout.limit -> pleroma.instance.chat_limit
defp maybe_update_instance_key(:down) do
with %ConfigDB{value: values} <- ConfigDB.get_by_params(@shout_params),
limit when is_integer(limit) <- values[:limit] do
@instance_params |> Map.put(:value, chat_limit: limit) |> ConfigDB.update_or_create()
@shout_params |> Map.put(:subkeys, [":limit"]) |> ConfigDB.delete()
else
_ ->
:noop
end
end
# pleroma.chat.enabled -> pleroma.shout.enabled
defp maybe_update_chat_key(:up) do
with %ConfigDB{value: values} <- ConfigDB.get_by_params(@chat_params),
enabled? when is_boolean(enabled?) <- values[:enabled] do
@shout_params |> Map.put(:value, enabled: enabled?) |> ConfigDB.update_or_create()
@chat_params |> Map.put(:subkeys, [":enabled"]) |> ConfigDB.delete()
else
_ ->
:noop
end
end
# pleroma.shout.enabled -> pleroma.chat.enabled
defp maybe_update_chat_key(:down) do
with %ConfigDB{value: values} <- ConfigDB.get_by_params(@shout_params),
enabled? when is_boolean(enabled?) <- values[:enabled] do
@chat_params |> Map.put(:value, enabled: enabled?) |> ConfigDB.update_or_create()
@shout_params |> Map.put(:subkeys, [":enabled"]) |> ConfigDB.delete()
else
_ ->
:noop
end
end
end

View file

@ -0,0 +1,9 @@
defmodule Pleroma.Repo.Migrations.AddPinnedObjectsToUsers do
use Ecto.Migration
def change do
alter table(:users) do
add(:pinned_objects, :map)
end
end
end

View file

@ -0,0 +1,23 @@
defmodule Pleroma.Repo.Migrations.AddFeaturedAddressToUsers do
use Ecto.Migration
def up do
alter table(:users) do
add(:featured_address, :string)
end
create(index(:users, [:featured_address]))
execute("""
update users set featured_address = concat(ap_id, '/collections/featured') where local = true and featured_address is null;
""")
end
def down do
alter table(:users) do
remove(:featured_address)
end
end
end

View file

@ -0,0 +1,28 @@
defmodule Pleroma.Repo.Migrations.MovePinnedActivitiesIntoPinnedObjects do
use Ecto.Migration
import Ecto.Query
alias Pleroma.Repo
alias Pleroma.User
def up do
from(u in User)
|> select([u], {u.id, fragment("?.pinned_activities", u)})
|> Repo.stream()
|> Stream.each(fn {user_id, pinned_activities_ids} ->
pinned_activities = Pleroma.Activity.all_by_ids_with_object(pinned_activities_ids)
pins =
Map.new(pinned_activities, fn %{object: %{data: %{"id" => object_id}}} ->
{object_id, NaiveDateTime.utc_now()}
end)
from(u in User, where: u.id == ^user_id)
|> Repo.update_all(set: [pinned_objects: pins])
end)
|> Stream.run()
end
def down, do: :noop
end

View file

@ -0,0 +1,15 @@
defmodule Pleroma.Repo.Migrations.RemovePinnedActivitiesFromUsers do
use Ecto.Migration
def up do
alter table(:users) do
remove(:pinned_activities)
end
end
def down do
alter table(:users) do
add(:pinned_activities, {:array, :string}, default: [])
end
end
end