From 91efee3b271ad0879be89804b060a62d96f2829b Mon Sep 17 00:00:00 2001 From: frytimo Date: Fri, 11 Jul 2025 13:57:54 -0300 Subject: [PATCH] Fix active calls eavesdrop (#7419) * Remove old debug comments * Remove unused variable * Remove debug information * Fix eavesdrop missing domain_name * Remove extended debug information --- .../classes/active_calls_service.php | 6 ++--- .../resources/classes/subscriber.php | 25 +++---------------- .../resources/classes/websocket_service.php | 6 ++--- 3 files changed, 9 insertions(+), 28 deletions(-) diff --git a/app/active_calls/resources/classes/active_calls_service.php b/app/active_calls/resources/classes/active_calls_service.php index 0c094013bb..b88993eecd 100644 --- a/app/active_calls/resources/classes/active_calls_service.php +++ b/app/active_calls/resources/classes/active_calls_service.php @@ -556,15 +556,15 @@ class active_calls_service extends service implements websocket_service_interfac $response['topic'] = $websocket_message->topic; $response['request_id'] = $websocket_message->request_id; - // Get the payload + // Get the payload and domain from message $payload = $websocket_message->payload(); + $domain_name = $websocket_message->domain_name() ?? ''; // Get the eavesdrop information from the payload to send to the switch $uuid = $payload['unique_id'] ?? ''; $origination_caller_id_name = $payload['origination_caller_id_name'] ?? ''; $caller_caller_id_number = $payload['caller_caller_id_number'] ?? ''; $origination_caller_contact = $payload['origination_caller_contact'] ?? ''; - $domain_name = $payload['domain_name'] ?? ''; $response['status_message'] = 'success'; $response['status_code'] = 200; @@ -815,7 +815,7 @@ class active_calls_service extends service implements websocket_service_interfac return; } - $this->debug("Received message on websocket: $json_string (" . strlen($json_string) . " bytes)"); + $this->debug("Received message on websocket: (" . strlen($json_string) . " bytes)"); // Get the web socket message as an object $message = websocket_message::create_from_json_message($json_string); diff --git a/core/websockets/resources/classes/subscriber.php b/core/websockets/resources/classes/subscriber.php index 2005c2b541..21a395774b 100644 --- a/core/websockets/resources/classes/subscriber.php +++ b/core/websockets/resources/classes/subscriber.php @@ -467,7 +467,7 @@ class subscriber { // Check for required fields if (empty($request_token)) { - $date = date('Y/m/d H:i:s', time()); + //$date = date('Y/m/d H:i:s', time()); //self::$logger->warn("Empty token given for $this->id"); return false; } @@ -500,19 +500,6 @@ class subscriber { $valid = $valid && (time() - $token_time < $token_limit * 60); // token_time_limit * 60 seconds = 15 minutes } - // Debug information - if (true) { - //self::$logger->debug("------------------ Authenticate Token Compare ------------------"); - //self::$logger->debug(" Subscriber token name: ".$request_token['name']); - //self::$logger->debug(" Subscriber token hash: ".$request_token['hash']); - //self::$logger->debug(" Server token name: $token_name"); - //self::$logger->debug(" Server token hash: $token_hash"); - //self::$logger->debug(" Server token time: $token_time"); - //self::$logger->debug(" Server token limit: $token_limit"); - //self::$logger->debug("Valid: " . ($valid ? 'yes' : 'no')); - //self::$logger->debug("----------------------------------------------------------------"); - } - // When token is valid if ($valid) { @@ -855,16 +842,10 @@ class subscriber { * @return bool True if the token has expired. False if the token is still valid */ public function token_time_exceeded(): bool { - if (!$this->enable_token_time_limit) + if (!$this->enable_token_time_limit) { return false; + } - //self::$logger->debug("------------- TOKEN TIME LIMIT -------------"); - //self::$logger->debug(" Token Limit: $this->token_limit"); - //self::$logger->debug(" Token Time: $this->token_time"); - //self::$logger->debug(" Current Time: " . time()); - //self::$logger->debug("time-token_time: " . (time() - $this->token_time)); - //self::$logger->debug(" Time Exceeded: " . ((time() - $this->token_time) > $this->token_limit ? 'Yes' : 'No')); - //self::$logger->debug("--------------------------------------------"); //test the time on the token to ensure it is valid return (time() - $this->token_time) > $this->token_limit; } diff --git a/core/websockets/resources/classes/websocket_service.php b/core/websockets/resources/classes/websocket_service.php index c1fd3d288e..1989a9218a 100644 --- a/core/websockets/resources/classes/websocket_service.php +++ b/core/websockets/resources/classes/websocket_service.php @@ -711,19 +711,19 @@ class websocket_service extends service { @fclose($resource); } - $this->debug("OLD Client List: " . var_dump($this->clients, true)); + //$this->debug("OLD Client List: " . var_dump($this->clients, true)); // Clean out the array $clients = array_filter($this->clients, function ($resource) { return is_resource($resource) && !feof($resource); }); - $this->debug("NEW Client List: " . var_dump($clients, true)); + //$this->debug("NEW Client List: " . var_dump($clients, true)); // Compare to the original array $diff = array_diff($this->clients, $clients); - $this->debug("DIFF Client List: " . var_dump($diff, true)); + //$this->debug("DIFF Client List: " . var_dump($diff, true)); // Replace the old list with only the connected ones $this->clients = $clients;