]> git.mxchange.org Git - friendica.git/commitdiff
Issue 13289: Ensure to not respect deactivated connector networks
authorMichael <heluecht@pirati.ca>
Sat, 22 Jul 2023 10:49:42 +0000 (10:49 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 22 Jul 2023 10:49:42 +0000 (10:49 +0000)
database.sql
src/Model/Circle.php
src/Model/Contact/Circle.php
src/Module/Admin/Federation.php
src/Module/Circle.php
static/dbstructure.config.php
static/dbview.config.php

index e9db927f1ef4bcbd20c75d3f114772bec6b5ae5b..5a8cee23c4a88f50949da1cac4009a3d1e83722e 100644 (file)
@@ -1,6 +1,6 @@
 -- ------------------------------------------
 -- Friendica 2023.09-dev (Giant Rhubarb)
--- DB_UPDATE_VERSION 1522
+-- DB_UPDATE_VERSION 1523
 -- ------------------------------------------
 
 
@@ -1900,6 +1900,37 @@ CREATE VIEW `application-view` AS SELECT
        FROM `application-token`
                        INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`;
 
+--
+-- VIEW circle-member-view
+--
+DROP VIEW IF EXISTS `circle-member-view`;
+CREATE VIEW `circle-member-view` AS SELECT 
+       `group_member`.`id` AS `id`,
+       `group`.`uid` AS `uid`,
+       `group_member`.`contact-id` AS `contact-id`,
+       `contact`.`uri-id` AS `contact-uri-id`,
+       `contact`.`url` AS `contact-link`,
+       `contact`.`addr` AS `contact-addr`,
+       `contact`.`name` AS `contact-name`,
+       `contact`.`nick` AS `contact-nick`,
+       `contact`.`thumb` AS `contact-avatar`,
+       `contact`.`network` AS `contact-network`,
+       `contact`.`blocked` AS `contact-blocked`,
+       `contact`.`hidden` AS `contact-hidden`,
+       `contact`.`readonly` AS `contact-readonly`,
+       `contact`.`archive` AS `contact-archive`,
+       `contact`.`pending` AS `contact-pending`,
+       `contact`.`self` AS `contact-self`,
+       `contact`.`rel` AS `contact-rel`,
+       `contact`.`contact-type` AS `contact-contact-type`,
+       `group_member`.`gid` AS `circle-id`,
+       `group`.`visible` AS `circle-visible`,
+       `group`.`deleted` AS `circle-deleted`,
+       `group`.`name` AS `circle-name`
+       FROM `group_member`
+                       INNER JOIN `contact` ON `group_member`.`contact-id` = `contact`.`id`
+                       INNER JOIN `group` ON `group_member`.`gid` = `group`.`id`;
+
 --
 -- VIEW post-user-view
 --
index c0b3cf6b4b37cc9365e35735de5407414ee1a956..2b32103db99715a56e0f8d9dd36fca9e61cb6b45 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Model;
 
 use Friendica\BaseModule;
+use Friendica\Content\Widget;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
@@ -565,7 +566,12 @@ class Circle
                        }
 
                        if ($each == 'circle') {
-                               $count = DBA::count('group_member', ['gid' => $circle['id']]);
+                               $networks = Widget::unavailableNetworks();
+                               $sql_values = array_merge([$circle['id']], $networks);
+                               $condition = ["`circle-id` = ? AND NOT `contact-network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")"];
+                               $condition = array_merge($condition, $sql_values);
+
+                               $count = DBA::count('circle-member-view', $condition);
                                $circle_name = sprintf('%s (%d)', $circle['name'], $count);
                        } else {
                                $circle_name = $circle['name'];
index d3eea5ac5b24188d2292e7caae8fb45f56860dd2..7cd18acbb1b06ac5b54a441c601c1e0628d4f45e 100644 (file)
@@ -21,6 +21,7 @@
 
 namespace Friendica\Model\Contact;
 
+use Friendica\Content\Widget;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
@@ -42,6 +43,9 @@ class Circle
                $return = [];
 
                if (intval($gid)) {
+                       $networks = Widget::unavailableNetworks();
+                       $sql_values = array_merge([$gid, DI::userSession()->getLocalUserId()], $networks);
+
                        $stmt = DBA::p('SELECT `circle_member`.`contact-id`, `contact`.*
                                FROM `contact`
                                INNER JOIN `group_member` AS `circle_member`
@@ -52,9 +56,9 @@ class Circle
                                AND NOT `contact`.`deleted`
                                AND NOT `contact`.`blocked`
                                AND NOT `contact`.`pending`
+                               AND NOT `contact`.`network` IN (' . substr(str_repeat('?, ', count($networks)), 0, -2) . ')
                                ORDER BY `contact`.`name` ASC',
-                               $gid,
-                               DI::userSession()->getLocalUserId()
+                               $sql_values
                        );
 
                        if (DBA::isResult($stmt)) {
@@ -77,9 +81,14 @@ class Circle
         */
        public static function listUncircled(int $uid)
        {
-               return Contact::selectToArray([], ["`uid` = ? AND NOT `self` AND NOT `deleted` AND NOT `blocked` AND NOT `pending` AND NOT `failed`
+               $networks = Widget::unavailableNetworks();
+               $query = "`uid` = ? AND NOT `self` AND NOT `deleted` AND NOT `blocked` AND NOT `pending` AND NOT `failed`
+                       AND NOT `network` IN (" . substr(str_repeat('?, ', count($networks)), 0, -2) . ")
                        AND `id` NOT IN (SELECT DISTINCT(`contact-id`) FROM `group_member` AS `circle_member` INNER JOIN `group` AS `circle` ON `circle`.`id` = `circle_member`.`gid`
-                               WHERE `circle`.`uid` = ? AND `contact-id` = `contact`.`id`)", $uid, $uid]);
+                       WHERE `circle`.`uid` = ? AND `contact-id` = `contact`.`id`)";
+               $condition = array_merge([$query], [$uid], $networks, [$uid]);
+
+               return Contact::selectToArray([], $condition);
        }
 
        /**
index 901176f0a53c7dc66db39be7acedaf835384e7df..51b83ccb4acce93388d473e5f801bc7c3594ea8b 100644 (file)
@@ -42,9 +42,9 @@ class Federation extends BaseAdmin
                        'akkoma'       => ['name' => 'Akkoma', 'color' => '#9574cd'], // Color from the page
                        'birdsitelive' => ['name' => 'BirdsiteLIVE', 'color' => '#1b6ec2'], // Color from the page
                        'bookwyrm'     => ['name' => 'BookWyrm', 'color' => '#00d1b2'], // Color from the page
-                       'calckey'      => ['name' => 'Calckey', 'color' => '#286983'], // Color from the page
                        'castopod'     => ['name' => 'Castopod', 'color' => '#00564a'], // Background color from the page
                        'diaspora'     => ['name' => 'Diaspora', 'color' => '#a1a1a1'], // logo is black and white, makes a gray
+                       'calckey'      => ['name' => 'firefish (Calckey)', 'color' => '#1c4a5c'], // Color from the page
                        'foundkey'     => ['name' => 'Foundkey', 'color' => '#609926'], // Some random color from the repository
                        'funkwhale'    => ['name' => 'Funkwhale', 'color' => '#4082B4'], // From the homepage
                        'gancio'       => ['name' => 'Gancio', 'color' => '#7253ed'], // Fontcolor from the page
@@ -116,6 +116,8 @@ class Federation extends BaseAdmin
                                        $version['version'] = $gserver['platform'] . ' ' . $version['version'];
                                } elseif (in_array($gserver['platform'], ['activityrelay', 'pub-relay', 'selective-relay', 'aoderelay'])) {
                                        $version['version'] = $gserver['platform'] . '-' . $version['version'];
+                               } elseif (in_array($gserver['platform'], ['calckey', 'firefish'])) {
+                                       $version['version'] = $gserver['platform'] . '-' . $version['version'];
                                }
 
                                $versionCounts[] = $version;
@@ -126,6 +128,8 @@ class Federation extends BaseAdmin
 
                        if ($platform == 'friendika') {
                                $platform = 'friendica';
+                       } elseif (in_array($platform, ['calckey', 'firefish'])) {
+                               $platform = 'calckey';
                        } elseif (in_array($platform, ['red matrix', 'redmatrix', 'red'])) {
                                $platform = 'hubzilla';
                        } elseif (in_array($platform, ['osada', 'mistpark', 'roadhouse', 'streams', 'zap'])) {
index 74d52ee6299c3027c791dd9acb2fe356f7c2e0e6..a51583ae9f23d8e25df4129dc51f7d3c9d69443c 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
+use Friendica\Content\Widget;
 use Friendica\Core\Renderer;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
@@ -146,8 +147,6 @@ class Circle extends BaseModule
                        throw new \Friendica\Network\HTTPException\ForbiddenException();
                }
 
-               $a = DI::app();
-
                DI::page()['aside'] = Model\Circle::sidebarWidget('contact', 'circle', 'extended', ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : 'everyone'));
 
                // With no circle number provided we jump to the unassigned contacts as a starting point
@@ -319,11 +318,13 @@ class Circle extends BaseModule
                if ($nocircle) {
                        $contacts = Model\Contact\Circle::listUncircled(DI::userSession()->getLocalUserId());
                } else {
-                       $contacts_stmt = DBA::select('contact', [],
-                               ['rel' => [Model\Contact::FOLLOWER, Model\Contact::FRIEND, Model\Contact::SHARING],
-                               'uid' => DI::userSession()->getLocalUserId(), 'pending' => false, 'blocked' => false, 'failed' => false, 'self' => false],
-                               ['order' => ['name']]
-                       );
+                       $networks = Widget::unavailableNetworks();
+                       $query = "`uid` = ? AND NOT `self` AND NOT `deleted` AND NOT `blocked` AND NOT `pending` AND NOT `failed`
+                               AND `rel` IN (?, ?, ?)
+                               AND NOT `network` IN (" . substr(str_repeat('?, ', count($networks)), 0, -2) . ")";
+                       $condition = array_merge([$query], [DI::userSession()->getLocalUserId(), Model\Contact::FOLLOWER, Model\Contact::FRIEND, Model\Contact::SHARING], $networks);
+
+                       $contacts_stmt = DBA::select('contact', [], $condition, ['order' => ['name']]);
                        $contacts = DBA::toArray($contacts_stmt);
                        $context['$desc'] = DI::l10n()->t('Click on a contact to add or remove.');
                }
index 1a61d9f2158c14e051318a384a9eea5f0694b09a..74a65e0eaab23ccd2af84146748170f2b890fef6 100644 (file)
@@ -56,7 +56,7 @@ use Friendica\Database\DBA;
 
 // This file is required several times during the test in DbaDefinition which justifies this condition
 if (!defined('DB_UPDATE_VERSION')) {
-       define('DB_UPDATE_VERSION', 1522);
+       define('DB_UPDATE_VERSION', 1523);
 }
 
 return [
index 43959f363361e9b4cc907689c70540cfd724c93b..e8641240c2c2de4653ea2b6f79877d4fe03d7ea5 100644 (file)
                "query" => "FROM `application-token`
                        INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`"
        ],
+       "circle-member-view" => [
+               "fields" => [
+                       "id" => ["group_member", "id"],
+                       "uid" => ["group", "uid"],
+                       "contact-id" => ["group_member", "contact-id"],
+                       "contact-uri-id" => ["contact", "uri-id"],
+                       "contact-link" => ["contact", "url"],
+                       "contact-addr" => ["contact", "addr"],
+                       "contact-name" => ["contact", "name"],
+                       "contact-nick" => ["contact", "nick"],
+                       "contact-avatar" => ["contact", "thumb"],
+                       "contact-network" => ["contact", "network"],
+                       "contact-blocked" => ["contact", "blocked"],
+                       "contact-hidden" => ["contact", "hidden"],
+                       "contact-readonly" => ["contact", "readonly"],
+                       "contact-archive" => ["contact", "archive"],
+                       "contact-pending" => ["contact", "pending"],
+                       "contact-self" => ["contact", "self"],
+                       "contact-rel" => ["contact", "rel"],
+                       "contact-contact-type" => ["contact", "contact-type"],
+                       "circle-id" => ["group_member", "gid"],
+                       "circle-visible" => ["group", "visible"],
+                       "circle-deleted" => ["group", "deleted"],
+                       "circle-name" => ["group", "name"],
+               ],
+               "query" => "FROM `group_member`
+                       INNER JOIN `contact` ON `group_member`.`contact-id` = `contact`.`id`
+                       INNER JOIN `group` ON `group_member`.`gid` = `group`.`id`"
+       ],
        "post-user-view" => [
                "fields" => [
                        "id" => ["post-user", "id"],