From 4108704ee364e91297ba03b3baf5448279c61300 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 4 Jun 2022 06:11:32 +0000 Subject: [PATCH] Fix: Only public posts can be pinned --- database.sql | 5 ++++- src/Model/Post/Collection.php | 3 ++- src/Object/Post.php | 2 +- static/dbstructure.config.php | 2 +- static/dbview.config.php | 3 +++ 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/database.sql b/database.sql index f2f9a89e2e..f8d5432658 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2022.05-rc (Siberian Iris) --- DB_UPDATE_VERSION 1464 +-- DB_UPDATE_VERSION 1465 -- ------------------------------------------ @@ -2309,6 +2309,9 @@ CREATE VIEW `collection-view` AS SELECT `post`.`received` AS `received`, `post`.`created` AS `created`, `post-thread`.`commented` AS `commented`, + `post`.`private` AS `private`, + `post`.`visible` AS `visible`, + `post`.`deleted` AS `deleted`, `post`.`thr-parent-id` AS `thr-parent-id`, `post`.`author-id` AS `author-id`, `post`.`gravity` AS `gravity` diff --git a/src/Model/Post/Collection.php b/src/Model/Post/Collection.php index 34b5dc6dee..363761d477 100644 --- a/src/Model/Post/Collection.php +++ b/src/Model/Post/Collection.php @@ -25,6 +25,7 @@ use Friendica\Database\DBA; use BadMethodCallException; use Friendica\Database\Database; use Friendica\DI; +use Friendica\Model\Item; use Friendica\Protocol\ActivityPub; class Collection @@ -81,6 +82,6 @@ class Collection */ public static function selectToArrayForContact(int $cid, int $type = self::FEATURED, array $fields = []) { - return DBA::selectToArray('collection-view', $fields, ['cid' => $cid, 'type' => $type]); + return DBA::selectToArray('collection-view', $fields, ['cid' => $cid, 'private' => [Item::PUBLIC, Item::UNLISTED], 'deleted' => false, 'type' => $type]); } } diff --git a/src/Object/Post.php b/src/Object/Post.php index 3f4b2760b5..fec3b3f2b3 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -342,7 +342,7 @@ class Post ]; if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) { - if ($origin) { + if ($origin && in_array($item['private'], [Item::PUBLIC, Item::UNLISTED])) { $ispinned = ($item['featured'] ? 'pinned' : 'unpinned'); $pin = [ diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index bf85bb56c7..ab25d934ab 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', 1464); + define('DB_UPDATE_VERSION', 1465); } return [ diff --git a/static/dbview.config.php b/static/dbview.config.php index 30e17baf81..68217118cc 100644 --- a/static/dbview.config.php +++ b/static/dbview.config.php @@ -677,6 +677,9 @@ "received" => ["post", "received"], "created" => ["post", "created"], "commented" => ["post-thread", "commented"], + "private" => ["post", "private"], + "visible" => ["post", "visible"], + "deleted" => ["post", "deleted"], "thr-parent-id" => ["post", "thr-parent-id"], "author-id" => ["post", "author-id"], "gravity" => ["post", "gravity"],