aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/websub/websub.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pleroma/web/websub/websub.ex')
-rw-r--r--lib/pleroma/web/websub/websub.ex15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/pleroma/web/websub/websub.ex b/lib/pleroma/web/websub/websub.ex
index 7c8efa917..5468758fd 100644
--- a/lib/pleroma/web/websub/websub.ex
+++ b/lib/pleroma/web/websub/websub.ex
@@ -204,4 +204,19 @@ defmodule Pleroma.Web.Websub do
{:error, websub}
end
end
+
+ def refresh_subscriptions(delta \\ 60 * 60 * 24) do
+ Logger.debug("Refreshing subscriptions")
+
+ cut_off = NaiveDateTime.add(NaiveDateTime.utc_now, delta)
+
+ query = from sub in WebsubClientSubscription,
+ where: sub.valid_until < ^cut_off and sub.state == "active"
+
+ subs = Repo.all(query)
+
+ Enum.map(subs, fn (sub) ->
+ request_subscription(sub)
+ end)
+ end
end