diff --git a/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php b/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php index 72bc1c78..7954a703 100644 --- a/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php +++ b/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php @@ -976,7 +976,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface $jo->requeue(); - // TODO: do we leave JO as assigned to rider? + $jo->clearRider(); // add event log $rider = $this->session->getRider(); @@ -987,6 +987,9 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface ->setRider($rider); $this->em->persist($event); + // set rider's active JO to null + $rider->setActiveJobOrder(); + $this->em->flush(); // send mqtt event @@ -997,6 +1000,13 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface ]; $this->mclient->sendEvent($jo, $payload); + // need to send another mqtt event saying rider is available + // to change icon on dashboard + $channel = 'rider/' . $rider->getID() . '/status'; + $rider_status = 'available'; + + $this->mclient->publish($channel, $rider_status); + return $data; }