Merge branch 'feed-routes' into 'develop'
Add /@:nickname route, redirect /users/:nickname.rss to /users/:nickname/feed.rss instead of .atom See merge request soapbox-pub/soapbox-be!120
This commit is contained in:
commit
9cbd2406cc
2 changed files with 6 additions and 2 deletions
|
@ -28,9 +28,12 @@ def feed_redirect(%{assigns: %{format: format}} = conn, _params)
|
|||
ActivityPubController.call(conn, :user)
|
||||
end
|
||||
|
||||
def feed_redirect(conn, %{"nickname" => nickname}) do
|
||||
def feed_redirect(%{assigns: assigns} = conn, %{"nickname" => nickname}) do
|
||||
format = Map.get(assigns, :format, "atom")
|
||||
format = if format in ["atom", "rss"], do: format, else: "atom"
|
||||
|
||||
with {_, %User{} = user} <- {:fetch_user, User.get_cached_by_nickname(nickname)} do
|
||||
redirect(conn, external: "#{Routes.user_feed_url(conn, :feed, user.nickname)}.atom")
|
||||
redirect(conn, external: "#{Routes.user_feed_url(conn, :feed, user.nickname)}.#{format}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -723,6 +723,7 @@ defmodule Pleroma.Web.Router do
|
|||
|
||||
# Note: returns user _profile_ for json requests, redirects to user _feed_ for non-json ones
|
||||
get("/users/:nickname", Feed.UserController, :feed_redirect, as: :user_feed)
|
||||
get("/@:nickname", Feed.UserController, :feed_redirect, as: :user_feed)
|
||||
end
|
||||
|
||||
scope "/", Pleroma.Web do
|
||||
|
|
Loading…
Reference in a new issue