projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix Reblog API
[akkoma]
/
lib
/
pleroma
/
workers
/
purge_expired_activity.ex
diff --git
a/lib/pleroma/workers/purge_expired_activity.ex
b/lib/pleroma/workers/purge_expired_activity.ex
index f981eda8eca9573b6dc31dd4853d276a49cce573..01256831bc6490a93f18475bfc5b114db234fecc 100644
(file)
--- 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
# Pleroma: A lightweight social networking server
-# Copyright © 2017-202
0
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-202
1
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Workers.PurgeExpiredActivity do
# 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
| {: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
{scheduled_at, args} = Map.pop(args, :expires_at)
args
@@
-42,16
+41,6
@@
defmodule Pleroma.Workers.PurgeExpiredActivity do
end
end
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}
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)
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
end
end