diff --git a/app/Controller/Api/V1/CommonController.php b/app/Controller/Api/V1/CommonController.php index 6461b6e..0a8b1f2 100644 --- a/app/Controller/Api/V1/CommonController.php +++ b/app/Controller/Api/V1/CommonController.php @@ -19,12 +19,6 @@ use App\Service\UserService; */ class CommonController extends CController { - /** - * @Inject - * @var UserService - */ - private $userService; - /** * @Inject * @var SmsCodeService diff --git a/app/Controller/Api/V1/Talk/MessageController.php b/app/Controller/Api/V1/Talk/MessageController.php index 0a0458a..d2ff5ce 100644 --- a/app/Controller/Api/V1/Talk/MessageController.php +++ b/app/Controller/Api/V1/Talk/MessageController.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace App\Controller\Api\V1\Talk; use App\Cache\UnreadTalkCache; +use App\Constants\MediaTypeConstant; use App\Constants\TalkEventConstant; use App\Constants\TalkModeConstant; use App\Controller\Api\V1\CController; @@ -187,6 +188,12 @@ class MessageController extends CController } $save_dir = "private/files/talks/" . date('Ymd') . '/' . create_random_filename($file->file_ext); + $url = ""; + if (MediaTypeConstant::getMediaType($file->file_ext) <= 3) { + $save_dir = "public/media/" . date('Ymd') . '/' . create_random_filename($file->file_ext); + $url = get_media_url($save_dir); + } + try { $filesystem->copy($file->path, $save_dir); } catch (\Exception $e) { @@ -204,6 +211,7 @@ class MessageController extends CController 'suffix' => $file->file_ext, 'size' => $file->file_size, 'path' => $save_dir, + 'url' => $url, ]); if (!$isTrue) return $this->response->fail('文件发送失败!'); @@ -271,8 +279,6 @@ class MessageController extends CController if (!$emoticon) return $this->response->fail('表情不存在!'); - var_dump($emoticon->toArray()); - $isTrue = $this->talkMessageService->insertFile([ 'talk_type' => $params['talk_type'], 'user_id' => $user_id, diff --git a/app/Repository/Contact/ContactRepository.php b/app/Repository/Contact/ContactRepository.php index 3b5a537..7862d45 100644 --- a/app/Repository/Contact/ContactRepository.php +++ b/app/Repository/Contact/ContactRepository.php @@ -38,7 +38,7 @@ class ContactRepository extends BaseRepository 'contact.user_id' => $user_id, 'contact.status' => 1, 'join table' => [ - ['users', 'users.id', '=', 'contact.friend_id', 'left'], + ['users', 'users.id', '=', 'contact.friend_id', 'inner'], ] ], [ 'users.id',