Add notification sending when rider rejects JO #472
This commit is contained in:
parent
0bd968d753
commit
01f5717c1c
3 changed files with 18 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue