From 3e0cc65957ab4d50012fdee79dd196655dbed577 Mon Sep 17 00:00:00 2001 From: EasyChen Date: Sat, 29 Jan 2022 09:34:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E6=B3=A8=E5=86=8C=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=E5=8F=91=E9=80=81=E6=B6=88?= =?UTF-8?q?=E6=81=AF=EF=BC=8C=E6=98=BE=E7=A4=BA=E6=B3=A8=E5=86=8C=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PushDeerMessageController.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/api/app/Http/Controllers/PushDeerMessageController.php b/api/app/Http/Controllers/PushDeerMessageController.php index 7f073e1..024056b 100644 --- a/api/app/Http/Controllers/PushDeerMessageController.php +++ b/api/app/Http/Controllers/PushDeerMessageController.php @@ -62,7 +62,7 @@ class PushDeerMessageController extends Controller $key = PushDeerKey::where('key', $validated['pushkey'])->get()->first(); - $result = false; + $result = []; if ($key) { $readkey = Str::random(32); @@ -75,15 +75,17 @@ class PushDeerMessageController extends Controller $the_message['pushkey_name'] = $key->name; $pd_message = Message::create($the_message); - $devices = PushDeerDevice::where('uid', $key->uid)->get(); - - foreach ($devices as $device) { - if ($device) { - $func_name = $device['type'].'_send'; - if (function_exists($func_name)) { - $result[] = $func_name($device->is_clip, $device->device_id, $validated['text'], '', env('APP_DEBUG')); + if ($devices = PushDeerDevice::where('uid', $key->uid)->get()) { + foreach ($devices as $device) { + if ($device) { + $func_name = $device['type'].'_send'; + if (function_exists($func_name)) { + $result[] = $func_name($device->is_clip, $device->device_id, $validated['text'], '', env('APP_DEBUG')); + } } } + } else { + return send_error('没有可用的设备,请先注册', ErrorCode('ARGS')); } }