aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/controller_helper.ex
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2019-10-02 20:42:40 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2019-10-02 20:42:40 +0300
commit64095961fe490029886cae358683532ea65bf2c0 (patch)
tree017731144aa638372b9ed356642c01920033618a /lib/pleroma/web/controller_helper.ex
parent6f67aed3acf557bb1e37415af82acd97e46c9ac4 (diff)
parenta22a7437d84065192601f73da73d2c27111c9b15 (diff)
downloadpleroma-64095961fe490029886cae358683532ea65bf2c0.tar.gz
[#1234] Merge remote-tracking branch 'remotes/upstream/develop' into 1234-mastodon-2-4-3-oauth-scopes
# Conflicts: # CHANGELOG.md # lib/pleroma/web/mastodon_api/controllers/mastodon_api_controller.ex # lib/pleroma/web/router.ex
Diffstat (limited to 'lib/pleroma/web/controller_helper.ex')
-rw-r--r--lib/pleroma/web/controller_helper.ex9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/pleroma/web/controller_helper.ex b/lib/pleroma/web/controller_helper.ex
index b53a01955..83b884ba9 100644
--- a/lib/pleroma/web/controller_helper.ex
+++ b/lib/pleroma/web/controller_helper.ex
@@ -6,7 +6,7 @@ defmodule Pleroma.Web.ControllerHelper do
use Pleroma.Web, :controller
# As in MastoAPI, per https://api.rubyonrails.org/classes/ActiveModel/Type/Boolean.html
- @falsy_param_values [false, 0, "0", "f", "F", "false", "FALSE", "off", "OFF"]
+ @falsy_param_values [false, 0, "0", "f", "F", "false", "False", "FALSE", "off", "OFF"]
def truthy_param?(blank_value) when blank_value in [nil, ""], do: nil
def truthy_param?(value), do: value not in @falsy_param_values
@@ -68,4 +68,11 @@ defmodule Pleroma.Web.ControllerHelper do
conn
end
end
+
+ def assign_account_by_id(%{params: %{"id" => id}} = conn, _) do
+ case Pleroma.User.get_cached_by_id(id) do
+ %Pleroma.User{} = account -> assign(conn, :account, account)
+ nil -> Pleroma.Web.MastodonAPI.FallbackController.call(conn, {:error, :not_found}) |> halt()
+ end
+ end
end