+ $config->set('nodeinfo', 'active_users_weekly', $userStats['active_users_weekly']);
+
+ $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);
+ $config->set('nodeinfo', 'local_comments', $comments);
+
+ $logger->info('User actitivy', ['posts' => $posts, 'comments' => $comments]);
+ }
+
+ /**
+ * Return the supported services
+ *
+ * @return Object with supported services
+ */
+ public static function getUsage(bool $version2 = false)
+ {
+ $config = DI::config();
+
+ $usage = new stdClass();
+
+ if (!empty($config->get('system', 'nodeinfo'))) {
+ $usage->users = [
+ 'total' => intval($config->get('nodeinfo', 'total_users')),
+ 'activeHalfyear' => intval($config->get('nodeinfo', 'active_users_halfyear')),
+ 'activeMonth' => intval($config->get('nodeinfo', 'active_users_monthly'))
+ ];
+ $usage->localPosts = intval($config->get('nodeinfo', 'local_posts'));
+ $usage->localComments = intval($config->get('nodeinfo', 'local_comments'));
+
+ if ($version2) {
+ $usage->users['activeWeek'] = intval($config->get('nodeinfo', 'active_users_weekly'));
+ }
+ }
+
+ return $usage;
+ }
+
+ /**
+ * Return the supported services
+ *
+ * @return array with supported services
+ */
+ public static function getServices()
+ {
+ $services = [
+ 'inbound' => [],
+ 'outbound' => [],
+ ];
+
+ if (Addon::isEnabled('blogger')) {
+ $services['outbound'][] = 'blogger';
+ }
+ if (Addon::isEnabled('dwpost')) {
+ $services['outbound'][] = 'dreamwidth';
+ }
+ if (Addon::isEnabled('statusnet')) {
+ $services['inbound'][] = 'gnusocial';
+ $services['outbound'][] = 'gnusocial';
+ }
+ if (Addon::isEnabled('ijpost')) {
+ $services['outbound'][] = 'insanejournal';
+ }
+ if (Addon::isEnabled('libertree')) {
+ $services['outbound'][] = 'libertree';
+ }
+ if (Addon::isEnabled('buffer')) {
+ $services['outbound'][] = 'linkedin';
+ }
+ if (Addon::isEnabled('ljpost')) {
+ $services['outbound'][] = 'livejournal';
+ }
+ if (Addon::isEnabled('buffer')) {
+ $services['outbound'][] = 'pinterest';
+ }
+ if (Addon::isEnabled('posterous')) {
+ $services['outbound'][] = 'posterous';
+ }
+ if (Addon::isEnabled('pumpio')) {
+ $services['inbound'][] = 'pumpio';
+ $services['outbound'][] = 'pumpio';
+ }
+
+ $services['outbound'][] = 'smtp';