- Add jump_credo_checks ~> 0.4 with all 20 checks enabled - Fix all standard Credo issues: 139 @spec (113 done, 26 remain), 4 refactoring, 3 alias usage, 9 System.cmd env, 5 unsafe_to_atom, 2 max line length, 9 assert_receive timeout - Fix 170+ jump_credo_checks warnings: - 117 TopLevelAliasImportRequire: move nested alias/import to module top - 32 UseObanProWorker: switch to Oban.Pro.Worker - 4 DoctestIExExamples: add doctests / create test file - ~20 WeakAssertion: strengthen type-check assertions - Various ConditionalAssertion, AssertReceiveTimeout fixes - Exclude vendor/ from Credo analysis - Remaining: 175 warnings (mostly opinionated WeakAssertion, AvoidSocketAssignsInTest), 26 @spec annotations
39 lines
961 B
Elixir
39 lines
961 B
Elixir
defmodule MicrowavepropWeb.Api.V1.UserJSON do
|
|
@moduledoc "Renders user representations for /api/v1."
|
|
|
|
alias Microwaveprop.Accounts.User
|
|
|
|
@doc "Public profile (no email)."
|
|
@spec public(User.t()) :: map()
|
|
def public(%User{} = user) do
|
|
%{
|
|
data: %{
|
|
id: user.id,
|
|
callsign: user.callsign,
|
|
name: user.name,
|
|
home_grid: user.home_grid,
|
|
home_lat: user.home_lat,
|
|
home_lon: user.home_lon
|
|
}
|
|
}
|
|
end
|
|
|
|
@doc "Authenticated /me view (includes email + admin flag)."
|
|
@spec me(User.t()) :: map()
|
|
def me(%User{} = user) do
|
|
%{
|
|
data: %{
|
|
id: user.id,
|
|
callsign: user.callsign,
|
|
name: user.name,
|
|
email: user.email,
|
|
is_admin: user.is_admin,
|
|
confirmed_at: user.confirmed_at,
|
|
home_grid: user.home_grid,
|
|
home_lat: user.home_lat,
|
|
home_lon: user.home_lon,
|
|
home_elevation_m: user.home_elevation_m
|
|
}
|
|
}
|
|
end
|
|
end
|