Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/UsersController.php
Show First 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | public static function statusInfo($user): array | ||||
] | ] | ||||
); | ); | ||||
// Check if the user is a controller of his wallet | // Check if the user is a controller of his wallet | ||||
$isController = $user->canDelete($user); | $isController = $user->canDelete($user); | ||||
$isDegraded = $user->isDegraded(); | $isDegraded = $user->isDegraded(); | ||||
$hasMeet = !$isDegraded && Sku::withObjectTenantContext($user)->where('title', 'room')->exists(); | $hasMeet = !$isDegraded && Sku::withObjectTenantContext($user)->where('title', 'room')->exists(); | ||||
// Enable all features if there are no skus for domain-hosting | |||||
$hasCustomDomain = $user->wallet()->entitlements() | $hasCustomDomain = $user->wallet()->entitlements() | ||||
->where('entitleable_type', Domain::class) | ->where('entitleable_type', Domain::class) | ||||
->count() > 0; | ->count() > 0 || !Sku::withObjectTenantContext($user)->where('title', 'domain-hosting')->exists(); | ||||
machniak: This should be `Sku::withObjectTenantContext($user)`. | |||||
// Get user's entitlements titles | // Get user's entitlements titles | ||||
$skus = $user->entitlements()->select('skus.title') | $skus = $user->entitlements()->select('skus.title') | ||||
->join('skus', 'skus.id', '=', 'entitlements.sku_id') | ->join('skus', 'skus.id', '=', 'entitlements.sku_id') | ||||
->get() | ->get() | ||||
->pluck('title') | ->pluck('title') | ||||
->sort() | ->sort() | ||||
->unique() | ->unique() | ||||
->values() | ->values() | ||||
->all(); | ->all(); | ||||
$hasBeta = in_array('beta', $skus); | $hasBeta = in_array('beta', $skus) || !Sku::withObjectTenantContext($user)->where('title', 'beta')->exists(); | ||||
Not Done Inline ActionsThis should be Sku::withObjectTenantContext($user). machniak: This should be `Sku::withObjectTenantContext($user)`. | |||||
$plan = $isController ? $user->wallet()->plan() : null; | $plan = $isController ? $user->wallet()->plan() : null; | ||||
$result = [ | $result = [ | ||||
'skus' => $skus, | 'skus' => $skus, | ||||
'enableBeta' => in_array('beta', $skus), | 'enableBeta' => $hasBeta, | ||||
// TODO: This will change when we enable all users to create domains | // TODO: This will change when we enable all users to create domains | ||||
'enableDomains' => $isController && $hasCustomDomain, | 'enableDomains' => $isController && $hasCustomDomain, | ||||
// TODO: Make 'enableDistlists' working for wallet controllers that aren't account owners | // TODO: Make 'enableDistlists' working for wallet controllers that aren't account owners | ||||
'enableDistlists' => $isController && $hasCustomDomain && $hasBeta, | 'enableDistlists' => $isController && $hasCustomDomain && $hasBeta, | ||||
'enableFiles' => !$isDegraded && $hasBeta && \config('app.with_files'), | 'enableFiles' => !$isDegraded && $hasBeta && \config('app.with_files'), | ||||
// TODO: Make 'enableFolders' working for wallet controllers that aren't account owners | // TODO: Make 'enableFolders' working for wallet controllers that aren't account owners | ||||
'enableFolders' => $isController && $hasCustomDomain && $hasBeta, | 'enableFolders' => $isController && $hasCustomDomain && $hasBeta, | ||||
// TODO: Make 'enableResources' working for wallet controllers that aren't account owners | // TODO: Make 'enableResources' working for wallet controllers that aren't account owners | ||||
▲ Show 20 Lines • Show All 510 Lines • Show Last 20 Lines |
This should be Sku::withObjectTenantContext($user).