Can the user view the content of the post in this discussion?

@param stdClass $user The user to check
@param discussion_entity $discussion The discussion to check
@param post_entity $post The post the user wants to view
@return bool
766879
public function can_view_post(stdClass $user, discussion_entity $discussion, post_entity $post) : bool {
        if (!$this->can_view_post_shell($user, $post)) {
            return false;
        }

        $forum = $this->get_forum();
        $forumrecord = $this->get_forum_record();
        $discussionrecord = $this->get_discussion_record($discussion);
        $postrecord = $this->get_post_record($post);
        $coursemodule = $forum->get_course_module_record();
        return forum_user_can_see_post($forumrecord, $discussionrecord, $postrecord, $user, $coursemodule, false);
    }
221108
protected function can_post($course, $forum, $discussion, $post, $cm, $context) {
        if (!isset($this->canpostto[$discussion->id])) {
            $this->canpostto[$discussion->id] = forum_user_can_post($forum, $discussion, $this->recipient, $cm, $course, $context);
        }
        return $this->canpostto[$discussion->id];
    }
311741
protected function feedback_viewed(\cm_info $cm, $contextid, $userid, $after = null) {
        return $this->feedback_post_action($cm, $contextid, $userid, $this->feedback_viewed_events(), $after);
    }
1135462
public function update(User $user, User $entity)
    {
        if ($entity->id === $user->id) {
            return true;
        }
        return $user->hasPermission('user-update');
    }
445467
public function can_delete_post(stdClass $user, discussion_entity $discussion, post_entity $post) : bool {
        global $CFG;

        $forum = $this->get_forum();

        if ($forum->get_type() == 'single' && $discussion->is_first_post($post)) {
            // Do not allow deleting of first post in single simple type.
            return false;
        } else {
            $context = $this->get_context();
            $ownpost = $post->is_owned_by_user($user);
            $ineditingtime = $post->get_age() < $CFG->maxeditingtime;

            return ($ownpost && $ineditingtime && has_capability('mod/forum:deleteownpost', $context, $user)) ||
                has_capability('mod/forum:deleteanypost', $context, $user);
        }
    }
35692
public function view($user, Event $event)
    {
        if ($event->creator->id == $user->id) {
            return true;
        }

        return User::findOrFail($user->id)->hasPermission('laralum::events.view');
    }
1029151
public function editOwnPost($user, $post) {
		$post = $this->getModel(\App\Post::class, $post);  // helper method for geting model

		return $user->id === $post->user_id;
	}
1372944
public function can_export_discussions(stdClass $user) : bool {
        global $CFG;
        return $CFG->enableportfolios && has_capability('mod/forum:exportdiscussion', $this->get_context(), $user);
    }
1185582
public function view(UserPolicy $user, Blog $blog)
    {
        if ($user->canDo('blog.blog.view') && $user->isAdmin()) {
            return true;
        }

        return $blog->user_id == user_id() && $blog->user_type == user_type();
    }
1295250
public function viewOnFrontend(User $user, Content $content)
    {
        if ($content->canBeShown()) {
            return true;
        }
        return ($content->author->id === $user->id);
    }
456978
public function canComment($user = null)
    {
        if ($this->getCommentStatus()->getId() == ArticleCommentStatus::ARTICLE_COMMENTS_OFF) {
            return false;
        }

        if ($this->getCommentStatus()->getId() == ArticleCommentStatus::ARTICLE_COMMENTS_INTERNAL) {
            if ($user && $user->isLoggedIn()) {
                return true;
            } else {
                return false;
            }
        }

        if ($this->getCommentStatus()->getId() == ArticleCommentStatus::ARTICLE_COMMENTS_ON) {
            return true;
        }

        return false;
    }
121739
public function stateFor(User $user)
    {
        $state = $this->state($user)->first();

        if (! $state) {
            $state = new UserState;
            $state->discussion_id = $this->id;
            $state->user_id = $user->id;
        }

        return $state;
    }
1232759
public static function can_view_category($category, $user = null) {
        if (!$category->id) {
            return has_capability('moodle/category:viewcourselist', context_system::instance(), $user);
        }
        $context = context_coursecat::instance($category->id);
        if (!$category->visible && !has_capability('moodle/category:viewhiddencategories', $context, $user)) {
            return false;
        }
        return has_capability('moodle/category:viewcourselist', $context, $user);
    }
630666
private function checkView(TokenInterface $token, User $user)
    {
        return $this->isOrganizationManager($token, $user) ?
              VoterInterface::ACCESS_GRANTED : VoterInterface::ACCESS_DENIED;
    }
655122
public function userIsParticipant( eZUser $user )
    {
        /** @var eZCollaborationItemParticipantLink $participantLink */
        foreach ( $this->participantList() as $participantLink )
        {
            $participant = $participantLink->participant();

            if ( $participant instanceof eZUser )
            {
                if ( $participant->attribute( 'contentobject_id' ) == $user->attribute( 'contentobject_id' ) )
                {
                    return true;
                }
            }
            // user group
            else if ( $participant instanceof eZContentObject )
            {
                foreach ( $user->groups() as $userGroup )
                {
                    if ( $participant->attribute( 'id' ) == $userGroup->attribute( 'id' ) )
                    {
                        return true;
                    }
                }
            }
        }
        return false;
    }
802424
public function can_split_discussions(stdClass $user) : bool {
        $forum = $this->get_forum();
        return $forum->get_type() !== 'single' && has_capability('mod/forum:splitdiscussions', $this->get_context(), $user);
    }
774907
public function get_discussion_list_renderer(
        forum_entity $forum
    ) : discussion_list_renderer {

        $capabilitymanager = $this->managerfactory->get_capability_manager($forum);
        $rendererbase = $this->rendererbase;
        $notifications = [];

        switch ($forum->get_type()) {
            case 'news':
                if (SITEID == $forum->get_course_id()) {
                    $template = 'mod_forum/frontpage_news_discussion_list';
                } else {
                    $template = 'mod_forum/news_discussion_list';
                }
                break;
            case 'qanda':
                $template = 'mod_forum/qanda_discussion_list';
                break;
            default:
                $template = 'mod_forum/discussion_list';
        }

        return new discussion_list_renderer(
            $forum,
            $rendererbase,
            $this->legacydatamapperfactory,
            $this->exporterfactory,
            $this->vaultfactory,
            $this->builderfactory,
            $capabilitymanager,
            $this->urlfactory,
            $template,
            $notifications,
            function($discussions, $user, $forum) {

                $exporteddiscussionsummarybuilder = $this->builderfactory->get_exported_discussion_summaries_builder();
                return $exporteddiscussionsummarybuilder->build(
                    $user,
                    $forum,
                    $discussions
                );
            }
        );
    }