Add a function to lookup client app details by the app_id

This commit is contained in:
Mark Felder 2021-02-09 14:41:58 -06:00
parent fc42e714e2
commit de8b8e9cf1

View File

@ -146,4 +146,14 @@ defmodule Pleroma.Web.OAuth.App do
Map.put(acc, key, error) Map.put(acc, key, error)
end) end)
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 end