diff --git a/app/Maildispatcher/Data/MailEntry.php b/app/Maildispatcher/Data/MailEntry.php index e54c7a3d..e51807bd 100644 --- a/app/Maildispatcher/Data/MailEntry.php +++ b/app/Maildispatcher/Data/MailEntry.php @@ -10,4 +10,9 @@ class MailEntry extends Data { $this->email = strtolower($email); } + + public function is(self $mailEntry): bool + { + return $this->email === $mailEntry->email; + } } diff --git a/app/Mailgateway/Types/Type.php b/app/Mailgateway/Types/Type.php index cab82bda..d1123215 100644 --- a/app/Mailgateway/Types/Type.php +++ b/app/Mailgateway/Types/Type.php @@ -79,8 +79,9 @@ abstract class Type */ public function sync(string $name, string $domain, Collection $results): void { + $members = $this->list($name, $domain); foreach ($results as $result) { - if ($this->search($name, $domain, $result->email)) { + if ($members->first(fn ($member) => $member->is($result))) { continue; } @@ -88,7 +89,7 @@ abstract class Type } $this->list($name, $domain) - ->filter(fn ($listEntry) => null === $results->first(fn ($r) => $r->email === $listEntry->email)) + ->filter(fn ($listEntry) => $results->doesntContain(fn ($r) => $r->is($listEntry))) ->each(fn ($listEntry) => $this->remove($name, $domain, $listEntry->email)); }