From: Mark Felder Date: Tue, 9 Feb 2021 20:41:58 +0000 (-0600) Subject: Add a function to lookup client app details by the app_id X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=de8b8e9cf15e5d0d084fbcdf73f5d637617c7744;p=akkoma Add a function to lookup client app details by the app_id --- 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 @@ defmodule Pleroma.Web.OAuth.App 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