end
def publish(topic, user, activity) do
+ # TODO: Only send to still valid subscriptions.
query = from sub in WebsubServerSubscription,
where: sub.topic == ^topic and sub.state == "active"
subscriptions = Repo.all(query)
{: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 == "accepted"
+
+ subs = Repo.all(query)
+
+ Enum.map(subs, fn (sub) ->
+ request_subscription(sub)
+ end)
+ end
end