From 55a9e58dcf6b47b22807b9b268e7b231d1be7a75 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Mon, 6 Oct 2025 16:21:58 -0600 Subject: [PATCH] Fix follow me Cast to a string and evaluating conditions as 'true' or 'false' is the most effective approach for Lua. --- app/switch/resources/scripts/follow_me.lua | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/switch/resources/scripts/follow_me.lua b/app/switch/resources/scripts/follow_me.lua index 2751542aae..fd37d87f79 100644 --- a/app/switch/resources/scripts/follow_me.lua +++ b/app/switch/resources/scripts/follow_me.lua @@ -16,7 +16,7 @@ -- -- The Initial Developer of the Original Code is -- Mark J Crane --- Copyright (C) 2010-2021 +-- Copyright (C) 2010-2025 -- the Initial Developer. All Rights Reserved. -- -- Contributor(s): @@ -54,9 +54,6 @@ local default_dialect = session:getVariable("default_dialect") or 'us'; local default_voice = session:getVariable("default_voice") or 'callie'; ---a moment to sleep - session:sleep(1000); - --check if the session is ready if not session:ready() then return end @@ -64,7 +61,9 @@ local dbh = Database.new('system'); --determine whether to update the dial string - local sql = "select extension, number_alias, accountcode, follow_me_uuid, follow_me_enabled "; + local sql = "select extension, number_alias, "; + sql = sql .. "accountcode, follow_me_uuid, "; + sql = sql .. "cast(follow_me_enabled as text) "; sql = sql .. "from v_extensions "; sql = sql .. "where domain_uuid = :domain_uuid "; sql = sql .. "and extension_uuid = :extension_uuid "; @@ -83,7 +82,7 @@ local follow_me_enabled = row.follow_me_enabled; --set follow me - if (not follow_me_enabled) then + if (follow_me_enabled == 'false') then --update the display and play a message channel_display(session:get_uuid(), "Activated") session:execute("sleep", "2000"); @@ -92,7 +91,7 @@ end --unset follow me - if (follow_me_enabled) then + if (follow_me_enabled == 'true') then --update the display and play a message channel_display(session:get_uuid(), "Cancelled") session:execute("sleep", "2000"); @@ -102,7 +101,7 @@ --enable or disable follow me sql = "update v_follow_me set "; - if (follow_me_enabled) then + if (follow_me_enabled == 'true') then sql = sql .. "follow_me_enabled = false "; else sql = sql .. "follow_me_enabled = true "; @@ -118,7 +117,7 @@ --update the extension sql = "update v_extensions set "; sql = sql .. "do_not_disturb = false, "; - if (follow_me_enabled) then + if (follow_me_enabled == 'true') then sql = sql .. "follow_me_enabled = false, "; else sql = sql .. "follow_me_enabled = true, ";