Skip to content

Commit

Permalink
deal better with empty payload
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed Sep 1, 2022
1 parent 0085b27 commit 713636f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/SparkPostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,19 +308,20 @@ protected function processPayload(array $payload, $batchId = null)
$subaccount = SparkPostHelper::getClient()->getSubaccount();

foreach ($payload as $r) {
// This is a test payload
if (empty($r) || empty($r['msys'])) {
continue;
}

$ev = $r['msys'] ?? null;

// Invalid payload
if ($ev === null) {
$logLevel = self::config()->log_level ? self::config()->log_level : 7;
$this->getLogger()->log("Invalid payload: " . substr(json_encode($r), 0, 100) . '...', $logLevel);
continue;
}

// This is a test payload
if (empty($ev)) {
continue;
}

$type = key($ev);
if (!isset($ev[$type])) {
$this->getLogger()->warn("Invalid type $type in SparkPost payload");
Expand Down

0 comments on commit 713636f

Please sign in to comment.