2019-05-29 06:33:53 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-29 06:33:53 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2021-01-03 22:54:54 +01:00
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-29 06:33:53 +02:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Jobs\Invitation;
|
|
|
|
|
|
|
|
use App\Utils\Traits\NumberFormatter;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
|
2019-12-27 01:28:36 +01:00
|
|
|
//todo - ensure we are MultiDB Aware in dispatched jobs
|
|
|
|
|
2019-05-29 06:33:53 +02:00
|
|
|
class MarkOpened implements ShouldQueue
|
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, NumberFormatter;
|
|
|
|
|
|
|
|
public $message_id;
|
|
|
|
|
|
|
|
public $entity;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new job instance.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param string $message_id
|
|
|
|
* @param string $entity
|
2019-05-29 06:33:53 +02:00
|
|
|
*/
|
|
|
|
public function __construct(string $message_id, string $entity)
|
|
|
|
{
|
|
|
|
$this->message_id = $message_id;
|
|
|
|
|
|
|
|
$this->entity = $entity;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*
|
2019-12-30 22:59:12 +01:00
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @return false
|
2019-05-29 06:33:53 +02:00
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$invitation = $this->entity::with('user', 'contact')
|
|
|
|
->whereMessageId($this->message_id)
|
|
|
|
->first();
|
|
|
|
|
|
|
|
if (! $invitation) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-02-20 22:05:01 +01:00
|
|
|
$invitation->opened_date = now();
|
|
|
|
//$invitation->email_error = $error;
|
2019-05-29 06:33:53 +02:00
|
|
|
$invitation->save();
|
|
|
|
}
|
|
|
|
}
|