Merge branch 'feature/521-pinned-post-federation' into 'develop'
Pinned posts federation Closes #521 See merge request pleroma/pleroma!3312
This commit is contained in:
commit
79376b4afb
41 changed files with 1465 additions and 127 deletions
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue