mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Set user in send invoice/quote activity
This commit is contained in:
parent
5293db2756
commit
430a0edbad
@ -405,7 +405,8 @@ class InvoiceController extends BaseController
|
||||
if ($invoice->is_recurring) {
|
||||
$response = $this->emailRecurringInvoice($invoice);
|
||||
} else {
|
||||
$this->dispatch(new SendInvoiceEmail($invoice, $reminder, $template));
|
||||
$userId = Auth::user()->id;
|
||||
$this->dispatch(new SendInvoiceEmail($invoice, $userId, $reminder, $template));
|
||||
$response = true;
|
||||
}
|
||||
|
||||
@ -437,7 +438,8 @@ class InvoiceController extends BaseController
|
||||
if ($invoice->isPaid()) {
|
||||
return true;
|
||||
} else {
|
||||
$this->dispatch(new SendInvoiceEmail($invoice));
|
||||
$userId = Auth::user()->id;
|
||||
$this->dispatch(new SendInvoiceEmail($invoice, $userId));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Monolog\Logger;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* Class SendInvoiceEmail.
|
||||
@ -31,6 +32,11 @@ class SendInvoiceEmail extends Job implements ShouldQueue
|
||||
*/
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $userId;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
@ -39,9 +45,10 @@ class SendInvoiceEmail extends Job implements ShouldQueue
|
||||
* @param bool $reminder
|
||||
* @param mixed $pdfString
|
||||
*/
|
||||
public function __construct(Invoice $invoice, $reminder = false, $template = false)
|
||||
public function __construct(Invoice $invoice, $userId = false, $reminder = false, $template = false)
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
$this->userId = $userId;
|
||||
$this->reminder = $reminder;
|
||||
$this->template = $template;
|
||||
}
|
||||
@ -53,7 +60,16 @@ class SendInvoiceEmail extends Job implements ShouldQueue
|
||||
*/
|
||||
public function handle(ContactMailer $mailer)
|
||||
{
|
||||
// send email as user
|
||||
if ($this->userId) {
|
||||
Auth::loginUsingId($this->userId);
|
||||
}
|
||||
|
||||
$mailer->sendInvoice($this->invoice, $this->reminder, $this->template);
|
||||
|
||||
if ($this->userId) {
|
||||
Auth::logout();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user