Redirect to user feed instead of directly serving it.

This commit is contained in:
Roger Braun 2017-05-01 18:05:02 +02:00
parent 1854842b09
commit 92a8944dfe
3 changed files with 8 additions and 2 deletions

View File

@ -4,8 +4,14 @@ defmodule Pleroma.Web.OStatus.OStatusController do
alias Pleroma.{User, Activity} alias Pleroma.{User, Activity}
alias Pleroma.Web.OStatus.FeedRepresenter alias Pleroma.Web.OStatus.FeedRepresenter
alias Pleroma.Repo alias Pleroma.Repo
alias Pleroma.Web.OStatus
import Ecto.Query 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 def feed(conn, %{"nickname" => nickname}) do
user = User.get_cached_by_nickname(nickname) user = User.get_cached_by_nickname(nickname)
query = from activity in Activity, query = from activity in Activity,

View File

@ -74,7 +74,7 @@ def user_fetcher(username) do
pipe_through :ostatus pipe_through :ostatus
get "/users/:nickname/feed", OStatus.OStatusController, :feed 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 "/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming
post "/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request post "/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request
get "/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation get "/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation

View File

@ -99,7 +99,7 @@ defp lease_time(_) do
defp valid_topic(%{"hub.topic" => topic}, user) do defp valid_topic(%{"hub.topic" => topic}, user) do
if topic == OStatus.feed_path(user) do if topic == OStatus.feed_path(user) do
{:ok, topic} {:ok, OStatus.feed_path(user)}
else else
{:error, "Wrong topic requested, expected #{OStatus.feed_path(user)}, got #{topic}"} {:error, "Wrong topic requested, expected #{OStatus.feed_path(user)}, got #{topic}"}
end end