mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 08:36:29 +00:00
Ensure only Note objects are set to expire
This commit is contained in:
parent
0589e9156a
commit
724ed354f2
1 changed files with 10 additions and 1 deletions
|
@ -134,14 +134,23 @@ defmodule Mix.Tasks.Pleroma.Database do
|
||||||
|
|
||||||
Pleroma.Activity
|
Pleroma.Activity
|
||||||
|> join(:left, [a], u in assoc(a, :expiration))
|
|> join(:left, [a], u in assoc(a, :expiration))
|
||||||
|
|> join(:inner, [a, _u], o in Object,
|
||||||
|
on:
|
||||||
|
fragment(
|
||||||
|
"(?->>'id') = COALESCE((?)->'object'->> 'id', (?)->>'object')",
|
||||||
|
o.data,
|
||||||
|
a.data,
|
||||||
|
a.data
|
||||||
|
)
|
||||||
|
)
|
||||||
|> where(local: true)
|
|> where(local: true)
|
||||||
|> where([a, u], is_nil(u))
|
|> where([a, u], is_nil(u))
|
||||||
|> where([a], fragment("(? ->> 'type'::text) = 'Create'", a.data))
|
|> where([a], fragment("(? ->> 'type'::text) = 'Create'", a.data))
|
||||||
|
|> where([_a, _u, o], fragment("?->>'type' = 'Note'", o.data))
|
||||||
|> Pleroma.RepoStreamer.chunk_stream(100)
|
|> Pleroma.RepoStreamer.chunk_stream(100)
|
||||||
|> Stream.each(fn activities ->
|
|> Stream.each(fn activities ->
|
||||||
Enum.each(activities, fn activity ->
|
Enum.each(activities, fn activity ->
|
||||||
expires_at = Timex.shift(activity.inserted_at, days: days)
|
expires_at = Timex.shift(activity.inserted_at, days: days)
|
||||||
|
|
||||||
Pleroma.ActivityExpiration.create(activity, expires_at, false)
|
Pleroma.ActivityExpiration.create(activity, expires_at, false)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in a new issue