alias Pleroma.Web.CommonAPI
alias Pleroma.Web.MastodonAPI.AccountView
alias Pleroma.Web.MastodonAPI.ScheduledActivityView
+ alias Pleroma.Web.OAuth.Token
alias Pleroma.Web.Plugs.OAuthScopesPlug
alias Pleroma.Web.Plugs.RateLimiter
)
end
- defp put_application(params, %{assigns: %{token: %{app_id: app_id}}} = _conn) do
- Map.put(params, :application, Pleroma.Web.OAuth.App.get_app_by_id(app_id))
+ defp put_application(params, %{assigns: %{token: %Token{} = token}} = _conn) do
+ %{client_name: client_name, website: website} = Repo.preload(token, :app).app
+ Map.put(params, :application, %{name: client_name, website: website})
end
defp put_application(params, _), do: Map.put(params, :application, %{name: "Web", website: nil})
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