diff --git a/src/Service/MQTTClient.php b/src/Service/MQTTClient.php index ccf03839..f0ed72fa 100644 --- a/src/Service/MQTTClient.php +++ b/src/Service/MQTTClient.php @@ -40,9 +40,6 @@ class MQTTClient //error_log('sending mqtt event: '); //error_log(print_r($payload, true)); - // append jo id to payload - $payload['jo_id'] = $job_order->getID(); - // get all new and legacy mobile sessions $legacy_sessions = $job_order->getCustomer()->getMobileSessions(); @@ -84,14 +81,22 @@ class MQTTClient { $phone_num = $sess['data']->getPhoneNumber(); - // use appropriate prefix so we have different channel names for new api - $prefix = $sess['legacy'] ? self::PREFIX : self::PREFIX_APIv2; + $channel_payload = $payload; + + // keep channel and payload for legacy the same + if ($sess['legacy']) { + $prefix = self::PREFIX; + } else { + $prefix = self::PREFIX_APIv2; + $channel_payload['jo_id'] = $job_order->getID(); + } + $channel = $prefix . $phone_num; error_log("SENDING TO CHANNEL: " . $channel); // gather channels, so we only send once - $channels[$channel] = json_encode($payload); + $channels[$channel] = json_encode($channel_payload); } foreach ($channels as $channel => $json_payload)