Fix objects.
This commit is contained in:
parent
aa8ddfdbe2
commit
2e277dd4ad
@ -5,6 +5,7 @@
|
|||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Activity
|
alias Pleroma.Activity
|
||||||
|
alias Pleroma.Object
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
defmodule Pleroma.SpcFixes do
|
defmodule Pleroma.SpcFixes do
|
||||||
@ -87,6 +88,26 @@ defmodule Pleroma.SpcFixes do
|
|||||||
)
|
)
|
||||||
|
|
||||||
Repo.update_all(query, [])
|
Repo.update_all(query, [])
|
||||||
|
|
||||||
|
# Fix objects
|
||||||
|
query =
|
||||||
|
from(a in Object,
|
||||||
|
where: fragment("?->>'actor' = ?", a.data, ^mapping[user.ap_id]),
|
||||||
|
update: [
|
||||||
|
set: [
|
||||||
|
data:
|
||||||
|
fragment(
|
||||||
|
"jsonb_set(jsonb_set(?, '{actor}', ?), '{to}', (?->'to')::jsonb || ?)",
|
||||||
|
a.data,
|
||||||
|
^user.ap_id,
|
||||||
|
a.data,
|
||||||
|
^[user.follower_address]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
Repo.update_all(query, [])
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,6 +11,7 @@ defmodule Pleroma.SpcFixesTest do
|
|||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Activity
|
alias Pleroma.Activity
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
|
alias Pleroma.Object
|
||||||
|
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
@ -62,5 +63,10 @@ defmodule Pleroma.SpcFixesTest do
|
|||||||
assert activity.data["actor"] == user.ap_id
|
assert activity.data["actor"] == user.ap_id
|
||||||
assert user.follower_address in activity.recipients
|
assert user.follower_address in activity.recipients
|
||||||
assert user.follower_address in activity.data["to"]
|
assert user.follower_address in activity.data["to"]
|
||||||
|
|
||||||
|
object = Object.get_by_ap_id(activity.data["object"]["id"])
|
||||||
|
|
||||||
|
assert object.data["actor"] == user.ap_id
|
||||||
|
assert user.follower_address in object.data["to"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user