Merge branch 'develop' into feature/bulk-confirmation
This commit is contained in:
commit
f3a1f9c3bb
274 changed files with 8654 additions and 9573 deletions
|
|
@ -32,7 +32,8 @@ defmodule Mix.Tasks.Pleroma.Config do
|
|||
|
||||
@spec migrate_to_db(Path.t() | nil) :: any()
|
||||
def migrate_to_db(file_path \\ nil) do
|
||||
if Pleroma.Config.get([:configurable_from_database]) do
|
||||
with true <- Pleroma.Config.get([:configurable_from_database]),
|
||||
:ok <- Pleroma.Config.DeprecationWarnings.warn() do
|
||||
config_file =
|
||||
if file_path do
|
||||
file_path
|
||||
|
|
@ -46,7 +47,8 @@ defmodule Mix.Tasks.Pleroma.Config do
|
|||
|
||||
do_migrate_to_db(config_file)
|
||||
else
|
||||
migration_error()
|
||||
:error -> deprecation_error()
|
||||
_ -> migration_error()
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -120,6 +122,10 @@ defmodule Mix.Tasks.Pleroma.Config do
|
|||
)
|
||||
end
|
||||
|
||||
defp deprecation_error do
|
||||
shell_error("Migration is not allowed until all deprecation warnings have been resolved.")
|
||||
end
|
||||
|
||||
if Code.ensure_loaded?(Config.Reader) do
|
||||
defp config_header, do: "import Config\r\n\r\n"
|
||||
defp read_file(config_file), do: Config.Reader.read_imports!(config_file)
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ defmodule Mix.Tasks.Pleroma.Database do
|
|||
where: fragment("(?)->>'likes' is not null", object.data),
|
||||
select: %{id: object.id, likes: fragment("(?)->>'likes'", object.data)}
|
||||
)
|
||||
|> Pleroma.RepoStreamer.chunk_stream(100)
|
||||
|> Pleroma.Repo.chunk_stream(100, :batches)
|
||||
|> Stream.each(fn objects ->
|
||||
ids =
|
||||
objects
|
||||
|
|
@ -133,8 +133,7 @@ defmodule Mix.Tasks.Pleroma.Database do
|
|||
days = Pleroma.Config.get([:mrf_activity_expiration, :days], 365)
|
||||
|
||||
Pleroma.Activity
|
||||
|> join(:left, [a], u in assoc(a, :expiration))
|
||||
|> join(:inner, [a, _u], o in Object,
|
||||
|> join(:inner, [a], o in Object,
|
||||
on:
|
||||
fragment(
|
||||
"(?->>'id') = COALESCE((?)->'object'->> 'id', (?)->>'object')",
|
||||
|
|
@ -144,14 +143,20 @@ defmodule Mix.Tasks.Pleroma.Database do
|
|||
)
|
||||
)
|
||||
|> where(local: true)
|
||||
|> where([a, u], is_nil(u))
|
||||
|> where([a], fragment("(? ->> 'type'::text) = 'Create'", a.data))
|
||||
|> where([_a, _u, o], fragment("?->>'type' = 'Note'", o.data))
|
||||
|> Pleroma.RepoStreamer.chunk_stream(100)
|
||||
|> where([_a, o], fragment("?->>'type' = 'Note'", o.data))
|
||||
|> Pleroma.Repo.chunk_stream(100, :batches)
|
||||
|> Stream.each(fn activities ->
|
||||
Enum.each(activities, fn activity ->
|
||||
expires_at = Timex.shift(activity.inserted_at, days: days)
|
||||
Pleroma.ActivityExpiration.create(activity, expires_at, false)
|
||||
expires_at =
|
||||
activity.inserted_at
|
||||
|> DateTime.from_naive!("Etc/UTC")
|
||||
|> Timex.shift(days: days)
|
||||
|
||||
Pleroma.Workers.PurgeExpiredActivity.enqueue(%{
|
||||
activity_id: activity.id,
|
||||
expires_at: expires_at
|
||||
})
|
||||
end)
|
||||
end)
|
||||
|> Stream.run()
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ defmodule Mix.Tasks.Pleroma.Emoji do
|
|||
|
||||
IO.puts("Downloading the pack and generating SHA256")
|
||||
|
||||
binary_archive = Tesla.get!(client(), src).body
|
||||
{:ok, %{body: binary_archive}} = Pleroma.HTTP.get(src)
|
||||
archive_sha = :crypto.hash(:sha256, binary_archive) |> Base.encode16()
|
||||
|
||||
IO.puts("SHA256 is #{archive_sha}")
|
||||
|
|
@ -252,7 +252,7 @@ defmodule Mix.Tasks.Pleroma.Emoji do
|
|||
end
|
||||
|
||||
defp fetch("http" <> _ = from) do
|
||||
with {:ok, %{body: body}} <- Tesla.get(client(), from) do
|
||||
with {:ok, %{body: body}} <- Pleroma.HTTP.get(from) do
|
||||
{:ok, body}
|
||||
end
|
||||
end
|
||||
|
|
@ -271,13 +271,5 @@ defmodule Mix.Tasks.Pleroma.Emoji do
|
|||
)
|
||||
end
|
||||
|
||||
defp client do
|
||||
middleware = [
|
||||
{Tesla.Middleware.FollowRedirects, [max_redirects: 3]}
|
||||
]
|
||||
|
||||
Tesla.client(middleware)
|
||||
end
|
||||
|
||||
defp default_manifest, do: Pleroma.Config.get!([:emoji, :default_manifest])
|
||||
end
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ defmodule Mix.Tasks.Pleroma.User do
|
|||
start_pleroma()
|
||||
|
||||
Pleroma.User.Query.build(%{nickname: "@#{instance}"})
|
||||
|> Pleroma.RepoStreamer.chunk_stream(500)
|
||||
|> Pleroma.Repo.chunk_stream(500, :batches)
|
||||
|> Stream.each(fn users ->
|
||||
users
|
||||
|> Enum.each(fn user ->
|
||||
|
|
@ -413,7 +413,7 @@ defmodule Mix.Tasks.Pleroma.User do
|
|||
start_pleroma()
|
||||
|
||||
Pleroma.User.Query.build(%{local: true})
|
||||
|> Pleroma.RepoStreamer.chunk_stream(500)
|
||||
|> Pleroma.Repo.chunk_stream(500, :batches)
|
||||
|> Stream.each(fn users ->
|
||||
users
|
||||
|> Enum.each(fn user ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue