Fix: Only public posts can be pinned

This commit is contained in:
Michael 2022-06-04 06:11:32 +00:00
parent 6e3b5d251e
commit 4108704ee3
5 changed files with 11 additions and 4 deletions

View file

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 2022.05-rc (Siberian Iris) -- 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`.`received` AS `received`,
`post`.`created` AS `created`, `post`.`created` AS `created`,
`post-thread`.`commented` AS `commented`, `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`.`thr-parent-id` AS `thr-parent-id`,
`post`.`author-id` AS `author-id`, `post`.`author-id` AS `author-id`,
`post`.`gravity` AS `gravity` `post`.`gravity` AS `gravity`

View file

@ -25,6 +25,7 @@ use Friendica\Database\DBA;
use BadMethodCallException; use BadMethodCallException;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
class Collection class Collection
@ -81,6 +82,6 @@ class Collection
*/ */
public static function selectToArrayForContact(int $cid, int $type = self::FEATURED, array $fields = []) 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]);
} }
} }

View file

@ -342,7 +342,7 @@ class Post
]; ];
if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) { 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'); $ispinned = ($item['featured'] ? 'pinned' : 'unpinned');
$pin = [ $pin = [

View file

@ -55,7 +55,7 @@
use Friendica\Database\DBA; use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) { if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1464); define('DB_UPDATE_VERSION', 1465);
} }
return [ return [

View file

@ -677,6 +677,9 @@
"received" => ["post", "received"], "received" => ["post", "received"],
"created" => ["post", "created"], "created" => ["post", "created"],
"commented" => ["post-thread", "commented"], "commented" => ["post-thread", "commented"],
"private" => ["post", "private"],
"visible" => ["post", "visible"],
"deleted" => ["post", "deleted"],
"thr-parent-id" => ["post", "thr-parent-id"], "thr-parent-id" => ["post", "thr-parent-id"],
"author-id" => ["post", "author-id"], "author-id" => ["post", "author-id"],
"gravity" => ["post", "gravity"], "gravity" => ["post", "gravity"],