mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-06 01:04:36 -04:00
Fixes for postmark delivery logging
This commit is contained in:
parent
72ad8915e9
commit
30defb6170
@ -1 +1 @@
|
||||
5.5.10
|
||||
5.5.11
|
@ -102,6 +102,17 @@ class NinjaMailerJob implements ShouldQueue
|
||||
|
||||
$this->nmo->mailable->tag($this->company->company_key);
|
||||
|
||||
if($this->nmo->invitation)
|
||||
{
|
||||
|
||||
$this->nmo
|
||||
->mailable
|
||||
->withSymfonyMessage(function ($message) {
|
||||
$message->getHeaders()->addTextHeader('x-invitation', $this->nmo->invitation->key);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//send email
|
||||
try {
|
||||
nlog("trying to send to {$this->nmo->to_user->email} ". now()->toDateTimeString());
|
||||
|
@ -26,6 +26,7 @@ use App\Models\Company;
|
||||
use App\Models\CreditInvitation;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PurchaseOrderInvitation;
|
||||
use App\Models\QuoteInvitation;
|
||||
use App\Models\RecurringInvoiceInvitation;
|
||||
use App\Models\SystemLog;
|
||||
@ -283,6 +284,8 @@ class ProcessPostmarkWebhook implements ShouldQueue
|
||||
return $invitation;
|
||||
elseif($invitation = CreditInvitation::where('message_id', $message_id)->first())
|
||||
return $invitation;
|
||||
elseif($invitation = PurchaseOrderInvitation::where('message_id', $message_id)->first())
|
||||
return $invitation;
|
||||
else
|
||||
return $invitation;
|
||||
}
|
||||
|
@ -12,9 +12,15 @@
|
||||
namespace App\Listeners\Mail;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\CreditInvitation;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Models\PurchaseOrderInvitation;
|
||||
use App\Models\QuoteInvitation;
|
||||
use App\Models\RecurringInvoiceInvitation;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Events\MessageSent;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Symfony\Component\Mime\MessageConverter;
|
||||
|
||||
class MailSentListener implements ShouldQueue
|
||||
{
|
||||
@ -35,19 +41,50 @@ class MailSentListener implements ShouldQueue
|
||||
*/
|
||||
public function handle(MessageSent $event)
|
||||
{
|
||||
nlog("mail listener");
|
||||
nlog($event);
|
||||
// if (property_exists($event->message, 'invitation') && $event->message->invitation) {
|
||||
// MultiDB::setDb($event->sent->invitation->company->db);
|
||||
|
||||
// if ($event->message->getHeaders()->get('x-pm-message-id')) {
|
||||
// $postmark_id = $event->sent->getHeaders()->get('x-pm-message-id')->getValue();
|
||||
$message_id = $event->sent->getMessageId();
|
||||
|
||||
$message = MessageConverter::toEmail($event->sent->getOriginalMessage());
|
||||
|
||||
$invitation_key = $message->getHeaders()->get('x-invitation')->getValue();
|
||||
|
||||
if($message_id && $invitation_key)
|
||||
{
|
||||
|
||||
$invitation = $this->discoverInvitation($invitation_key);
|
||||
|
||||
if(!$invitation)
|
||||
return;
|
||||
|
||||
$invitation->message_id = $message_id;
|
||||
$invitation->save();
|
||||
}
|
||||
|
||||
// // nlog($postmark_id);
|
||||
// $invitation = $event->sent->invitation;
|
||||
// $invitation->message_id = $postmark_id;
|
||||
// $invitation->save();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private function discoverInvitation($key)
|
||||
{
|
||||
|
||||
$invitation = false;
|
||||
|
||||
foreach (MultiDB::$dbs as $db)
|
||||
{
|
||||
|
||||
if($invitation = InvoiceInvitation::on($db)->where('key', $key)->first())
|
||||
return $invitation;
|
||||
elseif($invitation = QuoteInvitation::on($db)->where('key', $key)->first())
|
||||
return $invitation;
|
||||
elseif($invitation = RecurringInvoiceInvitation::on($db)->where('key', $key)->first())
|
||||
return $invitation;
|
||||
elseif($invitation = CreditInvitation::on($db)->where('key', $key)->first())
|
||||
return $invitation;
|
||||
elseif($invitation = PurchaseOrderInvitation::on($db)->where('key', $key)->first())
|
||||
return $invitation;
|
||||
|
||||
}
|
||||
|
||||
return $invitation;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -271,9 +271,9 @@ class EventServiceProvider extends ServiceProvider
|
||||
],
|
||||
MessageSending::class => [
|
||||
],
|
||||
// MessageSent::class => [
|
||||
// MailSentListener::class,
|
||||
// ],
|
||||
MessageSent::class => [
|
||||
MailSentListener::class,
|
||||
],
|
||||
UserWasCreated::class => [
|
||||
CreatedUserActivity::class,
|
||||
SendVerificationNotification::class,
|
||||
|
@ -14,8 +14,8 @@ return [
|
||||
'require_https' => env('REQUIRE_HTTPS', true),
|
||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||
'app_version' => '5.5.10',
|
||||
'app_tag' => '5.5.10',
|
||||
'app_version' => '5.5.11',
|
||||
'app_tag' => '5.5.11',
|
||||
'minimum_client_version' => '5.0.16',
|
||||
'terms_version' => '1.0.1',
|
||||
'api_secret' => env('API_SECRET', ''),
|
||||
|
Loading…
x
Reference in New Issue
Block a user