Files
firezone/elixir/apps/api/lib/api/controllers/client_json.ex
Brian Manifold a51b35a6b4 refactor(portal): remove created_by_<identity/actor> columns (#9306)
Why:

* Now that we have started using the `created_by_subject` field on
various tables, we no longer need to keep the
`created_by_<identity/actor>` fields. This will help remove a foreign
key reference and will be one step closer to allowing us to hard delete
data rather than soft deleting all data in order to keep foreign key
references like these.
2025-05-30 21:06:35 +00:00

51 lines
1.6 KiB
Elixir

defmodule API.ClientJSON do
alias API.Pagination
alias Domain.Clients
@doc """
Renders a list of Clients.
"""
def index(%{clients: clients, metadata: metadata}) do
%{
data: Enum.map(clients, &data/1),
metadata: Pagination.metadata(metadata)
}
end
@doc """
Render a single Client
"""
def show(%{client: client}) do
%{data: data(client)}
end
defp data(%Clients.Client{} = client) do
%{
id: client.id,
external_id: client.external_id,
actor_id: client.actor_id,
name: client.name,
ipv4: client.ipv4,
ipv6: client.ipv6,
online: client.online?,
last_seen_user_agent: client.last_seen_user_agent,
last_seen_remote_ip: client.last_seen_remote_ip,
last_seen_remote_ip_location_region: client.last_seen_remote_ip_location_region,
last_seen_remote_ip_location_city: client.last_seen_remote_ip_location_city,
last_seen_remote_ip_location_lat: client.last_seen_remote_ip_location_lat,
last_seen_remote_ip_location_lon: client.last_seen_remote_ip_location_lon,
last_seen_version: client.last_seen_version,
last_seen_at: client.last_seen_at,
device_serial: client.device_serial,
device_uuid: client.device_uuid,
identifier_for_vendor: client.identifier_for_vendor,
firebase_installation_id: client.firebase_installation_id,
verified_at: client.verified_at,
verified_by: client.verified_by,
verified_by_subject: client.verified_by_subject,
created_at: client.inserted_at,
updated_at: client.updated_at
}
end
end