Fixed parentDomain bug

This commit is contained in:
Will Browning
2019-09-16 09:38:12 +01:00
parent 7b48390431
commit 6d81de50e4
3 changed files with 16 additions and 14 deletions

View File

@@ -81,24 +81,26 @@ class ReceiveEmail extends Command
})
->first();
$subdomain = substr($recipient['domain'], 0, strrpos($recipient['domain'], '.'.$parentDomain));
if ($parentDomain) {
$subdomain = substr($recipient['domain'], 0, strrpos($recipient['domain'], '.'.$parentDomain));
if ($subdomain === 'unsubscribe') {
$this->handleUnsubscribe($recipient);
continue;
}
$user = User::where('username', $subdomain)->first();
if (is_null($user)) {
// Check if this is a custom domain.
if ($customDomain = Domain::where('domain', $recipient['domain'])->first()) {
$user = $customDomain->user;
if ($subdomain === 'unsubscribe') {
$this->handleUnsubscribe($recipient);
continue;
}
// Check if this is an additional username.
if ($additionalUsername = AdditionalUsername::where('username', $subdomain)->first()) {
$user = $additionalUsername->user;
} else {
$user = User::where('username', $subdomain)->first();
}
}
if (!isset($user)) {
// Check if this is a custom domain.
if ($customDomain = Domain::where('domain', $recipient['domain'])->first()) {
$user = $customDomain->user;
}
// Check if this is a uuid generated alias.