Merge branch 'users' into 'develop'
Fix users lookup/return type See merge request pleroma/pleroma!201
This commit is contained in:
commit
45a935f0bd
|
@ -15,6 +15,8 @@ def user(conn, %{"nickname" => nickname}) do
|
||||||
conn
|
conn
|
||||||
|> put_resp_header("content-type", "application/activity+json")
|
|> put_resp_header("content-type", "application/activity+json")
|
||||||
|> json(UserView.render("user.json", %{user: user}))
|
|> json(UserView.render("user.json", %{user: user}))
|
||||||
|
else
|
||||||
|
nil -> {:error, :not_found}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,19 +12,24 @@ defmodule Pleroma.Web.OStatus.OStatusController do
|
||||||
action_fallback(:errors)
|
action_fallback(:errors)
|
||||||
|
|
||||||
def feed_redirect(conn, %{"nickname" => nickname}) do
|
def feed_redirect(conn, %{"nickname" => nickname}) do
|
||||||
with {_, %User{} = user} <- {:user, User.get_cached_by_nickname(nickname)} do
|
|
||||||
case get_format(conn) do
|
case get_format(conn) do
|
||||||
"html" -> Fallback.RedirectController.redirector(conn, nil)
|
"html" ->
|
||||||
"activity+json" -> ActivityPubController.call(conn, :user)
|
Fallback.RedirectController.redirector(conn, nil)
|
||||||
_ -> redirect(conn, external: OStatus.feed_path(user))
|
|
||||||
end
|
"activity+json" ->
|
||||||
|
ActivityPubController.call(conn, :user)
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
with %User{} = user <- User.get_cached_by_nickname(nickname) do
|
||||||
|
redirect(conn, external: OStatus.feed_path(user))
|
||||||
else
|
else
|
||||||
{:user, nil} -> {:error, :not_found}
|
nil -> {:error, :not_found}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def feed(conn, %{"nickname" => nickname} = params) do
|
def feed(conn, %{"nickname" => nickname} = params) do
|
||||||
with {_, %User{} = user} <- {:user, User.get_cached_by_nickname(nickname)} do
|
with %User{} = user <- User.get_cached_by_nickname(nickname) do
|
||||||
query_params =
|
query_params =
|
||||||
Map.take(params, ["max_id"])
|
Map.take(params, ["max_id"])
|
||||||
|> Map.merge(%{"whole_db" => true, "actor_id" => user.ap_id})
|
|> Map.merge(%{"whole_db" => true, "actor_id" => user.ap_id})
|
||||||
|
@ -43,7 +48,7 @@ def feed(conn, %{"nickname" => nickname} = params) do
|
||||||
|> put_resp_content_type("application/atom+xml")
|
|> put_resp_content_type("application/atom+xml")
|
||||||
|> send_resp(200, response)
|
|> send_resp(200, response)
|
||||||
else
|
else
|
||||||
{:user, nil} -> {:error, :not_found}
|
nil -> {:error, :not_found}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue