Browse Source

Update message_events.php

If row is empty use continue to skip rest of the work in the loop.
FusionPBX 1 year ago
parent
commit
5341bd128a
1 changed files with 12 additions and 11 deletions
  1. 12 11
      resources/service/message_events.php

+ 12 - 11
resources/service/message_events.php

@@ -137,6 +137,10 @@ description - message_events service
 		//decode the event into an array
 		//decode the event into an array
 		$array = json_decode($response['$'], true);
 		$array = json_decode($response['$'], true);
 
 
+		//initialize variable(s)
+		$user_uuid = '';
+		$message_type = 'sms';
+
 		//set variables from the event array
 		//set variables from the event array
 		$event_name = $array['Event-Name'];
 		$event_name = $array['Event-Name'];
 		$event_type = $array['event_type'];
 		$event_type = $array['event_type'];
@@ -148,10 +152,8 @@ description - message_events service
 		$to_user = $array['to_user'];
 		$to_user = $array['to_user'];
 		$to_host = $array['to_host'];
 		$to_host = $array['to_host'];
 		$from_sip_ip = $array['from_sip_ip'];
 		$from_sip_ip = $array['from_sip_ip'];
-		$to = $array['to'];
 		$message_content = $array['_body'];
 		$message_content = $array['_body'];
-		$message_type = 'sms';
-		$to = $to_user;
+		$to = $array['to_user'];
 
 
 		//if the message is from an external number don't relay the message
 		//if the message is from an external number don't relay the message
 		$from_command = "user_exists id ".$from_user." ".$from_host;
 		$from_command = "user_exists id ".$from_user." ".$from_host;
@@ -219,13 +221,12 @@ description - message_events service
 		$parameters['source_number'] = $source_number;
 		$parameters['source_number'] = $source_number;
 		$row = $database->select($sql, $parameters, 'row');
 		$row = $database->select($sql, $parameters, 'row');
 		//view_array($row, false);
 		//view_array($row, false);
-		if (is_array($row)) {
-			$domain_uuid = $row["domain_uuid"];
-			$provider_uuid = $row["provider_uuid"];
-			$destination_prefix = $row["destination_prefix"];
-			$destination_number = $row["destination_number"];
-		}
-		unset($parameters);
+		if (empty($row)) { continue; }
+		$domain_uuid = $row["domain_uuid"];
+		$provider_uuid = $row["provider_uuid"];
+		$destination_prefix = $row["destination_prefix"];
+		$destination_number = $row["destination_number"];
+		unset($parameters, $row);
 
 
 		//get the source and destination numbers
 		//get the source and destination numbers
 		$from = $destination_prefix.$destination_number;
 		$from = $destination_prefix.$destination_number;
@@ -248,7 +249,7 @@ description - message_events service
 		$parameters['domain_uuid'] = $domain_uuid;
 		$parameters['domain_uuid'] = $domain_uuid;
 		$row = $database->select($sql, $parameters, 'row');
 		$row = $database->select($sql, $parameters, 'row');
 		//view_array($row, false);
 		//view_array($row, false);
-		if (is_array($row)) {
+		if (!empty($row)) {
 			$user_uuid = $row["user_uuid"];
 			$user_uuid = $row["user_uuid"];
 		}
 		}
 		unset($parameters);
 		unset($parameters);