Skip to content

Commit 76633a2

Browse files
authored
Track the link api version in the connection metadata (#1875)
This is useful for knowing if there are devices we, as a platform, might want to recommend users/customers upgrade. Eg. security, performance, feature set, compatibility
1 parent 9fd03f3 commit 76633a2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/nerves_hub_web/channels/device_channel.ex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,12 @@ defmodule NervesHubWeb.DeviceChannel do
372372
{:noreply, socket}
373373
end
374374

375-
defp assign_api_version(socket, params) do
376-
assign(socket, :device_api_version, Map.get(params, "device_api_version", "1.0.0"))
375+
defp assign_api_version(%{assigns: %{reference_id: ref_id}} = socket, params) do
376+
version = Map.get(params, "device_api_version", "1.0.0")
377+
378+
:ok = Connections.merge_update_metadata(ref_id, %{"device_api_version" => version})
379+
380+
assign(socket, :device_api_version, version)
377381
end
378382

379383
defp retry_device_registration(socket, attempt) do

0 commit comments

Comments
 (0)