X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fworkers%2Fpurge_expired_activity.ex;h=01256831bc6490a93f18475bfc5b114db234fecc;hb=1b79dce7bc53f0aa6ce07fdc178bb72b5caabe98;hp=f981eda8eca9573b6dc31dd4853d276a49cce573;hpb=eb5ff715f7917e174b9ae104a5d82779ff925301;p=akkoma
diff --git a/lib/pleroma/workers/purge_expired_activity.ex b/lib/pleroma/workers/purge_expired_activity.ex
index f981eda8e..01256831b 100644
--- a/lib/pleroma/workers/purge_expired_activity.ex
+++ b/lib/pleroma/workers/purge_expired_activity.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Workers.PurgeExpiredActivity do
@@ -18,8 +18,7 @@ defmodule Pleroma.Workers.PurgeExpiredActivity do
| {:error, :expired_activities_disabled}
| {:error, :expiration_too_close}
def enqueue(args) do
- with true <- enabled?(),
- args when is_map(args) <- validate_expires_at(args) do
+ with true <- enabled?() do
{scheduled_at, args} = Map.pop(args, :expires_at)
args
@@ -42,16 +41,6 @@ defmodule Pleroma.Workers.PurgeExpiredActivity do
end
end
- defp validate_expires_at(%{validate: false} = args), do: Map.delete(args, :validate)
-
- defp validate_expires_at(args) do
- if expires_late_enough?(args[:expires_at]) do
- args
- else
- {:error, :expiration_too_close}
- end
- end
-
defp find_activity(id) do
with nil <- Activity.get_by_id_with_object(id) do
{:error, :activity_not_found}
@@ -77,6 +66,7 @@ defmodule Pleroma.Workers.PurgeExpiredActivity do
def expires_late_enough?(scheduled_at) do
now = DateTime.utc_now()
diff = DateTime.diff(scheduled_at, now, :millisecond)
- diff > :timer.hours(1)
+ min_lifetime = Pleroma.Config.get([__MODULE__, :min_lifetime], 600)
+ diff > :timer.seconds(min_lifetime)
end
end