<commit_before><?php

namespace Coyote\Providers;

use Coyote\Http\Factories\CacheFactory;
use Coyote\User;
use Illuminate\Contracts\View\View;
use Illuminate\Support\ServiceProvider;
use Coyote\Repositories\Contracts\ForumRepositoryInterface;
use Coyote\Repositories\Criteria\Forum\AccordingToUserOrder;
use Coyote\Repositories\Criteria\Forum\OnlyThoseWithAccess;
use Lavary\Menu\Builder;
use Lavary\Menu\Menu;
use Lcobucci\JWT\Signer\Hmac\Sha256;
use Lcobucci\JWT\Signer\Key;

class ViewServiceProvider extends ServiceProvider
{
    use CacheFactory;

    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        $this->app['view']->composer(['layout', 'adm.home'], function (View $view) {
            $this->registerPublicData();
            $this->registerWebSocket();

            $guestId = $this->app['session']->get('guest_id');

            $view->with([
                '__public' => json_encode($this->app['request']->attributes->all()),
                '__master_menu' => $this->buildMasterMenu(),

                '__dark_theme' => $this->app['setting']->getItem('dark.theme', $guestId)
            ]);
        });
    }

    private function registerWebSocket()
    {
        if (config('services.ws.host') && $this->app['request']->user()) {
            $this->app['request']->attributes->set(
                'ws',
                (config('services.ws.proxy') ?: config('services.ws.host')) . (config('services.ws.port') ? ':' . config('services.ws.port') : '')
            );
        }
    }

    private function registerPublicData()
    {
        $this->app['request']->attributes->add([
            'public'        => route('home'),
            'cdn'           => config('app.cdn') ? ('//' . config('app.cdn')) : route('home'),
            'ping_interval' => config('session.lifetime') - 5, // every 10 minutes
            'notifications_unread' => 0,
            'pm_unread'     => 0
        ]);

        if (!empty($this->app['request']->user())) {
            $user = $this->app['request']->user();

            $this->app['request']->attributes->add([
                'token' => $this->getJWtToken($user),
                'notifications_unread' => $user->notifications_unread,
                'pm_unread' => $user->pm_unread
            ]);
        }<commit_msg>powrot do poprzedniego tokena<commit_after><?php

namespace Coyote\Providers;

use Coyote\Http\Factories\CacheFactory;
use Coyote\User;
use Illuminate\Contracts\View\View;
use Illuminate\Support\ServiceProvider;
use Coyote\Repositories\Contracts\ForumRepositoryInterface;
use Coyote\Repositories\Criteria\Forum\AccordingToUserOrder;
use Coyote\Repositories\Criteria\Forum\OnlyThoseWithAccess;
use Lavary\Menu\Builder;
use Lavary\Menu\Menu;
use Lcobucci\JWT\Signer\Hmac\Sha256;
use Lcobucci\JWT\Signer\Key;
use Illuminate\Contracts\Encryption\Encrypter;

class ViewServiceProvider extends ServiceProvider
{
    use CacheFactory;

    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        $this->app['view']->composer(['layout', 'adm.home'], function (View $view) {
            $this->registerPublicData();
            $this->registerWebSocket();

            $guestId = $this->app['session']->get('guest_id');

            $view->with([
                '__public' => json_encode($this->app['request']->attributes->all()),
                '__master_menu' => $this->buildMasterMenu(),

                '__dark_theme' => $this->app['setting']->getItem('dark.theme', $guestId)
            ]);
        });
    }

    private function registerWebSocket()
    {
        if (config('services.ws.host') && $this->app['request']->user()) {
            $this->app['request']->attributes->set(
                'ws',
                (config('services.ws.proxy') ?: config('services.ws.host')) . (config('services.ws.port') ? ':' . config('services.ws.port') : '')
            );
        }
    }

    private function registerPublicData()
    {
        $this->app['request']->attributes->add([
            'public'        => route('home'),
            'cdn'           => config('app.cdn') ? ('//' . config('app.cdn')) : route('home'),
            'ping_interval' => config('session.lifetime') - 5, // every 10 minutes
            'notifications_unread' => 0,
            'pm_unread'     => 0
        ]);

        if (!empty($this->app['request']->user())) {
            $user = $this->app['request']->user();

            $this->app['request']->attributes->add([
                'token' => app(Encrypter::class)->encrypt('user:' . $user->id . '|' . time()),
//                'token' => $this->getJWtToken($user),
                'notifications_unread' => $user->notifications_unread,
                'pm_unread' => $user->pm_unread
            ]);
        }
{'fraction_non_alphanumeric': 0.17619243421052633, 'fraction_numerical': 0.003289473684210526, 'mean_word_length': 2.376127689104788, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 90, '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': '1350317', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1448, 'n_words': 209}