Skip to content

Commit

Permalink
Move field check after confirming that body has been decoded to an ob…
Browse files Browse the repository at this point in the history
…ject.
  • Loading branch information
TheDoctor0 authored Sep 26, 2023
1 parent fc8f470 commit a0042b0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/App/Http/Controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,18 @@ public function handleRequest(ServerRequestInterface $request, string $type): mi
// At this point we have a valid SNS notification message.
$message = json_decode($body->Message);

if (!isset($message->eventType)) {
$message->eventType = $message->notificationType;
}

// The SES event notification has a Message property that should be a object when decoded.
if (!is_object($message)) {
Log::error('Result message failed to decode: '.json_last_error_msg());

return response()->json(['success' => false], 422);
}

// Handle notificationType field that can be present instead of eventType
if (!isset($message->eventType)) {
$message->eventType = $message->notificationType;
}

return $message;
}

Expand Down

0 comments on commit a0042b0

Please sign in to comment.