<commit_before><?php
/**
 * Minds Group API
 * Group information endpoints
 */
namespace Minds\Controllers\api\v1\groups;

use Minds\Core;
use Minds\Core\Session;
use Minds\Interfaces;
use Minds\Api\Factory;
use Minds\Entities\User;
use Minds\Entities\File as FileEntity;
use Minds\Entities\Factory as EntitiesFactory;
use Minds\Entities\Group as GroupEntity;

use Minds\Exceptions\GroupOperationException;

class group implements Interfaces\Api
{
    /**
     * Returns the conversations or conversation
     * @param array $pages
     *
     * API:: /v1/group/group/:guid
     */
    public function get($pages)
    {
        $group = EntitiesFactory::build($pages[0]);
        $user = Session::getLoggedInUser();

        $response = [];

        if ($group) {
            $response['group'] = $group->export();

            $membership = (new Core\Groups\Membership)
              ->setGroup($group);

            $notifications = (new Core\Groups\Notifications)
              ->setGroup($group);

            $response['group']['is:muted'] = $notifications->isMuted($user);

            if (!$membership->isMember($user) && !$user->isAdmin()) {
                $allowed = ['guid', 'name', 'membership', 'type'];
                $response['group'] = array_filter($response['group'], function ($key) use ($allowed) {
                    return in_array($key, $allowed);
                }, ARRAY_FILTER_USE_KEY);
            }

            if ($group->isOwner($user)) {
                /** @var Core\Groups\Feeds $feeds */
                $feeds = Core\Di\Di::_()->get('Groups\Feeds');
                $count = (int) $feeds->setGroup($group)->count();

                $response['group']['adminqueue:count'] = $count;
            }
        }

        return Factory::response($response);<commit_msg>(bug) open groups do not sho numbers or number of posts if youre not member (#479)<commit_after><?php
/**
 * Minds Group API
 * Group information endpoints
 */
namespace Minds\Controllers\api\v1\groups;

use Minds\Core;
use Minds\Core\Session;
use Minds\Interfaces;
use Minds\Api\Factory;
use Minds\Entities\User;
use Minds\Entities\File as FileEntity;
use Minds\Entities\Factory as EntitiesFactory;
use Minds\Entities\Group as GroupEntity;

use Minds\Exceptions\GroupOperationException;

class group implements Interfaces\Api
{
    /**
     * Returns the conversations or conversation
     * @param array $pages
     *
     * API:: /v1/group/group/:guid
     */
    public function get($pages)
    {
        $group = EntitiesFactory::build($pages[0]);
        $user = Session::getLoggedInUser();

        $response = [];

        if ($group) {
            $response['group'] = $group->export();

            $membership = (new Core\Groups\Membership)
              ->setGroup($group);

            $notifications = (new Core\Groups\Notifications)
              ->setGroup($group);

            $response['group']['is:muted'] = $notifications->isMuted($user);

            if (!$membership->isMember($user) && !$user->isAdmin()) {
                $allowed = ['guid', 'name', 'membership', 'type' ];
                if ($response['group']['membership'] == 2) {
                    $allowed = array_merge($allowed, ['members:count', 'activity:count', 'comments:count']);
                }

                $response['group'] = array_filter($response['group'], function ($key) use ($allowed) {
                    return in_array($key, $allowed);
                }, ARRAY_FILTER_USE_KEY);
            }

            if ($group->isOwner($user)) {
                /** @var Core\Groups\Feeds $feeds */
                $feeds = Core\Di\Di::_()->get('Groups\Feeds');
                $count = (int) $feeds->setGroup($group)->count();

                $response['group']['adminqueue:count'] = $count;
            }
        }

        return Factory::response($response);
{'fraction_non_alphanumeric': 0.15591815591815592, 'fraction_numerical': 0.00259000259000259, 'mean_word_length': 2.3121783876500857, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '910701', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1089, 'n_words': 224}