Merge remote-tracking branch 'remotes/origin/develop' into feature/object-hashtags-rework
# Conflicts: # CHANGELOG.md # lib/pleroma/web/activity_pub/activity_pub.ex
This commit is contained in:
commit
4e14945670
130 changed files with 923 additions and 175 deletions
|
|
@ -0,0 +1,11 @@
|
|||
defmodule Pleroma.Repo.Migrations.AddLastActiveAtToUsers do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table(:users) do
|
||||
add(:last_active_at, :naive_datetime)
|
||||
end
|
||||
|
||||
create_if_not_exists(index(:users, [:last_active_at]))
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
defmodule Pleroma.Repo.Migrations.RemoveDuplicatesFromActivityExpirationQueue do
|
||||
use Ecto.Migration
|
||||
|
||||
import Ecto.Query, only: [from: 2]
|
||||
|
||||
def up do
|
||||
duplicate_ids =
|
||||
from(j in Oban.Job,
|
||||
where: j.queue == "activity_expiration",
|
||||
where: j.worker == "Pleroma.Workers.PurgeExpiredActivity",
|
||||
where: j.state == "scheduled",
|
||||
select:
|
||||
{fragment("(?)->>'activity_id'", j.args), fragment("array_agg(?)", j.id), count(j.id)},
|
||||
group_by: fragment("(?)->>'activity_id'", j.args),
|
||||
having: count(j.id) > 1
|
||||
)
|
||||
|> Pleroma.Repo.all()
|
||||
|> Enum.map(fn {_, ids, _} ->
|
||||
max_id = Enum.max(ids)
|
||||
List.delete(ids, max_id)
|
||||
end)
|
||||
|> List.flatten()
|
||||
|
||||
from(j in Oban.Job, where: j.id in ^duplicate_ids)
|
||||
|> Pleroma.Repo.delete_all()
|
||||
end
|
||||
|
||||
def down, do: :noop
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue