Only push to still valid websub subscriptions.

This commit is contained in:
lain 2018-03-13 18:32:17 +01:00
parent 71cee07686
commit 0067c9d2be

View file

@ -49,7 +49,8 @@ def verify(subscription, getter \\ &@httpoison.get/3) do
def publish(topic, user, %{data: %{"type" => type}} = activity) when type in @supported_activities do def publish(topic, user, %{data: %{"type" => type}} = activity) when type in @supported_activities do
# TODO: Only send to still valid subscriptions. # TODO: Only send to still valid subscriptions.
query = from sub in WebsubServerSubscription, query = from sub in WebsubServerSubscription,
where: sub.topic == ^topic and sub.state == "active" where: sub.topic == ^topic and sub.state == "active",
where: fragment("? > NOW()", sub.valid_until)
subscriptions = Repo.all(query) subscriptions = Repo.all(query)
Enum.each(subscriptions, fn(sub) -> Enum.each(subscriptions, fn(sub) ->
response = user response = user