Redirect to user feed instead of directly serving it.
authorRoger Braun <roger@rogerbraun.net>
Mon, 1 May 2017 16:05:02 +0000 (18:05 +0200)
committerRoger Braun <roger@rogerbraun.net>
Mon, 1 May 2017 16:05:02 +0000 (18:05 +0200)
lib/pleroma/web/ostatus/ostatus_controller.ex
lib/pleroma/web/router.ex
lib/pleroma/web/websub/websub.ex

index 4174db786c688c69826ad964a6dfd8a2b51d1674..1c609f6f223611d3b56dcf84e6b735d067b3725d 100644 (file)
@@ -4,8 +4,14 @@ defmodule Pleroma.Web.OStatus.OStatusController do
   alias Pleroma.{User, Activity}
   alias Pleroma.Web.OStatus.FeedRepresenter
   alias Pleroma.Repo
+  alias Pleroma.Web.OStatus
   import Ecto.Query
 
+  def feed_redirect(conn, %{"nickname" => nickname}) do
+    user = User.get_cached_by_nickname(nickname)
+    redirect conn, external: OStatus.feed_path(user)
+  end
+
   def feed(conn, %{"nickname" => nickname}) do
     user = User.get_cached_by_nickname(nickname)
     query = from activity in Activity,
index e875839df265489264914d039ac0d2a00d603d30..e1475a03eea26e0f1d85225ef92e3bd4f4b4c33e 100644 (file)
@@ -74,7 +74,7 @@ defmodule Pleroma.Web.Router do
     pipe_through :ostatus
 
     get "/users/:nickname/feed", OStatus.OStatusController, :feed
-    get "/users/:nickname", OStatus.OStatusController, :feed
+    get "/users/:nickname", OStatus.OStatusController, :feed_redirect
     post "/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming
     post "/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request
     get "/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation
index 67055a116a0be47b5daa24b0a33f5522552ec672..b279a50609cad64f3e33d371c6845c9737ce5978 100644 (file)
@@ -99,7 +99,7 @@ defmodule Pleroma.Web.Websub do
 
   defp valid_topic(%{"hub.topic" => topic}, user) do
     if topic == OStatus.feed_path(user) do
-      {:ok, topic}
+      {:ok, OStatus.feed_path(user)}
     else
       {:error, "Wrong topic requested, expected #{OStatus.feed_path(user)}, got #{topic}"}
     end