diff --git a/src/app/Domain.php b/src/app/Domain.php --- a/src/app/Domain.php +++ b/src/app/Domain.php @@ -250,6 +250,35 @@ throw new \Exception("Invalid domain status: {$status}"); } + if ($this->isPublic()) { + $this->attributes['status'] = $new_status; + return; + } + + if ($new_status & self::STATUS_CONFIRMED) { + if ($new_status & self::STATUS_VERIFIED) { + $new_status |= self::STATUS_ACTIVE; + } else { + // if we have confirmed ownership of or management access to the domain, then + // we have also confirmed the domain exists in DNS. + $new_status |= self::STATUS_VERIFIED; + $new_status |= self::STATUS_ACTIVE; + } + } + + if ($new_status & self::STATUS_DELETED && $new_status & self::STATUS_ACTIVE) { + $new_status ^= self::STATUS_ACTIVE; + } + + if ($new_status & self::STATUS_SUSPENDED && $new_status & self::STATUS_ACTIVE) { + $new_status ^= self::STATUS_ACTIVE; + } + + // if the domain is now active, it is not new anymore. + if ($new_status & self::STATUS_ACTIVE && $new_status & self::STATUS_NEW) { + $new_status ^= self::STATUS_NEW; + } + $this->attributes['status'] = $new_status; } diff --git a/src/app/Observers/DomainObserver.php b/src/app/Observers/DomainObserver.php --- a/src/app/Observers/DomainObserver.php +++ b/src/app/Observers/DomainObserver.php @@ -26,7 +26,7 @@ $domain->namespace = \strtolower($domain->namespace); - $domain->status |= Domain::STATUS_NEW | Domain::STATUS_ACTIVE; + $domain->status |= Domain::STATUS_NEW; } /**