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,5 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace common\tasks;
|
||||
|
||||
use common\emails\EmailHelper;
|
||||
@@ -34,11 +35,11 @@ class SendRegistrationEmail 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;
|
||||
}
|
||||
|
||||
@@ -48,10 +49,10 @@ class SendRegistrationEmail implements RetryableJobInterface {
|
||||
*/
|
||||
public function execute($queue) {
|
||||
Yii::$app->statsd->inc('queue.sendRegistrationEmail.attempt');
|
||||
$params = new RegistrationEmailParams($this->username, $this->code, $this->link);
|
||||
$to = EmailHelper::buildTo($this->username, $this->email);
|
||||
$template = new RegistrationEmail($to, $this->locale, $params, Yii::$app->emailsRenderer);
|
||||
$template->send();
|
||||
$template = new RegistrationEmail(Yii::$app->mailer, Yii::$app->emailsRenderer);
|
||||
$template->setLocale($this->locale);
|
||||
$template->setParams(new RegistrationEmailParams($this->username, $this->code, $this->link));
|
||||
$template->send(EmailHelper::buildTo($this->username, $this->email));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user