diff --git a/app/Http/Controllers/MailController.php b/app/Http/Controllers/MailController.php index 8e5964c..359170e 100644 --- a/app/Http/Controllers/MailController.php +++ b/app/Http/Controllers/MailController.php @@ -71,13 +71,15 @@ function ($attribute, $value, $fail) { try { $key = Crypt::decryptString($key); $key = json_decode($key, true); - if (time() - $key['time'] < 300 && !empty($key['id'])) { + if (!empty($key['id'])) { $where[] = ['id', '>', $key['id']]; + } elseif (time() - $key['time'] < 300) { + $where[] = ['received_at', '>', Carbon::parse($key['time'])]; } else { - $where[] = ['received_at', '>', Carbon::now()]; + $where[] = ['received_at', '>', Carbon::now()->subSeconds(60)]; } } catch (\Throwable $th) { - return abort(400); + return abort(400, $th->getMessage()); } $new_email_list = Mail::where($where) @@ -125,11 +127,14 @@ public function put(Request $request) return abort(401); } + $to = strtolower($to); + $from = strtolower($from); + $mail = new Mail; $mail->from = $from; $mail->from_hash = hash('sha256', $from); - $mail->to = strtolower($to); + $mail->to = $to; $mail->to_hash = hash('sha256', $to); $mail->title = $title;