aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-05-10 18:45:55 +0200
committerRoger Braun <roger@rogerbraun.net>2017-05-10 18:45:55 +0200
commit34a1ce00ecc6f19827638fc311e4e76d3c4cb162 (patch)
tree96cdbe8a1987819ebfac9acbbe15747d83ba4d93 /lib
parenta2ca3b86053d0f74106bc65fddd7073d12423bbe (diff)
downloadpleroma-34a1ce00ecc6f19827638fc311e4e76d3c4cb162.tar.gz
Set valid_until date.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/websub/websub_controller.ex6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/pleroma/web/websub/websub_controller.ex b/lib/pleroma/web/websub/websub_controller.ex
index 4fc693214..9d3c1cd01 100644
--- a/lib/pleroma/web/websub/websub_controller.ex
+++ b/lib/pleroma/web/websub/websub_controller.ex
@@ -18,9 +18,11 @@ defmodule Pleroma.Web.Websub.WebsubController do
end
end
- def websub_subscription_confirmation(conn, %{"id" => id, "hub.mode" => "subscribe", "hub.challenge" => challenge, "hub.topic" => topic}) do
+ # TODO: Extract this into the Websub module
+ def websub_subscription_confirmation(conn, %{"id" => id, "hub.mode" => "subscribe", "hub.challenge" => challenge, "hub.topic" => topic, "hub.lease_seconds" => lease_seconds}) do
with %WebsubClientSubscription{} = websub <- Repo.get_by(WebsubClientSubscription, id: id, topic: topic) do
- change = Ecto.Changeset.change(websub, %{state: "accepted"})
+ valid_until = NaiveDateTime.add(NaiveDateTime.utc_now, String.to_integer(lease_seconds))
+ change = Ecto.Changeset.change(websub, %{state: "accepted", valid_until: valid_until})
{:ok, _websub} = Repo.update(change)
conn
|> send_resp(200, challenge)