<commit_before><?php

// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

namespace App\Http\Controllers;

use App\Libraries\Chat;
use App\Libraries\UserChannelList;
use App\Models\Chat\Channel;
use App\Models\Chat\Message;
use App\Models\User;
use Request;

class ChatController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');

        // TODO: notification server and chat client needs some updating
        // to handle verification_requirement_change properly.
        if (config('osu.user.post_action_verification')) {
            $this->middleware('verify-user');
        }

        return parent::__construct();
    }

    public function index()
    {
        $user = auth()->user();
        Chat::ack($user);

        $targetId = get_params(request()->all(), null, ['sendto:int'], ['null_missing' => true])['sendto'];
        // rejoin any existing channel first, otherwise it'll be missing from the preload later.
        $targetUser = $targetId !== null ? User::lookup($targetId, 'id') : null;
        if ($targetUser !== null) {
            $channel = Channel::findPM($targetUser, $user);
            $channel?->addUser($user);

            $sendToJson = [
                'can_message' => $channel?->canMessage($user) ?? priv_check('ChatPmStart', $targetUser),
                'channel_id' => $channel?->getKey(),
                'target' => json_item($targetUser, 'UserCompact'),
            ];
        }

        $json = [
            'last_message_id' => optional(Message::last())->getKey(),
            'presence' => (new UserChannelList($user))->get(),
        ];

        if (isset($sendToJson)) {
            $json['send_to'] = [
                'can_message' => $channel?->canMessage($user) ?? priv_check('ChatPmStart', $targetUser),
                'channel_id' => $channel?->getKey(),
                'target' => json_item($targetUser, 'UserCompact'),
            ];
        }

        return ext_view('chat.index', compact('json'));
    }
}
<commit_msg>unused<commit_after><?php

// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

namespace App\Http\Controllers;

use App\Libraries\Chat;
use App\Libraries\UserChannelList;
use App\Models\Chat\Channel;
use App\Models\Chat\Message;
use App\Models\User;

class ChatController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');

        // TODO: notification server and chat client needs some updating
        // to handle verification_requirement_change properly.
        if (config('osu.user.post_action_verification')) {
            $this->middleware('verify-user');
        }

        return parent::__construct();
    }

    public function index()
    {
        $user = auth()->user();
        Chat::ack($user);

        $targetId = get_params(request()->all(), null, ['sendto:int'], ['null_missing' => true])['sendto'];
        // rejoin any existing channel first, otherwise it'll be missing from the preload later.
        $targetUser = $targetId !== null ? User::lookup($targetId, 'id') : null;
        if ($targetUser !== null) {
            $channel = Channel::findPM($targetUser, $user);
            $channel?->addUser($user);

            $sendToJson = [
                'can_message' => $channel?->canMessage($user) ?? priv_check('ChatPmStart', $targetUser),
                'channel_id' => $channel?->getKey(),
                'target' => json_item($targetUser, 'UserCompact'),
            ];
        }

        $json = [
            'last_message_id' => optional(Message::last())->getKey(),
            'presence' => (new UserChannelList($user))->get(),
        ];

        if (isset($sendToJson)) {
            $json['send_to'] = [
                'can_message' => $channel?->canMessage($user) ?? priv_check('ChatPmStart', $targetUser),
                'channel_id' => $channel?->getKey(),
                'target' => json_item($targetUser, 'UserCompact'),
            ];
        }

        return ext_view('chat.index', compact('json'));
    }
}

{'fraction_non_alphanumeric': 0.15447726207219878, 'fraction_numerical': 0.0009376465072667605, 'mean_word_length': 2.4946764946764945, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4110009', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1203, 'n_words': 272}