Resolve "CMB - rider realtime not displaying" #1387

Closed
jankstudio wants to merge 86 commits from 489-cmb-rider-realtime-not-displaying into master
3 changed files with 18 additions and 2 deletions
Showing only changes of commit 01f5717c1c - Show all commits

View file

@ -61,6 +61,12 @@ class Notification
*/
protected $flag_fresh;
public function __construct()
{
$this->flag_read = false;
$this->flag_fresh = true;
}
public function getID()
{
return $this->id;

View file

@ -22,7 +22,7 @@ class NotificationManager
}
// set user_id to 0 for all
public function sendNotification($user_id, $msg)
public function sendNotification($user_id, $msg, $url)
{
// send mqtt
$chan = $this->getChannel($user_id);
@ -31,6 +31,10 @@ class NotificationManager
// create notif
$notif = new Notification();
$notif->setUserID($user_id)
->setIcon('')
->setMessage($msg)
->setURL($url);
// save to db
$this->em->persist($notif);

View file

@ -23,6 +23,7 @@ use App\Service\WarrantyHandler;
use App\Service\JobOrderHandlerInterface;
use App\Service\InvoiceGeneratorInterface;
use App\Service\RiderTracker;
use App\Service\NotificationManager;
use App\Entity\RiderSession;
use App\Entity\Rider;
@ -53,13 +54,14 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
protected $ic;
protected $session;
protected $upload_dir;
protected $nm;
public function __construct(EntityManagerInterface $em, RedisClientProvider $redis,
EncoderFactoryInterface $ef, RiderCache $rcache,
string $country_code, MQTTClient $mclient,
WarrantyHandler $wh, JobOrderHandlerInterface $jo_handler,
InvoiceGeneratorInterface $ic, string $upload_dir,
RiderTracker $rider_tracker)
RiderTracker $rider_tracker, NotificationManager $nm)
{
$this->em = $em;
$this->redis = $redis;
@ -72,6 +74,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$this->ic = $ic;
$this->upload_dir = $upload_dir;
$this->rider_tracker = $rider_tracker;
$this->nm = $nm;
// one device = one session, since we have control over the devices
// when a rider logs in, we just change the rider assigned to the device
@ -1154,6 +1157,9 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$this->mclient->publish($channel, $rider_status);
$notif_url = $this->generateUrl('jo_onestep_edit_form', ['id' => $jo->getID()]);
$this->nm->sendNotification(0, 'Job order has been rejected by rider.', $notif_url);
return $data;
}