Add a function to lookup client app details by the app_id
authorMark Felder <feld@feld.me>
Tue, 9 Feb 2021 20:41:58 +0000 (14:41 -0600)
committerMark Felder <feld@feld.me>
Tue, 9 Feb 2021 22:59:58 +0000 (16:59 -0600)
lib/pleroma/web/o_auth/app.ex

index 38275001036177a142cb0f2d436242bd2cc9063a..083b5ce092075cb4602b49c3ad760ac190da06ad 100644 (file)
@@ -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