From 1c368c5aff20ca3d9a99ef6544cb9a7fc6f5eee4 Mon Sep 17 00:00:00 2001 From: Luca Andrea Rossi Date: Thu, 28 Oct 2021 11:10:25 +0200 Subject: [PATCH 1/3] Store email before calling the routes --- src/Routing/Router.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Routing/Router.php b/src/Routing/Router.php index 390d839..761eb49 100644 --- a/src/Routing/Router.php +++ b/src/Routing/Router.php @@ -84,6 +84,10 @@ protected function createRoute(string $subject, string $pattern, $action): Route public function callMailboxes(InboundEmail $email) { if ($email->isValid()) { + if ($this->shouldStoreInboundEmails() && $this->shouldStoreAllInboundEmails($matchedRoutes)) { + $this->storeEmail($email); + } + $matchedRoutes = $this->routes->match($email)->map(function (Route $route) use ($email) { $route->run($email); }); @@ -97,10 +101,6 @@ public function callMailboxes(InboundEmail $email) $matchedRoutes[] = $this->catchAllRoute; $this->catchAllRoute->run($email); } - - if ($this->shouldStoreInboundEmails() && $this->shouldStoreAllInboundEmails($matchedRoutes)) { - $this->storeEmail($email); - } } } From cb5811f78ec4c6b9bda0f8dc78f5eedceeea725f Mon Sep 17 00:00:00 2001 From: Luca Andrea Rossi Date: Thu, 28 Oct 2021 11:14:59 +0200 Subject: [PATCH 2/3] Update Router.php --- src/Routing/Router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Routing/Router.php b/src/Routing/Router.php index 761eb49..3751ad7 100644 --- a/src/Routing/Router.php +++ b/src/Routing/Router.php @@ -87,7 +87,7 @@ public function callMailboxes(InboundEmail $email) if ($this->shouldStoreInboundEmails() && $this->shouldStoreAllInboundEmails($matchedRoutes)) { $this->storeEmail($email); } - + $matchedRoutes = $this->routes->match($email)->map(function (Route $route) use ($email) { $route->run($email); }); From ed6eb8a792368d293da6cf3a50c54c6ff2e92981 Mon Sep 17 00:00:00 2001 From: Luca Andrea Rossi Date: Wed, 2 Feb 2022 14:26:15 +0100 Subject: [PATCH 3/3] Update Router.php --- src/Routing/Router.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Routing/Router.php b/src/Routing/Router.php index 3751ad7..1bc6a3b 100644 --- a/src/Routing/Router.php +++ b/src/Routing/Router.php @@ -84,11 +84,13 @@ protected function createRoute(string $subject, string $pattern, $action): Route public function callMailboxes(InboundEmail $email) { if ($email->isValid()) { + $matchedRoutes = $this->routes->match($email); + if ($this->shouldStoreInboundEmails() && $this->shouldStoreAllInboundEmails($matchedRoutes)) { $this->storeEmail($email); } - $matchedRoutes = $this->routes->match($email)->map(function (Route $route) use ($email) { + $matchedRoutes->map(function (Route $route) use ($email) { $route->run($email); });