From 8c34c3b8ae76bd88cd75be69537f94511f71ce87 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 24 Mar 2022 11:30:32 +0000 Subject: [PATCH] Don't display Peertube groups as forums --- database.sql | 20 ++++++++++++-------- src/Content/ForumManager.php | 24 +++++++++++++++--------- static/dbstructure.config.php | 2 +- static/dbview.config.php | 14 +++++++++----- 4 files changed, 37 insertions(+), 23 deletions(-) diff --git a/database.sql b/database.sql index 39e40c044a..ffe0202033 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2022.05-dev (Siberian Iris) --- DB_UPDATE_VERSION 1452 +-- DB_UPDATE_VERSION 1453 -- ------------------------------------------ @@ -2412,10 +2412,8 @@ CREATE VIEW `account-view` AS SELECT `contact`.`archive` AS `archive`, `contact`.`deleted` AS `deleted`, `contact`.`blocked` AS `blocked`, - `contact`.`request` AS `dfrn-request`, `contact`.`notify` AS `dfrn-notify`, `contact`.`poll` AS `dfrn-poll`, - `contact`.`confirm` AS `dfrn-confirm`, `fcontact`.`guid` AS `diaspora-guid`, `fcontact`.`batch` AS `diaspora-batch`, `fcontact`.`notify` AS `diaspora-notify`, @@ -2431,11 +2429,15 @@ CREATE VIEW `account-view` AS SELECT `apcontact`.`generator` AS `ap-generator`, `apcontact`.`following_count` AS `ap-following_count`, `apcontact`.`followers_count` AS `ap-followers_count`, - `apcontact`.`statuses_count` AS `ap-statuses_count` + `apcontact`.`statuses_count` AS `ap-statuses_count`, + `gserver`.`site_name` AS `site_name`, + `gserver`.`platform` AS `platform`, + `gserver`.`version` AS `version` FROM `contact` LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id` LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id` LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id` + LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid` WHERE `contact`.`uid` = 0; -- @@ -2511,10 +2513,8 @@ CREATE VIEW `account-user-view` AS SELECT `ucontact`.`subhub` AS `subhub`, `ucontact`.`hub-verify` AS `hub-verify`, `ucontact`.`reason` AS `reason`, - `contact`.`request` AS `dfrn-request`, `contact`.`notify` AS `dfrn-notify`, `contact`.`poll` AS `dfrn-poll`, - `contact`.`confirm` AS `dfrn-confirm`, `fcontact`.`guid` AS `diaspora-guid`, `fcontact`.`batch` AS `diaspora-batch`, `fcontact`.`notify` AS `diaspora-notify`, @@ -2530,12 +2530,16 @@ CREATE VIEW `account-user-view` AS SELECT `apcontact`.`generator` AS `ap-generator`, `apcontact`.`following_count` AS `ap-following_count`, `apcontact`.`followers_count` AS `ap-followers_count`, - `apcontact`.`statuses_count` AS `ap-statuses_count` + `apcontact`.`statuses_count` AS `ap-statuses_count`, + `gserver`.`site_name` AS `site_name`, + `gserver`.`platform` AS `platform`, + `gserver`.`version` AS `version` FROM `contact` AS `ucontact` INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id` LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id` - LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr'; + LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr' + LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`; -- -- VIEW pending-view diff --git a/src/Content/ForumManager.php b/src/Content/ForumManager.php index 0104d388f5..51abaa49dd 100644 --- a/src/Content/ForumManager.php +++ b/src/Content/ForumManager.php @@ -57,23 +57,29 @@ class ForumManager $params = ['order' => ['name']]; } - $condition_str = "`network` IN (?, ?) AND `uid` = ? AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND "; - - if ($showprivate) { - $condition_str .= '(`forum` OR `prv`)'; - } else { - $condition_str .= '`forum`'; + $condition = [ + 'contact-type' => Contact::TYPE_COMMUNITY, + 'network' => [Protocol::DFRN, Protocol::ACTIVITYPUB], + 'uid' => $uid, + 'blocked' => false, + 'pending' => false, + 'archive' => false, + ]; + + $condition = DBA::mergeConditions($condition, ["`platform` != ?", 'peertube']); + + if (!$showprivate) { + $condition = DBA::mergeConditions($condition, ['manually-approve' => false]); } if (!$showhidden) { - $condition_str .= ' AND NOT `hidden`'; + $condition = DBA::mergeConditions($condition, ['hidden' => false]); } $forumlist = []; $fields = ['id', 'url', 'name', 'micro', 'thumb', 'avatar', 'network', 'uid']; - $condition = [$condition_str, Protocol::DFRN, Protocol::ACTIVITYPUB, $uid]; - $contacts = DBA::select('contact', $fields, $condition, $params); + $contacts = DBA::select('account-user-view', $fields, $condition, $params); if (!$contacts) { return($forumlist); } diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 8963b1df60..fd1e39cc2e 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -55,7 +55,7 @@ use Friendica\Database\DBA; if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1452); + define('DB_UPDATE_VERSION', 1453); } return [ diff --git a/static/dbview.config.php b/static/dbview.config.php index 014973de26..a5c52c9b13 100644 --- a/static/dbview.config.php +++ b/static/dbview.config.php @@ -873,10 +873,8 @@ "archive" => ["contact", "archive"], "deleted" => ["contact", "deleted"], "blocked" => ["contact", "blocked"], - "dfrn-request" => ["contact", "request"], "dfrn-notify" => ["contact", "notify"], "dfrn-poll" => ["contact", "poll"], - "dfrn-confirm" => ["contact", "confirm"], "diaspora-guid" => ["fcontact", "guid"], "diaspora-batch" => ["fcontact", "batch"], "diaspora-notify" => ["fcontact", "notify"], @@ -893,11 +891,15 @@ "ap-following_count" => ["apcontact", "following_count"], "ap-followers_count" => ["apcontact", "followers_count"], "ap-statuses_count" => ["apcontact", "statuses_count"], + "site_name" => ["gserver", "site_name"], + "platform" => ["gserver", "platform"], + "version" => ["gserver", "version"], ], "query" => "FROM `contact` LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id` LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id` LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id` + LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid` WHERE `contact`.`uid` = 0" ], "account-user-view" => [ @@ -970,10 +972,8 @@ "subhub" => ["ucontact", "subhub"], "hub-verify" => ["ucontact", "hub-verify"], "reason" => ["ucontact", "reason"], - "dfrn-request" => ["contact", "request"], "dfrn-notify" => ["contact", "notify"], "dfrn-poll" => ["contact", "poll"], - "dfrn-confirm" => ["contact", "confirm"], "diaspora-guid" => ["fcontact", "guid"], "diaspora-batch" => ["fcontact", "batch"], "diaspora-notify" => ["fcontact", "notify"], @@ -990,12 +990,16 @@ "ap-following_count" => ["apcontact", "following_count"], "ap-followers_count" => ["apcontact", "followers_count"], "ap-statuses_count" => ["apcontact", "statuses_count"], + "site_name" => ["gserver", "site_name"], + "platform" => ["gserver", "platform"], + "version" => ["gserver", "version"], ], "query" => "FROM `contact` AS `ucontact` INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id` LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id` - LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr'" + LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr' + LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`" ], "pending-view" => [ "fields" => [ -- 2.39.5