Explorar el Código

update: remind mail i18n

tokumeikoi hace 3 años
padre
commit
2d5fb03937

+ 3 - 16
app/Console/Commands/SendRemindMail.php

@@ -2,6 +2,7 @@
 
 namespace App\Console\Commands;
 
+use App\Services\MailService;
 use Illuminate\Console\Command;
 use App\Models\User;
 use App\Models\MailLog;
@@ -41,23 +42,9 @@ class SendRemindMail extends Command
     public function handle()
     {
         $users = User::all();
+        $mailService = new MailService();
         foreach ($users as $user) {
-            if ($user->remind_expire) $this->remindExpire($user);
-        }
-    }
-
-    private function remindExpire($user)
-    {
-        if ($user->expired_at !== NULL && ($user->expired_at - 86400) < time() && $user->expired_at > time()) {
-            SendEmailJob::dispatch([
-                'email' => $user->email,
-                'subject' => '在' . config('v2board.app_name', 'V2board') . '的服务即将到期',
-                'template_name' => 'remindExpire',
-                'template_value' => [
-                    'name' => config('v2board.app_name', 'V2Board'),
-                    'url' => config('v2board.app_url')
-                ]
-            ]);
+            if ($user->remind_expire) $mailService->remindExpire($user);
         }
     }
 }

+ 16 - 0
app/Services/MailService.php

@@ -29,6 +29,22 @@ class MailService
         ]);
     }
 
+    public function remindExpire(User $user)
+    {
+        if ($user->expired_at !== NULL && ($user->expired_at - 86400) < time() && $user->expired_at > time()) return;
+        SendEmailJob::dispatch([
+            'email' => $user->email,
+            'subject' => __('The service in :app_name is about to expire', [
+               'app_name' =>  config('v2board.app_name', 'V2board')
+            ]),
+            'template_name' => 'remindExpire',
+            'template_value' => [
+                'name' => config('v2board.app_name', 'V2Board'),
+                'url' => config('v2board.app_url')
+            ]
+        ]);
+    }
+
     private function remindTrafficIsWarnValue($u, $d, $transfer_enable)
     {
         $ud = $u + $d;

+ 2 - 1
resources/lang/en-US.json

@@ -83,5 +83,6 @@
     "Email can not be empty": "Email can not be empty",
     "Email format is incorrect": "Email format is incorrect",
     "Password can not be empty": "Password can not be empty",
-    "The traffic usage in :app_name has reached 80%": "The traffic usage in :app has reached 80%"
+    "The traffic usage in :app_name has reached 80%": "The traffic usage in :app_name has reached 80%",
+    "The service in :app_name is about to expire": "The service in :app_name is about to expire"
 }

+ 2 - 1
resources/lang/zh-CN.json

@@ -83,5 +83,6 @@
     "Email can not be empty": "邮箱不能为空",
     "Email format is incorrect": "邮箱格式不正确",
     "Password can not be empty": "密码不能为空",
-    "The traffic usage in :app_name has reached 80%": "在:app的流量使用已达到80%"
+    "The traffic usage in :app_name has reached 80%": "在:app_name的流量使用已达到80%",
+    "The service in :app_name is about to expire": "在:app_name的服务即将到期"
 }