<commit_before><?php namespace Flarum\Core\Posts;

use Flarum\Core\Discussions\Discussion;
use Flarum\Core\Users\User;
use Flarum\Events\ModelAllow;
use Flarum\Events\RegisterPostTypes;
use Flarum\Events\ScopePostVisibility;
use Flarum\Support\ServiceProvider;
use Flarum\Extend;
use Carbon\Carbon;

class PostsServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {
        Post::setValidator($this->app->make('validator'));

        CommentPost::setFormatter($this->app->make('flarum.formatter'));

        $this->registerPostTypes();

        $events = $this->app->make('events');
        $settings = $this->app->make('Flarum\Core\Settings\SettingsRepository');

        $events->listen(ModelAllow::class, function (ModelAllow $event) use ($settings) {
            if ($event->model instanceof Post) {
                $post = $event->model;
                $action = $event->action;
                $actor = $event->actor;

                if ($action === 'view' &&
                    (! $post->hide_user_id || $post->can($actor, 'edit'))) {
                    return true;
                }<commit_msg>Allow post author to see their own deleted post<commit_after><?php namespace Flarum\Core\Posts;

use Flarum\Core\Discussions\Discussion;
use Flarum\Core\Users\User;
use Flarum\Events\ModelAllow;
use Flarum\Events\RegisterPostTypes;
use Flarum\Events\ScopePostVisibility;
use Flarum\Support\ServiceProvider;
use Flarum\Extend;
use Carbon\Carbon;

class PostsServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {
        Post::setValidator($this->app->make('validator'));

        CommentPost::setFormatter($this->app->make('flarum.formatter'));

        $this->registerPostTypes();

        $events = $this->app->make('events');
        $settings = $this->app->make('Flarum\Core\Settings\SettingsRepository');

        $events->listen(ModelAllow::class, function (ModelAllow $event) use ($settings) {
            if ($event->model instanceof Post) {
                $post = $event->model;
                $action = $event->action;
                $actor = $event->actor;

                if ($action === 'view' &&
                    (! $post->hide_user_id || $post->hide_user_id == $actor->id || $post->can($actor, 'edit'))) {
                    return true;
                }
{'fraction_non_alphanumeric': 0.14520657841957482, 'fraction_numerical': 0.0, 'mean_word_length': 2.567954220314735, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '6801614', 'n_tokens_mistral': 735, 'n_tokens_neox': 681, 'n_words': 136}