websub: improve error handling
authorWilliam Pitcock <nenolod@dereferenced.org>
Tue, 15 Jan 2019 18:00:20 +0000 (18:00 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Tue, 15 Jan 2019 18:03:49 +0000 (18:03 +0000)
lib/pleroma/web/websub/websub.ex
lib/pleroma/web/websub/websub_controller.ex

index 3a287edd98b18a53e5ada6e329ed85e624102736..7ca62c83b111fb9ccd560d6c232f9605e105da98 100644 (file)
@@ -121,6 +121,12 @@ defmodule Pleroma.Web.Websub do
     end
   end
 
+  def incoming_subscription_request(user, params) do
+    Logger.info("Unhandled WebSub request for #{user.nickname}: #{inspect(params)}")
+
+    {:error, "Invalid WebSub request"}
+  end
+
   defp get_subscription(topic, callback) do
     Repo.get_by(WebsubServerSubscription, topic: topic, callback: callback) ||
       %WebsubServerSubscription{}
index 27304d988c5b3dffcf3c33bcea85d29c98a6582b..e58f144e5227d3721e44271122acd11653991128 100644 (file)
@@ -67,6 +67,13 @@ defmodule Pleroma.Web.Websub.WebsubController do
     end
   end
 
+  def websub_subscription_confirmation(conn, params) do
+    Logger.info("Invalid WebSub confirmation request: #{inspect(params)}")
+
+    conn
+    |> send_resp(500, "Invalid parameters")
+  end
+
   def websub_incoming(conn, %{"id" => id}) do
     with "sha1=" <> signature <- hd(get_req_header(conn, "x-hub-signature")),
          signature <- String.downcase(signature),