the browser-facing portion of osu!
at master 1.5 kB view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6namespace App\Http\Controllers\Chat\Channels; 7 8use App\Http\Controllers\Chat\Controller; 9use App\Models\Chat\Channel; 10use App\Models\Chat\UserChannel; 11use App\Models\User; 12use App\Transformers\UserCompactTransformer; 13 14class UsersController extends Controller 15{ 16 public function index($channelId) 17 { 18 $channel = Channel::findOrFail($channelId); 19 20 if (!priv_check('ChatChannelListUsers', $channel)->can()) { 21 return [ 22 'users' => [], 23 ...cursor_for_response(null), 24 ]; 25 } 26 27 $channel = Channel::findOrFail($channelId); 28 $cursorHelper = UserChannel::makeDbCursorHelper(); 29 [$userChannels, $hasMore] = $channel 30 ->userChannels() 31 ->select('user_id') 32 ->limit(UserChannel::PER_PAGE) 33 ->cursorSort($cursorHelper, cursor_from_params(\Request::all())) 34 ->getWithHasMore(); 35 $users = User 36 ::with(UserCompactTransformer::CARD_INCLUDES_PRELOAD) 37 ->find($userChannels->pluck('user_id')); 38 39 return [ 40 'users' => json_collection( 41 $users, 42 new UserCompactTransformer(), 43 UserCompactTransformer::CARD_INCLUDES, 44 ), 45 ...cursor_for_response($cursorHelper->next($userChannels, $hasMore)), 46 ]; 47 } 48}