forked from AkkomaGang/akkoma
don't load pinned activities in due_expirations
This commit is contained in:
parent
091da10832
commit
3ab83f837e
4 changed files with 15 additions and 4 deletions
|
@ -150,9 +150,7 @@ def run(["ensure_expiration"]) do
|
||||||
|> 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 ->
|
||||||
user = User.get_cached_by_ap_id(activity.actor)
|
if not Pleroma.Activity.pinned_by_actor?(activity) do
|
||||||
|
|
||||||
if activity.id not in user.pinned_activities do
|
|
||||||
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
|
||||||
|
|
|
@ -340,4 +340,10 @@ def direct_conversation_id(activity, for_user) do
|
||||||
_ -> nil
|
_ -> nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec pinned_by_actor?(Activity.t()) :: boolean()
|
||||||
|
def pinned_by_actor?(%Activity{} = activity) do
|
||||||
|
actor = user_actor(activity)
|
||||||
|
activity.id in actor.pinned_activities
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,7 +47,11 @@ def due_expirations(offset \\ 0) do
|
||||||
ActivityExpiration
|
ActivityExpiration
|
||||||
|> where([exp], exp.scheduled_at < ^naive_datetime)
|
|> where([exp], exp.scheduled_at < ^naive_datetime)
|
||||||
|> limit(50)
|
|> limit(50)
|
||||||
|
|> preload(:activity)
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|
|> Enum.reject(fn %{activity: activity} ->
|
||||||
|
Activity.pinned_by_actor?(activity)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_scheduled_at(changeset, false), do: changeset
|
def validate_scheduled_at(changeset, false), do: changeset
|
||||||
|
|
|
@ -11,7 +11,10 @@ defmodule Pleroma.ActivityExpirationTest do
|
||||||
|
|
||||||
test "finds activities due to be deleted only" do
|
test "finds activities due to be deleted only" do
|
||||||
activity = insert(:note_activity)
|
activity = insert(:note_activity)
|
||||||
expiration_due = insert(:expiration_in_the_past, %{activity_id: activity.id})
|
|
||||||
|
expiration_due =
|
||||||
|
insert(:expiration_in_the_past, %{activity_id: activity.id}) |> Repo.preload(:activity)
|
||||||
|
|
||||||
activity2 = insert(:note_activity)
|
activity2 = insert(:note_activity)
|
||||||
insert(:expiration_in_the_future, %{activity_id: activity2.id})
|
insert(:expiration_in_the_future, %{activity_id: activity2.id})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue