Page MenuHomePhorge

D4223.1775267316.diff
No OneTemporary

Authored By
Unknown
Size
7 KB
Referenced Files
None
Subscribers
None

D4223.1775267316.diff

diff --git a/src/app/Domain.php b/src/app/Domain.php
--- a/src/app/Domain.php
+++ b/src/app/Domain.php
@@ -191,24 +191,20 @@
return;
}
+ // if we have confirmed ownership of or management access to the domain, then we have
+ // also confirmed the domain exists in DNS.
if ($new_status & self::STATUS_CONFIRMED) {
- // 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;
+ $new_status |= self::STATUS_VERIFIED | 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;
+ // it can't be deleted-or-suspended and active
+ if ($new_status & self::STATUS_DELETED || $new_status & self::STATUS_SUSPENDED) {
+ $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;
+ if ($new_status & self::STATUS_ACTIVE) {
+ $new_status &= ~self::STATUS_NEW;
}
$this->attributes['status'] = $new_status;
diff --git a/src/app/Http/Controllers/RelationController.php b/src/app/Http/Controllers/RelationController.php
--- a/src/app/Http/Controllers/RelationController.php
+++ b/src/app/Http/Controllers/RelationController.php
@@ -108,7 +108,8 @@
$with_ldap = \config('app.with_ldap');
- $state['isReady'] = (!isset($state['isImapReady']) || $state['isImapReady'])
+ $state['isReady'] = (!isset($state['isActive']) || $state['isActive'])
+ && (!isset($state['isImapReady']) || $state['isImapReady'])
&& (!$with_ldap || !isset($state['isLdapReady']) || $state['isLdapReady'])
&& (!isset($state['isVerified']) || $state['isVerified'])
&& (!isset($state['isConfirmed']) || $state['isConfirmed']);
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
@@ -89,19 +89,8 @@
*/
public function restoring(Domain $domain)
{
- // Make sure it's not DELETED/LDAP_READY/SUSPENDED
- if ($domain->isDeleted()) {
- $domain->status ^= Domain::STATUS_DELETED;
- }
- if ($domain->isLdapReady()) {
- $domain->status ^= Domain::STATUS_LDAP_READY;
- }
- if ($domain->isSuspended()) {
- $domain->status ^= Domain::STATUS_SUSPENDED;
- }
- if ($domain->isConfirmed() && $domain->isVerified()) {
- $domain->status |= Domain::STATUS_ACTIVE;
- }
+ // Reset the status
+ $domain->status = Domain::STATUS_NEW;
// Note: $domain->save() is invoked between 'restoring' and 'restored' events
}
diff --git a/src/app/Observers/GroupObserver.php b/src/app/Observers/GroupObserver.php
--- a/src/app/Observers/GroupObserver.php
+++ b/src/app/Observers/GroupObserver.php
@@ -72,18 +72,8 @@
*/
public function restoring(Group $group)
{
- // Make sure it's not DELETED/LDAP_READY/SUSPENDED anymore
- if ($group->isDeleted()) {
- $group->status ^= Group::STATUS_DELETED;
- }
- if ($group->isLdapReady()) {
- $group->status ^= Group::STATUS_LDAP_READY;
- }
- if ($group->isSuspended()) {
- $group->status ^= Group::STATUS_SUSPENDED;
- }
-
- $group->status |= Group::STATUS_ACTIVE;
+ // Reset the status
+ $group->status = Group::STATUS_NEW;
// Note: $group->save() is invoked between 'restoring' and 'restored' events
}
diff --git a/src/app/Observers/UserObserver.php b/src/app/Observers/UserObserver.php
--- a/src/app/Observers/UserObserver.php
+++ b/src/app/Observers/UserObserver.php
@@ -140,21 +140,8 @@
*/
public function restoring(User $user)
{
- // Make sure it's not DELETED/LDAP_READY/IMAP_READY/SUSPENDED anymore
- if ($user->isDeleted()) {
- $user->status ^= User::STATUS_DELETED;
- }
- if ($user->isLdapReady()) {
- $user->status ^= User::STATUS_LDAP_READY;
- }
- if ($user->isImapReady()) {
- $user->status ^= User::STATUS_IMAP_READY;
- }
- if ($user->isSuspended()) {
- $user->status ^= User::STATUS_SUSPENDED;
- }
-
- $user->status |= User::STATUS_ACTIVE;
+ // Reset the status
+ $user->status = User::STATUS_NEW;
// Note: $user->save() is invoked between 'restoring' and 'restored' events
}
diff --git a/src/tests/Feature/DomainTest.php b/src/tests/Feature/DomainTest.php
--- a/src/tests/Feature/DomainTest.php
+++ b/src/tests/Feature/DomainTest.php
@@ -328,8 +328,9 @@
$this->assertFalse($domain->isDeleted());
$this->assertFalse($domain->isSuspended());
$this->assertFalse($domain->isLdapReady());
- $this->assertTrue($domain->isActive());
- $this->assertTrue($domain->isConfirmed());
+ $this->assertFalse($domain->isActive());
+ $this->assertFalse($domain->isConfirmed());
+ $this->assertTrue($domain->isNew());
// Assert entitlements
$this->assertTrue($ent2->fresh()->trashed());
diff --git a/src/tests/Feature/GroupTest.php b/src/tests/Feature/GroupTest.php
--- a/src/tests/Feature/GroupTest.php
+++ b/src/tests/Feature/GroupTest.php
@@ -163,11 +163,16 @@
Queue::fake();
$user = $this->getTestUser('user-test@kolabnow.com');
- $group = $this->getTestGroup('group-test@kolabnow.com');
+ $group = $this->getTestGroup('group-test@kolabnow.com', [
+ 'status' => Group::STATUS_ACTIVE | Group::STATUS_LDAP_READY | Group::STATUS_SUSPENDED,
+ ]);
$group->assignToWallet($user->wallets->first());
$entitlements = \App\Entitlement::where('entitleable_id', $group->id);
+ $this->assertTrue($group->isSuspended());
+ $this->assertTrue($group->isLdapReady());
+ $this->assertTrue($group->isActive());
$this->assertSame(1, $entitlements->count());
$group->delete();
@@ -185,7 +190,8 @@
$this->assertFalse($group->isDeleted());
$this->assertFalse($group->isSuspended());
$this->assertFalse($group->isLdapReady());
- $this->assertTrue($group->isActive());
+ $this->assertFalse($group->isActive());
+ $this->assertTrue($group->isNew());
$this->assertSame(1, $entitlements->count());
$entitlements->get()->each(function ($ent) {
diff --git a/src/tests/Feature/UserTest.php b/src/tests/Feature/UserTest.php
--- a/src/tests/Feature/UserTest.php
+++ b/src/tests/Feature/UserTest.php
@@ -1121,7 +1121,8 @@
$this->assertFalse($userA->isSuspended());
$this->assertFalse($userA->isLdapReady());
$this->assertFalse($userA->isImapReady());
- $this->assertTrue($userA->isActive());
+ $this->assertFalse($userA->isActive());
+ $this->assertTrue($userA->isNew());
$this->assertTrue($userB->fresh()->trashed());
$this->assertTrue($domainB->fresh()->trashed());

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 4, 1:48 AM (10 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18826138
Default Alt Text
D4223.1775267316.diff (7 KB)

Event Timeline