forked from AkkomaGang/akkoma
- save object ids on pin, instead of activity ids - pins federation - removed pinned_activities field from the users table - activityPub endpoint for user pins - pulling remote users pins
28 lines
744 B
Elixir
28 lines
744 B
Elixir
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
|