Changeset View
Changeset View
Standalone View
Standalone View
src/app/Jobs/UserVerify.php
Show All 38 Lines | class UserVerify implements ShouldQueue | ||||
/** | /** | ||||
* Execute the job. | * Execute the job. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
// Verify a mailbox sku is among the user entitlements. | if (!$this->user->hasSku('mailbox')) { | ||||
$skuMailbox = \App\Sku::where('title', 'mailbox')->first(); | |||||
if (!$skuMailbox) { | |||||
return; | |||||
} | |||||
$mailbox = \App\Entitlement::where( | |||||
[ | |||||
'sku_id' => $skuMailbox->id, | |||||
'entitleable_id' => $this->user->id, | |||||
'entitleable_type' => User::class | |||||
] | |||||
)->first(); | |||||
if (!$mailbox) { | |||||
return; | return; | ||||
} | } | ||||
// The user has a mailbox | // The user has a mailbox | ||||
if (!$this->user->isImapReady()) { | if (!$this->user->isImapReady()) { | ||||
if (IMAP::verifyAccount($this->user->email)) { | if (IMAP::verifyAccount($this->user->email)) { | ||||
$this->user->status |= User::STATUS_IMAP_READY; | $this->user->status |= User::STATUS_IMAP_READY; | ||||
$this->user->status |= User::STATUS_ACTIVE; | $this->user->status |= User::STATUS_ACTIVE; | ||||
$this->user->save(); | $this->user->save(); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } |