From de8b8e9cf15e5d0d084fbcdf73f5d637617c7744 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 9 Feb 2021 14:41:58 -0600 Subject: [PATCH] Add a function to lookup client app details by the app_id --- lib/pleroma/web/o_auth/app.ex | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/pleroma/web/o_auth/app.ex b/lib/pleroma/web/o_auth/app.ex index 382750010..083b5ce09 100644 --- a/lib/pleroma/web/o_auth/app.ex +++ b/lib/pleroma/web/o_auth/app.ex @@ -146,4 +146,14 @@ def errors(changeset) do Map.put(acc, key, error) end) end + + @spec get_app_by_id(pos_integer()) :: {:ok, map()} + def get_app_by_id(app_id) do + query = + __MODULE__ + |> where([a], a.id == ^app_id) + |> select([a], %{name: a.client_name, website: a.website}) + + Repo.one!(query) + end end