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)
-- 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
--

View 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'];

View 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);
}
/**

View 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'])) {

View 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.');
}

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
if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1522);
define('DB_UPDATE_VERSION', 1523);
}
return [

View file

@ -58,6 +58,35 @@
"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"],