2017-04-20 15:47:33 +00:00
|
|
|
defmodule Pleroma.Web.Websub.WebsubController do
|
|
|
|
use Pleroma.Web, :controller
|
2017-04-22 11:44:21 +00:00
|
|
|
alias Pleroma.User
|
2017-04-22 10:05:48 +00:00
|
|
|
alias Pleroma.Web.Websub
|
2017-04-22 11:44:21 +00:00
|
|
|
|
2017-04-20 15:47:33 +00:00
|
|
|
def websub_subscription_request(conn, %{"nickname" => nickname} = params) do
|
|
|
|
user = User.get_cached_by_nickname(nickname)
|
|
|
|
|
2017-04-22 11:44:21 +00:00
|
|
|
with {:ok, _websub} <- Websub.incoming_subscription_request(user, params)
|
2017-04-20 15:47:33 +00:00
|
|
|
do
|
|
|
|
conn
|
|
|
|
|> send_resp(202, "Accepted")
|
|
|
|
else {:error, reason} ->
|
|
|
|
conn
|
|
|
|
|> send_resp(500, reason)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|