diff --git a/app/Http/Controllers/MailController.php b/app/Http/Controllers/MailController.php index 84d774d..ca50af6 100644 --- a/app/Http/Controllers/MailController.php +++ b/app/Http/Controllers/MailController.php @@ -63,24 +63,31 @@ function ($attribute, $value, $fail) { return abort(400); } - $now_time = Carbon::now(); try { $key = Crypt::decryptString($key); + $key = Carbon::parse($key); } catch (\Throwable $th) { return abort(400); } - $key = Carbon::parse($key); - if ($key->diffInMinutes($now_time) > 5) { - $key = $now_time; - } + // $now_time = Carbon::now(); + // if ($key->diffInMinutes($now_time) > 5) { + // $key = $now_time; + // } $to_hash = hash('sha256', $email); + $max_received_at = Mail::where([ + ['to_hash', '=', $to_hash], + ['received_at', '>=', $key], + ]) + ->orderBy('received_at', 'desc') + ->value("received_at"); + $new_email_list = Mail::where([ ['to_hash', '=', $to_hash], - ['created_at', '>=', $key], + ['received_at', '>=', $key], ]) ->select([ 'id as key', @@ -102,7 +109,7 @@ function ($attribute, $value, $fail) { 'msg' => '', 'data' => [ 'list' => $new_email_list, - 'new_key' => Crypt::encryptString($now_time->format('Y-m-d H:i:s')), + 'new_key' => Crypt::encryptString(Carbon::parse($max_received_at)->format('Y-m-d H:i:s')), ], ]); } diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php index 85ecb82..e4cfe4b 100644 --- a/resources/views/welcome.blade.php +++ b/resources/views/welcome.blade.php @@ -193,7 +193,7 @@ function isValidDomain(domain) { console.log(domain); - var pattern = /^(?!:\/\/)([a-zA-Z0-9-]+\.)*[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[a-zA-Z]{2,11}?$/; + var pattern = /^(?!:\/\/)([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.[a-zA-Z]{2,11}$/; return pattern.test(domain); }