Issue 13289: Ensure to not respect deactivated connector networks

This commit is contained in:
Michael 2023-07-22 10:49:42 +00:00
parent d84866cf8c
commit 7538f6a346
7 changed files with 95 additions and 15 deletions

View File

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 2023.09-dev (Giant Rhubarb) -- 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` FROM `application-token`
INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`; 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 -- VIEW post-user-view
-- --

View File

@ -22,6 +22,7 @@
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Content\Widget;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
@ -565,7 +566,12 @@ class Circle
} }
if ($each == '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); $circle_name = sprintf('%s (%d)', $circle['name'], $count);
} else { } else {
$circle_name = $circle['name']; $circle_name = $circle['name'];

View File

@ -21,6 +21,7 @@
namespace Friendica\Model\Contact; namespace Friendica\Model\Contact;
use Friendica\Content\Widget;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
@ -42,6 +43,9 @@ class Circle
$return = []; $return = [];
if (intval($gid)) { if (intval($gid)) {
$networks = Widget::unavailableNetworks();
$sql_values = array_merge([$gid, DI::userSession()->getLocalUserId()], $networks);
$stmt = DBA::p('SELECT `circle_member`.`contact-id`, `contact`.* $stmt = DBA::p('SELECT `circle_member`.`contact-id`, `contact`.*
FROM `contact` FROM `contact`
INNER JOIN `group_member` AS `circle_member` INNER JOIN `group_member` AS `circle_member`
@ -52,9 +56,9 @@ class Circle
AND NOT `contact`.`deleted` AND NOT `contact`.`deleted`
AND NOT `contact`.`blocked` AND NOT `contact`.`blocked`
AND NOT `contact`.`pending` AND NOT `contact`.`pending`
AND NOT `contact`.`network` IN (' . substr(str_repeat('?, ', count($networks)), 0, -2) . ')
ORDER BY `contact`.`name` ASC', ORDER BY `contact`.`name` ASC',
$gid, $sql_values
DI::userSession()->getLocalUserId()
); );
if (DBA::isResult($stmt)) { if (DBA::isResult($stmt)) {
@ -77,9 +81,14 @@ class Circle
*/ */
public static function listUncircled(int $uid) 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` 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);
} }
/** /**

View File

@ -42,9 +42,9 @@ class Federation extends BaseAdmin
'akkoma' => ['name' => 'Akkoma', 'color' => '#9574cd'], // Color from the page 'akkoma' => ['name' => 'Akkoma', 'color' => '#9574cd'], // Color from the page
'birdsitelive' => ['name' => 'BirdsiteLIVE', 'color' => '#1b6ec2'], // Color from the page 'birdsitelive' => ['name' => 'BirdsiteLIVE', 'color' => '#1b6ec2'], // Color from the page
'bookwyrm' => ['name' => 'BookWyrm', 'color' => '#00d1b2'], // 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 'castopod' => ['name' => 'Castopod', 'color' => '#00564a'], // Background color from the page
'diaspora' => ['name' => 'Diaspora', 'color' => '#a1a1a1'], // logo is black and white, makes a gray '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 'foundkey' => ['name' => 'Foundkey', 'color' => '#609926'], // Some random color from the repository
'funkwhale' => ['name' => 'Funkwhale', 'color' => '#4082B4'], // From the homepage 'funkwhale' => ['name' => 'Funkwhale', 'color' => '#4082B4'], // From the homepage
'gancio' => ['name' => 'Gancio', 'color' => '#7253ed'], // Fontcolor from the page 'gancio' => ['name' => 'Gancio', 'color' => '#7253ed'], // Fontcolor from the page
@ -116,6 +116,8 @@ class Federation extends BaseAdmin
$version['version'] = $gserver['platform'] . ' ' . $version['version']; $version['version'] = $gserver['platform'] . ' ' . $version['version'];
} elseif (in_array($gserver['platform'], ['activityrelay', 'pub-relay', 'selective-relay', 'aoderelay'])) { } elseif (in_array($gserver['platform'], ['activityrelay', 'pub-relay', 'selective-relay', 'aoderelay'])) {
$version['version'] = $gserver['platform'] . '-' . $version['version']; $version['version'] = $gserver['platform'] . '-' . $version['version'];
} elseif (in_array($gserver['platform'], ['calckey', 'firefish'])) {
$version['version'] = $gserver['platform'] . '-' . $version['version'];
} }
$versionCounts[] = $version; $versionCounts[] = $version;
@ -126,6 +128,8 @@ class Federation extends BaseAdmin
if ($platform == 'friendika') { if ($platform == 'friendika') {
$platform = 'friendica'; $platform = 'friendica';
} elseif (in_array($platform, ['calckey', 'firefish'])) {
$platform = 'calckey';
} elseif (in_array($platform, ['red matrix', 'redmatrix', 'red'])) { } elseif (in_array($platform, ['red matrix', 'redmatrix', 'red'])) {
$platform = 'hubzilla'; $platform = 'hubzilla';
} elseif (in_array($platform, ['osada', 'mistpark', 'roadhouse', 'streams', 'zap'])) { } elseif (in_array($platform, ['osada', 'mistpark', 'roadhouse', 'streams', 'zap'])) {

View File

@ -22,6 +22,7 @@
namespace Friendica\Module; namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Content\Widget;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
@ -146,8 +147,6 @@ class Circle extends BaseModule
throw new \Friendica\Network\HTTPException\ForbiddenException(); 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')); 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 // 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) { if ($nocircle) {
$contacts = Model\Contact\Circle::listUncircled(DI::userSession()->getLocalUserId()); $contacts = Model\Contact\Circle::listUncircled(DI::userSession()->getLocalUserId());
} else { } else {
$contacts_stmt = DBA::select('contact', [], $networks = Widget::unavailableNetworks();
['rel' => [Model\Contact::FOLLOWER, Model\Contact::FRIEND, Model\Contact::SHARING], $query = "`uid` = ? AND NOT `self` AND NOT `deleted` AND NOT `blocked` AND NOT `pending` AND NOT `failed`
'uid' => DI::userSession()->getLocalUserId(), 'pending' => false, 'blocked' => false, 'failed' => false, 'self' => false], AND `rel` IN (?, ?, ?)
['order' => ['name']] 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); $contacts = DBA::toArray($contacts_stmt);
$context['$desc'] = DI::l10n()->t('Click on a contact to add or remove.'); $context['$desc'] = DI::l10n()->t('Click on a contact to add or remove.');
} }

View File

@ -56,7 +56,7 @@ use Friendica\Database\DBA;
// This file is required several times during the test in DbaDefinition which justifies this condition // This file is required several times during the test in DbaDefinition which justifies this condition
if (!defined('DB_UPDATE_VERSION')) { if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1522); define('DB_UPDATE_VERSION', 1523);
} }
return [ return [

View File

@ -58,6 +58,35 @@
"query" => "FROM `application-token` "query" => "FROM `application-token`
INNER JOIN `application` ON `application-token`.`application-id` = `application`.`id`" 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" => [ "post-user-view" => [
"fields" => [ "fields" => [
"id" => ["post-user", "id"], "id" => ["post-user", "id"],