]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Nodeinfo.php
Merge remote-tracking branch 'upstream/2022.09-rc' into quote-uri-id
[friendica.git] / src / Model / Nodeinfo.php
index 398666185df1055afb57d194418cdc0e076163fe..5ce7f895137910ef9aea271ec3072fc7228a9bd5 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Model;
 
 use Friendica\Core\Addon;
+use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use stdClass;
@@ -60,9 +61,9 @@ class Nodeinfo
 
                $logger->info('user statistics', $userStats);
 
-               $posts = DBA::count('post-thread', ["EXISTS(SELECT `uri-id` FROM `post-user` WHERE NOT `deleted` AND `origin` AND `uri-id` = `post-thread`.`uri-id`)"]);
-               $comments = DBA::count('post', ["NOT `deleted` AND `gravity` = ? AND EXISTS(SELECT `uri-id` FROM `post-user` WHERE `origin` AND `uri-id` = `post`.`uri-id`)", GRAVITY_COMMENT]);
-               $config->set('nodeinfo', 'local_posts', $posts);
+               $posts = DBA::count('post-thread', ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE NOT `deleted` AND `origin`)"]);
+               $comments = DBA::count('post', ["NOT `deleted` AND `gravity` = ? AND `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)", GRAVITY_COMMENT]);
+                               $config->set('nodeinfo', 'local_posts', $posts);
                $config->set('nodeinfo', 'local_comments', $comments);
 
                $logger->info('User actitivy', ['posts' => $posts, 'comments' => $comments]);
@@ -78,6 +79,7 @@ class Nodeinfo
                $config = DI::config();
 
                $usage = new stdClass();
+               $usage->users = [];
 
                if (!empty($config->get('system', 'nodeinfo'))) {
                        $usage->users = [
@@ -156,7 +158,13 @@ class Nodeinfo
                return $services;
        }
 
-       public static function getOrganization()
+       /**
+        * Gathers organization information and returns it as an array
+        *
+        * @param IManageConfigValues $config Configuration instance
+        * @return array Organization information
+        */
+       public static function getOrganization(IManageConfigValues $config): array
        {
                $organization = [
                        'name' => null,
@@ -164,8 +172,8 @@ class Nodeinfo
                        'account' => null
                ];
 
-               if (!empty(DI::config()->get('config', 'admin_email'))) {
-                       $adminList = explode(',', str_replace(' ', '', DI::config()->get('config', 'admin_email')));
+               if (!empty($config->get('config', 'admin_email'))) {
+                       $adminList = explode(',', str_replace(' ', '', $config->get('config', 'admin_email')));
                        $organization['contact'] = $adminList[0];
                        $administrator = User::getByEmail($adminList[0], ['username', 'nickname']);
                        if (!empty($administrator)) {