mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Refactor emails models objects, rework related tests
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace common\tasks;
|
||||
|
||||
use common\emails\EmailHelper;
|
||||
use common\emails\templates\ChangeEmailConfirmCurrentEmail;
|
||||
use common\emails\templates\ChangeEmail;
|
||||
use common\models\confirmations\CurrentEmailConfirmation;
|
||||
use Yii;
|
||||
use yii\queue\RetryableJobInterface;
|
||||
@@ -25,22 +26,23 @@ class SendCurrentEmailConfirmation implements RetryableJobInterface {
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getTtr() {
|
||||
public function getTtr(): int {
|
||||
return 30;
|
||||
}
|
||||
|
||||
public function canRetry($attempt, $error) {
|
||||
public function canRetry($attempt, $error): bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \yii\queue\Queue $queue
|
||||
* @throws \common\emails\exceptions\CannotSendEmailException
|
||||
*/
|
||||
public function execute($queue) {
|
||||
Yii::$app->statsd->inc('queue.sendCurrentEmailConfirmation.attempt');
|
||||
$to = EmailHelper::buildTo($this->username, $this->email);
|
||||
$template = new ChangeEmailConfirmCurrentEmail($to, $this->code);
|
||||
$template->send();
|
||||
$template = new ChangeEmail(Yii::$app->mailer);
|
||||
$template->setKey($this->code);
|
||||
$template->send(EmailHelper::buildTo($this->username, $this->email));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user