public function checkChatChannelRead($user, $channel)
{
$prefix = 'chat.channel.read.';
switch (strtolower($channel->type)) {
case 'public':
return 'ok';
case 'private':
$commonGroupIds = array_intersect($user->groupIds(), $channel->allowed_groups);
if (count($commonGroupIds) > 0) {
return 'ok';
}
break;
case 'spectator':
case 'multiplayer':
case 'temporary':
// this and the comparisons below are needed until bancho is updated to use the new channel types
if (starts_with($channel->name, '#spect_')) {
return 'ok';
}
if (starts_with($channel->name, '#mp_')) {
$matchId = intval(str_replace('#mp_', '', $channel->name));
if (in_array($user->user_id, MultiplayerMatch::findOrFail($matchId)->currentPlayers(), true)) {
return 'ok';
}
}
break;
}
return $prefix . 'no_access';
}