Most user-item traces removed
This commit is contained in:
parent
ac03399a90
commit
c1d99d6c4c
32
database.sql
32
database.sql
|
@ -1,6 +1,6 @@
|
|||
-- ------------------------------------------
|
||||
-- Friendica 2021.03-dev (Red Hot Poker)
|
||||
-- DB_UPDATE_VERSION 1396
|
||||
-- DB_UPDATE_VERSION 1397
|
||||
-- ------------------------------------------
|
||||
|
||||
|
||||
|
@ -684,7 +684,6 @@ CREATE TABLE IF NOT EXISTS `item` (
|
|||
`guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this item',
|
||||
`uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||
`uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
|
||||
`uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
|
||||
`parent` int unsigned COMMENT 'item.id of the parent to this item if it is a reply of some form; otherwise this must be set to the id of this item',
|
||||
`parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT 'uri of the top-level parent to this item',
|
||||
`parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the top-level parent uri',
|
||||
|
@ -720,6 +719,7 @@ CREATE TABLE IF NOT EXISTS `item` (
|
|||
`psid` int unsigned COMMENT 'ID of the permission set of this post',
|
||||
`resource-id` varchar(32) NOT NULL DEFAULT '' COMMENT 'Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type',
|
||||
`event-id` int unsigned COMMENT 'Used to link to the event.id',
|
||||
`uri-hash` varchar(80) COMMENT 'Deprecated',
|
||||
`iaid` int unsigned COMMENT 'Deprecated',
|
||||
`icid` int unsigned COMMENT 'Deprecated',
|
||||
`attach` mediumtext COMMENT 'Deprecated',
|
||||
|
@ -1141,6 +1141,26 @@ CREATE TABLE IF NOT EXISTS `post-tag` (
|
|||
FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
|
||||
|
||||
--
|
||||
-- TABLE post-thread-user
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS `post-thread-user` (
|
||||
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
|
||||
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
|
||||
`pinned` boolean NOT NULL DEFAULT '0' COMMENT 'The thread is pinned on the profile page',
|
||||
`starred` boolean NOT NULL DEFAULT '0' COMMENT '',
|
||||
`ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
|
||||
`wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
|
||||
`pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
|
||||
`forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
|
||||
PRIMARY KEY(`uid`,`uri-id`),
|
||||
INDEX `uid_wall` (`uid`,`wall`),
|
||||
INDEX `uid_pinned` (`uid`,`pinned`),
|
||||
INDEX `uri-id` (`uri-id`),
|
||||
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
||||
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
|
||||
|
||||
--
|
||||
-- TABLE post-user
|
||||
--
|
||||
|
@ -1848,13 +1868,13 @@ CREATE VIEW `network-item-view` AS SELECT
|
|||
FROM `item`
|
||||
INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
|
||||
STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
|
||||
LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
|
||||
LEFT JOIN `post-user` ON `post-user`.`uri-id` = `item`.`uri-id` AND `post-user`.`uid` = `thread`.`uid`
|
||||
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
|
||||
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
|
||||
LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
|
||||
WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
|
||||
AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
|
||||
AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
|
||||
AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
|
||||
AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
|
||||
AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
|
||||
|
||||
|
@ -1879,13 +1899,13 @@ CREATE VIEW `network-thread-view` AS SELECT
|
|||
FROM `thread`
|
||||
STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
|
||||
STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
|
||||
LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
|
||||
LEFT JOIN `post-user` ON `post-user`.`uri-id` = `item`.`uri-id` AND `post-user`.`uid` = `thread`.`uid`
|
||||
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
|
||||
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
|
||||
LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
|
||||
WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
|
||||
AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
|
||||
AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
|
||||
AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
|
||||
AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
|
||||
AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
|
||||
|
||||
|
|
|
@ -149,9 +149,8 @@ function notification($params)
|
|||
}
|
||||
|
||||
if ($params['type'] == Notification\Type::COMMENT || $params['type'] == Notification\Type::TAG_SELF) {
|
||||
$thread = Post::selectFirstThreadForUser($params['uid'], ['ignored'], ['iid' => $parent_id, 'deleted' => false]);
|
||||
if (DBA::isResult($thread) && $thread['ignored']) {
|
||||
Logger::log('Thread ' . $parent_id . ' will be ignored', Logger::DEBUG);
|
||||
if (Post\ThreadUser::getIgnored($parent_uri_id, $params['uid'])) {
|
||||
Logger::info('Thread is ignored', ['parent' => $parent_id, 'parent-uri-id' => $parent_uri_id]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,9 +77,9 @@ class Status extends BaseFactory
|
|||
$userAttributes = new \Friendica\Object\Api\Mastodon\Status\UserAttributes(
|
||||
Post::exists(['thr-parent-id' => $uriId, 'uid' => $uid, 'origin' => true, 'gravity' => GRAVITY_ACTIVITY, 'vid' => Verb::getID(Activity::LIKE)]),
|
||||
Post::exists(['thr-parent-id' => $uriId, 'uid' => $uid, 'origin' => true, 'gravity' => GRAVITY_ACTIVITY, 'vid' => Verb::getID(Activity::ANNOUNCE)]),
|
||||
DBA::exists('thread', ['iid' => $item['id'], 'uid' => $item['uid'], 'ignored' => true]),
|
||||
Post\ThreadUser::getIgnored($uriId, $item['uid']),
|
||||
(bool)$item['starred'],
|
||||
DBA::exists('user-item', ['iid' => $item['id'], 'uid' => $item['uid'], 'pinned' => true])
|
||||
Post\ThreadUser::getPinned($uriId, $item['uid'])
|
||||
);
|
||||
|
||||
$sensitive = DBA::exists('tag-view', ['uri-id' => $uriId, 'name' => 'nsfw']);
|
||||
|
|
|
@ -31,7 +31,6 @@ use Friendica\Core\Session;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\DI;
|
||||
|
@ -133,49 +132,6 @@ class Item
|
|||
const PRIVATE = 1;
|
||||
const UNLISTED = 2;
|
||||
|
||||
const TABLES = ['item', 'user-item', 'post-content', 'post-delivery-data', 'diaspora-interaction'];
|
||||
|
||||
private static function getItemFields()
|
||||
{
|
||||
$definition = DBStructure::definition('', false);
|
||||
|
||||
$postfields = [];
|
||||
foreach (self::TABLES as $table) {
|
||||
$postfields[$table] = array_keys($definition[$table]['fields']);
|
||||
}
|
||||
|
||||
return $postfields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the pinned state of an item
|
||||
*
|
||||
* @param integer $iid Item ID
|
||||
* @param integer $uid User ID
|
||||
* @param boolean $pinned Pinned state
|
||||
*/
|
||||
public static function setPinned(int $iid, int $uid, bool $pinned)
|
||||
{
|
||||
DBA::update('user-item', ['pinned' => $pinned], ['iid' => $iid, 'uid' => $uid], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pinned state
|
||||
*
|
||||
* @param integer $iid Item ID
|
||||
* @param integer $uid User ID
|
||||
*
|
||||
* @return boolean pinned state
|
||||
*/
|
||||
public static function getPinned(int $iid, int $uid)
|
||||
{
|
||||
$useritem = DBA::selectFirst('user-item', ['pinned'], ['iid' => $iid, 'uid' => $uid]);
|
||||
if (!DBA::isResult($useritem)) {
|
||||
return false;
|
||||
}
|
||||
return (bool)$useritem['pinned'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update existing item entries
|
||||
*
|
||||
|
@ -285,12 +241,9 @@ class Item
|
|||
Post\User::update($item['uri-id'], $uid, ['hidden' => true], true);
|
||||
}
|
||||
|
||||
// "Deleting" global items just means hiding them
|
||||
if ($item['uid'] == 0) {
|
||||
DBA::update('user-item', ['hidden' => true], ['iid' => $item['id'], 'uid' => $uid], true);
|
||||
} elseif ($item['uid'] == $uid) {
|
||||
if ($item['uid'] == $uid) {
|
||||
self::markForDeletionById($item['id'], PRIORITY_HIGH);
|
||||
} else {
|
||||
} elseif ($item['uid'] != 0) {
|
||||
Logger::log('Wrong ownership. Not deleting item ' . $item['id']);
|
||||
}
|
||||
}
|
||||
|
@ -393,12 +346,6 @@ class Item
|
|||
}
|
||||
} elseif ($item['uid'] != 0) {
|
||||
Post\User::update($item['uri-id'], $item['uid'], ['hidden' => true]);
|
||||
|
||||
// When we delete just our local user copy of an item, we have to set a marker to hide it
|
||||
$global_item = Post::selectFirst(['id'], ['uri-id' => $item['uri-id'], 'uid' => 0, 'deleted' => false]);
|
||||
if (DBA::isResult($global_item)) {
|
||||
DBA::update('user-item', ['hidden' => true], ['iid' => $global_item['id'], 'uid' => $item['uid']], true);
|
||||
}
|
||||
}
|
||||
|
||||
Logger::info('Item has been marked for deletion.', ['id' => $item_id]);
|
||||
|
@ -755,8 +702,6 @@ class Item
|
|||
|
||||
public static function insert($item, $notify = false, $dontcache = false)
|
||||
{
|
||||
$structure = self::getItemFields();
|
||||
|
||||
$orig_item = $item;
|
||||
|
||||
$priority = PRIORITY_HIGH;
|
||||
|
@ -1103,19 +1048,15 @@ class Item
|
|||
Post\ThreadUser::insert($item['uri-id'], $item['uid'], $item);
|
||||
}
|
||||
|
||||
// Remove all fields that aren't part of the item table
|
||||
foreach ($item as $field => $value) {
|
||||
if (!in_array($field, $structure['item'])) {
|
||||
unset($item[$field]);
|
||||
}
|
||||
}
|
||||
|
||||
$condition = ['uri-id' => $item['uri-id'], 'uid' => $item['uid'], 'network' => $item['network']];
|
||||
if (Post::exists($condition)) {
|
||||
Logger::notice('Item is already inserted - aborting', $condition);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Remove all fields that aren't part of the item table
|
||||
$item = DBStructure::getFieldsForTable('item', $item);
|
||||
|
||||
$result = DBA::insert('item', $item);
|
||||
|
||||
// When the item was successfully stored we fetch the ID of the item.
|
||||
|
|
|
@ -272,7 +272,7 @@ class Post
|
|||
unset($selected['pinned']);
|
||||
$selected = array_flip($selected);
|
||||
|
||||
$select_string = "(SELECT `pinned` FROM `user-item` WHERE `iid` = `" . $view . "`.`id` AND uid=`" . $view . "`.`uid`) AS `pinned`, ";
|
||||
$select_string = "(SELECT `pinned` FROM `post-thread-user` WHERE `uri-id` = `" . $view . "`.`uri-id` AND uid=`" . $view . "`.`uid`) AS `pinned`, ";
|
||||
}
|
||||
|
||||
$select_string .= implode(', ', array_map([DBA::class, 'quoteIdentifier'], $selected));
|
||||
|
@ -344,32 +344,6 @@ class Post
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single record from the starting post in the item table and returns it in an associative array
|
||||
*
|
||||
* @param integer $uid User ID
|
||||
* @param array $selected
|
||||
* @param array $condition
|
||||
* @param array $params
|
||||
* @return bool|array
|
||||
* @throws \Exception
|
||||
* @see DBA::select
|
||||
*/
|
||||
public static function selectFirstThreadForUser($uid, array $selected = [], array $condition = [], $params = [])
|
||||
{
|
||||
$params['limit'] = 1;
|
||||
|
||||
$result = self::selectThreadForUser($uid, $selected, $condition, $params);
|
||||
|
||||
if (is_bool($result)) {
|
||||
return $result;
|
||||
} else {
|
||||
$row = self::fetch($result);
|
||||
DBA::close($result);
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Select pinned rows from the item table for a given user
|
||||
*
|
||||
|
@ -383,24 +357,24 @@ class Post
|
|||
*/
|
||||
public static function selectPinned(int $uid, array $selected = [], array $condition = [], $params = [])
|
||||
{
|
||||
$useritems = DBA::select('user-item', ['iid'], ['uid' => $uid, 'pinned' => true]);
|
||||
if (!DBA::isResult($useritems)) {
|
||||
return $useritems;
|
||||
$postthreaduser = DBA::select('post-thread-user', ['uri-id'], ['uid' => $uid, 'pinned' => true]);
|
||||
if (!DBA::isResult($postthreaduser)) {
|
||||
return $postthreaduser;
|
||||
}
|
||||
|
||||
|
||||
$pinned = [];
|
||||
while ($useritem = DBA::fetch($useritems)) {
|
||||
$pinned[] = $useritem['iid'];
|
||||
while ($useritem = DBA::fetch($postthreaduser)) {
|
||||
$pinned[] = $useritem['uri-id'];
|
||||
}
|
||||
DBA::close($useritems);
|
||||
DBA::close($postthreaduser);
|
||||
|
||||
if (empty($pinned)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$condition = DBA::mergeConditions(['iid' => $pinned], $condition);
|
||||
$condition = DBA::mergeConditions(['uri-id' => $pinned, 'uid' => $uid, 'gravity' => GRAVITY_PARENT], $condition);
|
||||
|
||||
return self::selectThreadForUser($uid, $selected, $condition, $params);
|
||||
return self::selectForUser($uid, $selected, $condition, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -96,4 +96,58 @@ class ThreadUser
|
|||
{
|
||||
return DBA::delete('post-thread-user', $conditions, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $uri_id
|
||||
* @param int $uid
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getIgnored(int $uri_id, int $uid)
|
||||
{
|
||||
$threaduser = DBA::selectFirst('post-thread-user', ['ignored'], ['uri-id' => $uri_id, 'uid' => $uid]);
|
||||
if (empty($threaduser)) {
|
||||
return false;
|
||||
}
|
||||
return (bool)$threaduser['ignored'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $uri_id
|
||||
* @param int $uid
|
||||
* @param int $ignored
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function setIgnored(int $uri_id, int $uid, int $ignored)
|
||||
{
|
||||
DBA::update('post-thread-user', ['ignored' => $ignored], ['uri-id' => $uri_id, 'uid' => $uid], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $uri_id
|
||||
* @param int $uid
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getPinned(int $uri_id, int $uid)
|
||||
{
|
||||
$threaduser = DBA::selectFirst('post-thread-user', ['pinned'], ['uri-id' => $uri_id, 'uid' => $uid]);
|
||||
if (empty($threaduser)) {
|
||||
return false;
|
||||
}
|
||||
return (bool)$threaduser['pinned'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $uri_id
|
||||
* @param int $uid
|
||||
* @param int $pinned
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function setPinned(int $uri_id, int $uid, int $pinned)
|
||||
{
|
||||
DBA::update('post-thread-user', ['pinned' => $pinned], ['uri-id' => $uri_id, 'uid' => $uid], true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ class UserItem
|
|||
public static function setNotification(int $iid)
|
||||
{
|
||||
$fields = ['id', 'uri-id', 'parent-uri-id', 'uid', 'body', 'parent', 'gravity',
|
||||
'private', 'contact-id', 'thr-parent', 'parent-uri', 'author-id', 'verb'];
|
||||
'private', 'contact-id', 'thr-parent', 'parent-uri-id', 'parent-uri', 'author-id', 'verb'];
|
||||
$item = Post::selectFirst($fields, ['id' => $iid, 'origin' => false]);
|
||||
if (!DBA::isResult($item)) {
|
||||
return;
|
||||
|
@ -92,8 +92,7 @@ class UserItem
|
|||
*/
|
||||
private static function setNotificationForUser(array $item, int $uid)
|
||||
{
|
||||
$thread = Post::selectFirstThreadForUser($uid, ['ignored'], ['iid' => $item['parent'], 'deleted' => false]);
|
||||
if (!empty($thread['ignored'])) {
|
||||
if (Post\ThreadUser::getIgnored($item['parent-uri-id'], $uid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,27 +49,17 @@ class Ignore extends BaseModule
|
|||
|
||||
$dba = DI::dba();
|
||||
|
||||
$thread = Post::selectFirstThreadForUser(local_user(), ['uid', 'ignored'], ['iid' => $itemId]);
|
||||
$thread = Post::selectFirst(['uri-id', 'uid'], ['id' => $itemId, 'gravity' => GRAVITY_PARENT]);
|
||||
if (!$dba->isResult($thread)) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
// Numeric values are needed for the json output further below
|
||||
$ignored = !empty($thread['ignored']) ? 0 : 1;
|
||||
$ignored = !Post\ThreadUser::getIgnored($thread['uri-id'], local_user());
|
||||
|
||||
switch ($thread['uid'] ?? 0) {
|
||||
// if the thread is from the current user
|
||||
case local_user():
|
||||
$dba->update('thread', ['ignored' => $ignored], ['iid' => $itemId]);
|
||||
break;
|
||||
// 0 (null will get transformed to 0) => it's a public post
|
||||
case 0:
|
||||
$dba->update('user-item', ['ignored' => $ignored], ['iid' => $itemId, 'uid' => local_user()], true);
|
||||
break;
|
||||
// Throws a BadRequestException and not a ForbiddenException on purpose
|
||||
// Avoids harvesting existing, but forbidden IIDs (security issue)
|
||||
default:
|
||||
throw new HTTPException\BadRequestException();
|
||||
if (in_array($thread['uid'], [0, local_user()])) {
|
||||
Post\ThreadUser::setIgnored($thread['uri-id'], local_user(), $ignored);
|
||||
} else {
|
||||
throw new HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
// See if we've been passed a return path to redirect to
|
||||
|
|
|
@ -24,8 +24,9 @@ namespace Friendica\Module\Item;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
/**
|
||||
|
@ -47,9 +48,18 @@ class Pin extends BaseModule
|
|||
|
||||
$itemId = intval($parameters['id']);
|
||||
|
||||
$pinned = !Item::getPinned($itemId, local_user());
|
||||
$item = Post::selectFirst(['uri-id', 'uid'], ['id' => $itemId]);
|
||||
if (!DBA::isResult($item)) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
Item::setPinned($itemId, local_user(), $pinned);
|
||||
if (!in_array($item['uid'], [0, local_user()])) {
|
||||
throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
|
||||
}
|
||||
|
||||
$pinned = !Post\ThreadUser::getPinned($item['uri-id'], local_user());
|
||||
|
||||
Post\ThreadUser::setPinned($item['uri-id'], local_user(), $pinned);
|
||||
|
||||
// See if we've been passed a return path to redirect to
|
||||
$return_path = $_REQUEST['return'] ?? '';
|
||||
|
|
|
@ -307,17 +307,15 @@ class Post
|
|||
|
||||
if ($this->isToplevel()) {
|
||||
if(local_user()) {
|
||||
$thread = PostModel::selectFirstThreadForUser(local_user(), ['ignored'], ['iid' => $item['id']]);
|
||||
if (DBA::isResult($thread)) {
|
||||
$ignore = [
|
||||
'do' => DI::l10n()->t("ignore thread"),
|
||||
'undo' => DI::l10n()->t("unignore thread"),
|
||||
'toggle' => DI::l10n()->t("toggle ignore status"),
|
||||
'classdo' => $thread['ignored'] ? "hidden" : "",
|
||||
'classundo' => $thread['ignored'] ? "" : "hidden",
|
||||
'ignored' => DI::l10n()->t('ignored'),
|
||||
];
|
||||
}
|
||||
$ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], local_user());
|
||||
$ignore = [
|
||||
'do' => DI::l10n()->t("ignore thread"),
|
||||
'undo' => DI::l10n()->t("unignore thread"),
|
||||
'toggle' => DI::l10n()->t("toggle ignore status"),
|
||||
'classdo' => $ignored ? "hidden" : "",
|
||||
'classundo' => $ignored ? "" : "hidden",
|
||||
'ignored' => DI::l10n()->t('ignored'),
|
||||
];
|
||||
|
||||
if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) {
|
||||
if ($origin) {
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
use Friendica\Database\DBA;
|
||||
|
||||
if (!defined('DB_UPDATE_VERSION')) {
|
||||
define('DB_UPDATE_VERSION', 1396);
|
||||
define('DB_UPDATE_VERSION', 1397);
|
||||
}
|
||||
|
||||
return [
|
||||
|
@ -750,7 +750,6 @@ return [
|
|||
"guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this item"],
|
||||
"uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
||||
"uri-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"],
|
||||
"uri-hash" => ["type" => "varchar(80)", "not null" => "1", "default" => "", "comment" => "RIPEMD-128 hash from uri"],
|
||||
"parent" => ["type" => "int unsigned", "relation" => ["item" => "id"], "comment" => "item.id of the parent to this item if it is a reply of some form; otherwise this must be set to the id of this item"],
|
||||
"parent-uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "uri of the top-level parent to this item"],
|
||||
"parent-uri-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table that contains the top-level parent uri"],
|
||||
|
@ -774,7 +773,7 @@ return [
|
|||
"visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
|
||||
"moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
|
||||
"deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been deleted"],
|
||||
// User specific fields. Eventually they will move to user-item
|
||||
// User specific fields. Eventually they will move to post-user and post-thread-user
|
||||
"uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], "comment" => "Owner id which owns this copy of the item"],
|
||||
"contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id"], "comment" => "contact.id"],
|
||||
"wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "This item was posted to the wall of uid"],
|
||||
|
@ -789,6 +788,7 @@ return [
|
|||
"resource-id" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => "Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type"],
|
||||
"event-id" => ["type" => "int unsigned", "relation" => ["event" => "id"], "comment" => "Used to link to the event.id"],
|
||||
// Deprecated fields. Will be removed in upcoming versions
|
||||
"uri-hash" => ["type" => "varchar(80)", "comment" => "Deprecated"],
|
||||
"iaid" => ["type" => "int unsigned", "comment" => "Deprecated"],
|
||||
"icid" => ["type" => "int unsigned", "comment" => "Deprecated"],
|
||||
"attach" => ["type" => "mediumtext", "comment" => "Deprecated"],
|
||||
|
@ -1208,6 +1208,7 @@ return [
|
|||
"indexes" => [
|
||||
"PRIMARY" => ["uid", "uri-id"],
|
||||
"uid_wall" => ["uid", "wall"],
|
||||
"uid_pinned" => ["uid", "pinned"],
|
||||
"uri-id" => ["uri-id"],
|
||||
]
|
||||
],
|
||||
|
|
|
@ -395,13 +395,13 @@
|
|||
"query" => "FROM `item`
|
||||
INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
|
||||
STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
|
||||
LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
|
||||
LEFT JOIN `post-user` ON `post-user`.`uri-id` = `item`.`uri-id` AND `post-user`.`uid` = `thread`.`uid`
|
||||
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
|
||||
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
|
||||
LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
|
||||
WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
|
||||
AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
|
||||
AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
|
||||
AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
|
||||
AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
|
||||
AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
|
||||
],
|
||||
|
@ -424,13 +424,13 @@
|
|||
"query" => "FROM `thread`
|
||||
STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
|
||||
STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
|
||||
LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
|
||||
LEFT JOIN `post-user` ON `post-user`.`uri-id` = `item`.`uri-id` AND `post-user`.`uid` = `thread`.`uid`
|
||||
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
|
||||
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
|
||||
LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
|
||||
WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
|
||||
AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
|
||||
AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
|
||||
AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
|
||||
AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
|
||||
AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
|
||||
],
|
||||
|
|
|
@ -715,9 +715,9 @@ function update_1396()
|
|||
return Update::SUCCESS;
|
||||
}
|
||||
|
||||
function update_139x()
|
||||
function update_1397()
|
||||
{
|
||||
if (!DBStructure::existsTable('thread') || DBStructure::existsTable('user-item')) {
|
||||
if (!DBStructure::existsTable('thread') || !DBStructure::existsTable('user-item')) {
|
||||
return Update::SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user