From 5cd291d39632f92f234256391a8cd7c8057beaad Mon Sep 17 00:00:00 2001 From: Elin Olsson Date: Fri, 27 Dec 2024 13:38:32 +0100 Subject: [PATCH 1/2] Rename function for broadcasting extension events --- lib/nerves_hub/devices.ex | 4 ++-- lib/nerves_hub/extensions.ex | 12 ++++-------- lib/nerves_hub/products.ex | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/nerves_hub/devices.ex b/lib/nerves_hub/devices.ex index d693d38af..9204ce2b6 100644 --- a/lib/nerves_hub/devices.ex +++ b/lib/nerves_hub/devices.ex @@ -1409,7 +1409,7 @@ defmodule NervesHub.Devices do |> Repo.update() |> tap(fn {:ok, _} -> - Extensions.toggle_extension(device, "attach", extension_string) + Extensions.broadcast_extension_event(device, "attach", extension_string) _ -> :nope @@ -1423,7 +1423,7 @@ defmodule NervesHub.Devices do |> Repo.update() |> tap(fn {:ok, _} -> - Extensions.toggle_extension(device, "detach", extension_string) + Extensions.broadcast_extension_event(device, "detach", extension_string) _ -> :nope diff --git a/lib/nerves_hub/extensions.ex b/lib/nerves_hub/extensions.ex index 7bdc4e9e6..d1b4345ba 100644 --- a/lib/nerves_hub/extensions.ex +++ b/lib/nerves_hub/extensions.ex @@ -65,19 +65,15 @@ defmodule NervesHub.Extensions do :unsupported end - def toggle_extension(target, event, extension) do - device_internal_broadcast!(target, event, %{ - "extensions" => [extension] - }) - end - - defp device_internal_broadcast!(target, event, payload) do + def broadcast_extenstion_event(target, event, extention) do Phoenix.Channel.Server.broadcast_from!( NervesHub.PubSub, self(), topic(target), event, - payload + %{ + "extensions" => [extension] + } ) end diff --git a/lib/nerves_hub/products.ex b/lib/nerves_hub/products.ex index 89e77556e..d8ff4467a 100644 --- a/lib/nerves_hub/products.ex +++ b/lib/nerves_hub/products.ex @@ -278,7 +278,7 @@ defmodule NervesHub.Products do |> Repo.update() |> tap(fn {:ok, _} -> - Extensions.toggle_extension(product, "attach", extension_string) + Extensions.broadcast_extension_event(product, "attach", extension_string) _ -> :nope @@ -292,7 +292,7 @@ defmodule NervesHub.Products do |> Repo.update() |> tap(fn {:ok, _} -> - Extensions.toggle_extension(product, "detach", extension_string) + Extensions.broadcast_extension_event(product, "detach", extension_string) _ -> :nope From 03b50d880e76ac08fdc98c10b414fba69af01eb8 Mon Sep 17 00:00:00 2001 From: Elin Olsson Date: Fri, 27 Dec 2024 13:46:48 +0100 Subject: [PATCH 2/2] fix spelling --- lib/nerves_hub/extensions.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerves_hub/extensions.ex b/lib/nerves_hub/extensions.ex index d1b4345ba..330798e9d 100644 --- a/lib/nerves_hub/extensions.ex +++ b/lib/nerves_hub/extensions.ex @@ -65,7 +65,7 @@ defmodule NervesHub.Extensions do :unsupported end - def broadcast_extenstion_event(target, event, extention) do + def broadcast_extension_event(target, event, extension) do Phoenix.Channel.Server.broadcast_from!( NervesHub.PubSub, self(),