Changeset View
Changeset View
Standalone View
Standalone View
src/app/Domain.php
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | public function entitlement() | ||||
return $this->morphOne('App\Entitlement', 'entitleable'); | return $this->morphOne('App\Entitlement', 'entitleable'); | ||||
} | } | ||||
/** | /** | ||||
* Return list of public+active domain names (for current tenant) | * Return list of public+active domain names (for current tenant) | ||||
*/ | */ | ||||
public static function getPublicDomains(): array | public static function getPublicDomains(): array | ||||
{ | { | ||||
return self::withEnvTenant() | return self::withEnvTenantContext() | ||||
->whereRaw(sprintf('(type & %s)', Domain::TYPE_PUBLIC)) | ->whereRaw(sprintf('(type & %s)', Domain::TYPE_PUBLIC)) | ||||
->get(['namespace'])->pluck('namespace')->toArray(); | ->get(['namespace'])->pluck('namespace')->toArray(); | ||||
} | } | ||||
/** | /** | ||||
* Returns whether this domain is active. | * Returns whether this domain is active. | ||||
* | * | ||||
* @return bool | * @return bool | ||||
▲ Show 20 Lines • Show All 288 Lines • ▼ Show 20 Lines | public function unsuspend(): void | ||||
if ($this->isConfirmed() && $this->isVerified()) { | if ($this->isConfirmed() && $this->isVerified()) { | ||||
$this->status |= Domain::STATUS_ACTIVE; | $this->status |= Domain::STATUS_ACTIVE; | ||||
} | } | ||||
$this->save(); | $this->save(); | ||||
} | } | ||||
/** | /** | ||||
* List the users of a domain, so long as the domain is not a public registration domain. | |||||
* | |||||
* @return array | |||||
*/ | |||||
public function users(): array | |||||
{ | |||||
if ($this->isPublic()) { | |||||
return []; | |||||
} | |||||
$wallet = $this->wallet(); | |||||
if (!$wallet) { | |||||
return []; | |||||
} | |||||
$mailboxSKU = \App\Sku::withObjectTenantContext($this)->where('title', 'mailbox')->first(); | |||||
machniak: This query must have a tenant context. | |||||
if (!$mailboxSKU) { | |||||
\Log::error("No mailbox SKU available."); | |||||
return []; | |||||
} | |||||
$entitlements = $wallet->entitlements() | |||||
Done Inline ActionsThis will not list the "admin without mailbox" user. Just saying. machniak: This will not list the "admin without mailbox" user. Just saying. | |||||
->where('entitleable_type', \App\User::class) | |||||
->where('sku_id', $mailboxSKU->id)->get(); | |||||
$users = []; | |||||
foreach ($entitlements as $entitlement) { | |||||
$users[] = $entitlement->entitleable; | |||||
} | |||||
return $users; | |||||
} | |||||
/** | |||||
* Verify if a domain exists in DNS | * Verify if a domain exists in DNS | ||||
* | * | ||||
* @return bool True if registered, False otherwise | * @return bool True if registered, False otherwise | ||||
* @throws \Exception Throws exception on DNS or DB errors | * @throws \Exception Throws exception on DNS or DB errors | ||||
*/ | */ | ||||
public function verify(): bool | public function verify(): bool | ||||
{ | { | ||||
if ($this->isVerified()) { | if ($this->isVerified()) { | ||||
Show All 34 Lines |
This query must have a tenant context.