diff --git a/src/Service/MQTTClient.php b/src/Service/MQTTClient.php index 8beebde5..12973116 100644 --- a/src/Service/MQTTClient.php +++ b/src/Service/MQTTClient.php @@ -43,18 +43,26 @@ class MQTTClient $new_sessions = []; $cust_user = $job_order->getCustomer()->getCustomerUser(); - if (!empty($cust_user)) { + if ($cust_user->isEmpty()) { $new_sessions = $cust_user->getMobileSessions(); } - $sessions = array_merge($legacy_sessions, $new_sessions); // TODO: make this more elegant since getPhoneNumber() might differ later on + // TODO: make this more elegant. looping through each instead of merging the two because doctrine returns PersistentCollection if empty, and array if not + $sessions = []; + foreach ($legacy_sessions as $sess) { + $sessions[] = $sess; + } - if (count($sessions) == 0) + foreach ($new_sessions as $sess) { + $sessions[] = $sess; + } + + if (empty($sessions)) { error_log("no sessions to send mqtt event to"); return; } - + $channels = []; // send to every customer session