mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 17:34:30 -04:00
Update postmark to only update existing records with message IDs
This commit is contained in:
parent
33c8c713b1
commit
28f3de3f28
@ -56,6 +56,23 @@ class ProcessPostmarkWebhook implements ShouldQueue
|
||||
{
|
||||
}
|
||||
|
||||
private function getSystemLog(string $message_id): ?SystemLog
|
||||
{
|
||||
return SystemLog::query()
|
||||
->where('company_id', $this->invitation->company_id)
|
||||
->where('type_id', SystemLog::TYPE_WEBHOOK_RESPONSE)
|
||||
->whereJsonContains('log', ['MessageID' => $message_id])
|
||||
->orderBy('id','desc')
|
||||
->first();
|
||||
|
||||
}
|
||||
|
||||
private function updateSystemLog(SystemLog $system_log, array $data): void
|
||||
{
|
||||
$system_log->log = $data;
|
||||
$system_log->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
@ -135,6 +152,13 @@ class ProcessPostmarkWebhook implements ShouldQueue
|
||||
|
||||
$data = array_merge($this->request, ['history' => $this->fetchMessage()]);
|
||||
|
||||
$sl = $this->getSystemLog($this->request['MessageID']);
|
||||
|
||||
if($sl){
|
||||
$this->updateSystemLog($sl, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
(new SystemLogger(
|
||||
$data,
|
||||
SystemLog::CATEGORY_MAIL,
|
||||
@ -166,6 +190,13 @@ class ProcessPostmarkWebhook implements ShouldQueue
|
||||
|
||||
$data = array_merge($this->request, ['history' => $this->fetchMessage()]);
|
||||
|
||||
$sl = $this->getSystemLog($this->request['MessageID']);
|
||||
|
||||
if($sl) {
|
||||
$this->updateSystemLog($sl, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
(new SystemLogger(
|
||||
$data,
|
||||
SystemLog::CATEGORY_MAIL,
|
||||
@ -217,6 +248,13 @@ class ProcessPostmarkWebhook implements ShouldQueue
|
||||
|
||||
$data = array_merge($this->request, ['history' => $this->fetchMessage()]);
|
||||
|
||||
$sl = $this->getSystemLog($this->request['MessageID']);
|
||||
|
||||
if($sl) {
|
||||
$this->updateSystemLog($sl, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
(new SystemLogger($data, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_BOUNCED, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company))->handle();
|
||||
|
||||
// if(config('ninja.notification.slack'))
|
||||
@ -263,6 +301,13 @@ class ProcessPostmarkWebhook implements ShouldQueue
|
||||
|
||||
$data = array_merge($this->request, ['history' => $this->fetchMessage()]);
|
||||
|
||||
$sl = $this->getSystemLog($this->request['MessageID']);
|
||||
|
||||
if($sl) {
|
||||
$this->updateSystemLog($sl, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
(new SystemLogger($data, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_SPAM_COMPLAINT, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company))->handle();
|
||||
|
||||
if (config('ninja.notification.slack')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user