aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorlambda <pleromagit@rogerbraun.net>2018-06-08 11:10:10 +0000
committerlambda <pleromagit@rogerbraun.net>2018-06-08 11:10:10 +0000
commit45a935f0bd86501d64be7f453c08a47e46565ef9 (patch)
treeabfa2022ddb53c8d006c3b3225a7f2d07a5326c6 /lib
parentbb639a362e42cba5a78e64e4c7fc0380fe25c414 (diff)
parentfa0c2727d86f63136b88d65e3bb876dd17f316aa (diff)
downloadpleroma-45a935f0bd86501d64be7f453c08a47e46565ef9.tar.gz
Merge branch 'users' into 'develop'
Fix users lookup/return type See merge request pleroma/pleroma!201
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub_controller.ex2
-rw-r--r--lib/pleroma/web/ostatus/ostatus_controller.ex25
2 files changed, 17 insertions, 10 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex
index ee5d319a7..d337532d0 100644
--- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex
@@ -15,6 +15,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
conn
|> put_resp_header("content-type", "application/activity+json")
|> json(UserView.render("user.json", %{user: user}))
+ else
+ nil -> {:error, :not_found}
end
end
diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex
index f346cc9af..2f72fdb16 100644
--- a/lib/pleroma/web/ostatus/ostatus_controller.ex
+++ b/lib/pleroma/web/ostatus/ostatus_controller.ex
@@ -12,19 +12,24 @@ defmodule Pleroma.Web.OStatus.OStatusController do
action_fallback(:errors)
def feed_redirect(conn, %{"nickname" => nickname}) do
- with {_, %User{} = user} <- {:user, User.get_cached_by_nickname(nickname)} do
- case get_format(conn) do
- "html" -> Fallback.RedirectController.redirector(conn, nil)
- "activity+json" -> ActivityPubController.call(conn, :user)
- _ -> redirect(conn, external: OStatus.feed_path(user))
- end
- else
- {:user, nil} -> {:error, :not_found}
+ case get_format(conn) do
+ "html" ->
+ Fallback.RedirectController.redirector(conn, nil)
+
+ "activity+json" ->
+ ActivityPubController.call(conn, :user)
+
+ _ ->
+ with %User{} = user <- User.get_cached_by_nickname(nickname) do
+ redirect(conn, external: OStatus.feed_path(user))
+ else
+ nil -> {:error, :not_found}
+ end
end
end
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 =
Map.take(params, ["max_id"])
|> Map.merge(%{"whole_db" => true, "actor_id" => user.ap_id})
@@ -43,7 +48,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do
|> put_resp_content_type("application/atom+xml")
|> send_resp(200, response)
else
- {:user, nil} -> {:error, :not_found}
+ nil -> {:error, :not_found}
end
end