prop/lib/microwaveprop_web/controllers/api/v1/profile_controller.ex
Graham McIntire fd976b0cd5
fix: resolve 391 Credo issues across codebase
- 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
2026-06-12 13:51:32 -05:00

33 lines
1 KiB
Elixir

defmodule MicrowavepropWeb.Api.V1.ProfileController do
@moduledoc "Public per-callsign user profile (no email exposed)."
use Phoenix.Controller, formats: [:json]
alias Microwaveprop.Accounts
alias Microwaveprop.Beacons
alias Microwaveprop.Radio
alias MicrowavepropWeb.Api.ErrorJSON
alias MicrowavepropWeb.Api.V1.BeaconJSON
alias MicrowavepropWeb.Api.V1.ContactJSON
alias MicrowavepropWeb.Api.V1.UserJSON
plug :accepts, ["json"]
@spec show(Plug.Conn.t(), map()) :: Plug.Conn.t()
def show(conn, %{"callsign" => callsign}) do
case Accounts.get_user_by_callsign(callsign) do
nil ->
ErrorJSON.send_problem(conn, 404, "not_found", "Callsign not registered.")
user ->
contacts = Radio.list_contacts_involving_callsign(user.callsign)
beacons = Beacons.list_beacons_for_user(user)
json(conn, %{
user: UserJSON.public(user).data,
contacts: ContactJSON.index(%{contacts: contacts}).data,
beacons: BeaconJSON.index(%{beacons: beacons}).data
})
end
end
end