Add proper callback route for websub confirmation.

This commit is contained in:
Roger Braun 2017-04-28 09:51:47 +02:00
parent 90da25505f
commit 451d18af63
4 changed files with 12 additions and 3 deletions

View file

@ -75,6 +75,7 @@ defmodule Pleroma.Web.Router do
get "/users/:nickname/feed", OStatus.OStatusController, :feed
post "/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming
post "/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation
post "/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request
end

View file

@ -2,8 +2,8 @@ defmodule Pleroma.Web.Websub do
alias Pleroma.Repo
alias Pleroma.Web.Websub.{WebsubServerSubscription, WebsubClientSubscription}
alias Pleroma.Web.OStatus.FeedRepresenter
alias Pleroma.Web.OStatus
alias Pleroma.Web.XML
alias Pleroma.Web.{XML, Endpoint, OStatus}
alias Pleroma.Web.Router.Helpers
require Logger
import Ecto.Query
@ -136,7 +136,7 @@ defmodule Pleroma.Web.Websub do
"hub.mode": "subscribe",
"hub.topic": websub.topic,
"hub.secret": websub.secret,
"hub.callback": "https://social.heldscal.la/callback"
"hub.callback": Helpers.websub_url(Endpoint, :websub_subscription_confirmation, websub.id)
]
# This checks once a second if we are confirmed yet

View file

@ -15,4 +15,9 @@ defmodule Pleroma.Web.Websub.WebsubController do
|> send_resp(500, reason)
end
end
def websub_subscription_confirmation(conn, params) do
IO.inspect(params)
conn
end
end

View file

@ -3,11 +3,13 @@ defmodule Pleroma.Web.WebsubMock do
{:ok, sub}
end
end
defmodule Pleroma.Web.WebsubTest do
use Pleroma.DataCase
alias Pleroma.Web.Websub
alias Pleroma.Web.Websub.WebsubServerSubscription
import Pleroma.Factory
alias Pleroma.Web.Router.Helpers
test "a verification of a request that is accepted" do
sub = insert(:websub_subscription)
@ -121,6 +123,7 @@ defmodule Pleroma.Web.WebsubTest do
poster = fn (^hub, {:form, data}, _headers) ->
assert Keyword.get(data, :"hub.mode") == "subscribe"
assert Keyword.get(data, :"hub.callback") == Helpers.websub_url(Pleroma.Web.Endpoint, :websub_subscription_confirmation, websub.id)
{:ok, %{status_code: 202}}
end