mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Mail listeners to harvest message ids
This commit is contained in:
parent
e8d40d2fde
commit
c72fcfed64
@ -23,8 +23,8 @@ class ConnectedAccountController extends BaseController
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the data feed with the current Company User.
|
||||
/**
|
||||
* Connect an OAuth account to a regular email/password combination account
|
||||
*
|
||||
* @param Request $request
|
||||
* @return User Refresh Feed.
|
||||
|
@ -105,7 +105,7 @@ class EmailEntity implements ShouldQueue
|
||||
MultiDB::setDB($this->company->db);
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new TemplateEmail($this->email_entity_builder,$this->invitation->contact);
|
||||
$nmo->mailable = new TemplateEmail($this->email_entity_builder,$this->invitation->contact, $this->invitation);
|
||||
$nmo->company = $this->company;
|
||||
$nmo->settings = $this->settings;
|
||||
$nmo->to_user = $this->invitation->contact;
|
||||
|
47
app/Listeners/Mail/MailSentListener.php
Normal file
47
app/Listeners/Mail/MailSentListener.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Listeners\Mail;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Mail\Events\MessageSent;
|
||||
|
||||
class MailSentListener implements ShouldQueue
|
||||
{
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param object $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(MessageSent $event)
|
||||
{
|
||||
//MultiDB::setDb($event->company->db);
|
||||
//$postmark_id = $message->getHeaders()->get('x-pm-message-id')->getValue();
|
||||
|
||||
if(property_exists($event->message, 'invitation')){
|
||||
nlog($event->message->invitation);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -31,6 +31,8 @@ class BaseEmailEngine implements EngineInterface
|
||||
|
||||
public $text;
|
||||
|
||||
public $invitation;
|
||||
|
||||
public function setFooter($footer)
|
||||
{
|
||||
$this->footer = $footer;
|
||||
@ -141,4 +143,15 @@ class BaseEmailEngine implements EngineInterface
|
||||
public function build()
|
||||
{
|
||||
}
|
||||
|
||||
public function setInvitation($invitation)
|
||||
{
|
||||
$this->invitation = $invitation;
|
||||
}
|
||||
|
||||
public function getInvitation()
|
||||
{
|
||||
return $this->invitation;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,8 @@ class CreditEmailEngine extends BaseEmailEngine
|
||||
->setBody($body_template)
|
||||
->setFooter("<a href='{$this->invitation->getLink()}'>".ctrans('texts.view_credit').'</a>')
|
||||
->setViewLink($this->invitation->getLink())
|
||||
->setViewText(ctrans('texts.view_credit'));
|
||||
->setViewText(ctrans('texts.view_credit'))
|
||||
->setInvitation($this->invitation);
|
||||
|
||||
if ($this->client->getSetting('pdf_email_attachment') !== false) {
|
||||
$this->setAttachments(['path' => $this->credit->pdf_file_path(), 'name' => basename($this->credit->pdf_file_path())]);
|
||||
|
@ -94,7 +94,8 @@ class InvoiceEmailEngine extends BaseEmailEngine
|
||||
->setBody($body_template)
|
||||
->setFooter("<a href='{$this->invitation->getLink()}'>".ctrans('texts.view_invoice').'</a>')
|
||||
->setViewLink($this->invitation->getLink())
|
||||
->setViewText(ctrans('texts.view_invoice'));
|
||||
->setViewText(ctrans('texts.view_invoice'))
|
||||
->setInvitation($this->invitation);
|
||||
|
||||
if ($this->client->getSetting('pdf_email_attachment') !== false) {
|
||||
$this->setAttachments([$this->invoice->pdf_file_path()]);
|
||||
|
@ -85,7 +85,9 @@ class QuoteEmailEngine extends BaseEmailEngine
|
||||
->setBody($body_template)
|
||||
->setFooter("<a href='{$this->invitation->getLink()}'>".ctrans('texts.view_quote').'</a>')
|
||||
->setViewLink($this->invitation->getLink())
|
||||
->setViewText(ctrans('texts.view_quote'));
|
||||
->setViewText(ctrans('texts.view_quote'))
|
||||
->setInvitation($this->invitation);
|
||||
|
||||
|
||||
if ($this->client->getSetting('pdf_email_attachment') !== false) {
|
||||
// $this->setAttachments([$this->quote->pdf_file_path()]);
|
||||
|
@ -29,7 +29,9 @@ class TemplateEmail extends Mailable
|
||||
|
||||
private $company;
|
||||
|
||||
public function __construct($build_email, ClientContact $contact)
|
||||
private $invitation;
|
||||
|
||||
public function __construct($build_email, ClientContact $contact, $invitation = null)
|
||||
{
|
||||
$this->build_email = $build_email;
|
||||
|
||||
@ -38,6 +40,8 @@ class TemplateEmail extends Mailable
|
||||
$this->client = $contact->client;
|
||||
|
||||
$this->company = $contact->company;
|
||||
|
||||
$this->invitation = $invitation;
|
||||
}
|
||||
|
||||
public function build()
|
||||
@ -77,6 +81,7 @@ class TemplateEmail extends Mailable
|
||||
])
|
||||
->withSwiftMessage(function ($message) use($company){
|
||||
$message->getHeaders()->addTextHeader('Tag', $company->company_key);
|
||||
$message->invitation = $this->invitation;
|
||||
});
|
||||
|
||||
//conditionally attach files
|
||||
|
@ -136,6 +136,7 @@ use App\Listeners\Invoice\InvoiceRestoredActivity;
|
||||
use App\Listeners\Invoice\InvoiceReversedActivity;
|
||||
use App\Listeners\Invoice\InvoiceViewedActivity;
|
||||
use App\Listeners\Invoice\UpdateInvoiceActivity;
|
||||
use App\Listeners\Mail\MailSentListener;
|
||||
use App\Listeners\Misc\InvitationViewedListener;
|
||||
use App\Listeners\Payment\PaymentEmailFailureActivity;
|
||||
use App\Listeners\Payment\PaymentEmailedActivity;
|
||||
@ -157,6 +158,8 @@ use App\Listeners\User\RestoredUserActivity;
|
||||
use App\Listeners\User\UpdateUserLastLogin;
|
||||
use App\Listeners\User\UpdatedUserActivity;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Mail\Events\MessageSending;
|
||||
use Illuminate\Mail\Events\MessageSent;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
@ -166,6 +169,11 @@ class EventServiceProvider extends ServiceProvider
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
MessageSending::class =>[
|
||||
],
|
||||
MessageSent::class => [
|
||||
MailSentListener::class,
|
||||
],
|
||||
UserWasCreated::class => [
|
||||
CreatedUserActivity::class,
|
||||
SendVerificationNotification::class,
|
||||
|
Loading…
Reference in New Issue
Block a user