diff --git a/app/Controller/Api/V1/DownloadController.php b/app/Controller/Api/V1/DownloadController.php index bcd2925..1ba8f36 100644 --- a/app/Controller/Api/V1/DownloadController.php +++ b/app/Controller/Api/V1/DownloadController.php @@ -57,7 +57,7 @@ class DownloadController extends CController $user_id = $this->uid(); - //判断消息是否是当前用户发送(如果是则跳过权限验证) + // 判断消息是否是当前用户发送(如果是则跳过权限验证) if ($recordsInfo->user_id != $user_id) { if ($recordsInfo->source == 1) { if ($recordsInfo->receive_id != $user_id) { @@ -71,7 +71,7 @@ class DownloadController extends CController } $fileInfo = ChatRecordsFile::select(['save_dir', 'original_name'])->where('record_id', $params['cr_id'])->first(); - if (!$fileInfo) { + if (!$fileInfo || !file_exists($uploadService->driver($fileInfo->save_dir))) { return $this->response->fail('文件不存在或没有下载权限...'); } @@ -99,7 +99,7 @@ class DownloadController extends CController ->where('user_id', $this->uid()) ->first(); - if (!$info) { + if (!$info || !file_exists($uploadService->driver($info->save_dir))) { return $this->response->fail('文件不存在或没有下载权限...'); } diff --git a/app/Service/ContactsService.php b/app/Service/ContactsService.php index 623ac11..69de593 100644 --- a/app/Service/ContactsService.php +++ b/app/Service/ContactsService.php @@ -75,7 +75,12 @@ SQL; ->where('friend_id', $friend_id) ->orderBy('id', 'desc')->first(); - if (!$result) { + if ($result && $result->status == 0) { + $result->remarks = $remarks; + $result->updated_at = date('Y-m-d H:i:s'); + $result->save(); + return true; + } else { $result = UsersFriendsApply::create([ 'user_id' => $user_id, 'friend_id' => $friend_id, @@ -86,15 +91,7 @@ SQL; ]); return $result ? true : false; - } else if ($result->status == 0) { - $result->remarks = $remarks; - $result->updated_at = date('Y-m-d H:i:s'); - $result->save(); - - return true; } - - return false; } /**