2020-10-13 00:23:17 -04:00
|
|
|
<?php
|
2022-01-02 04:49:50 -05:00
|
|
|
/**
|
|
|
|
* @copyright Copyright (C) 2010-2022, the Friendica project
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2020-10-13 00:23:17 -04:00
|
|
|
|
|
|
|
namespace Friendica\Module\Update;
|
|
|
|
|
2022-10-19 00:43:47 -04:00
|
|
|
use Friendica\Core\Session;
|
2020-10-13 00:23:17 -04:00
|
|
|
use Friendica\Core\System;
|
|
|
|
use Friendica\DI;
|
2022-09-12 17:12:11 -04:00
|
|
|
use Friendica\Model\Item;
|
2021-01-15 23:16:09 -05:00
|
|
|
use Friendica\Model\Post;
|
2020-10-13 00:23:17 -04:00
|
|
|
use Friendica\Module\Conversation\Network as NetworkModule;
|
|
|
|
|
|
|
|
class Network extends NetworkModule
|
|
|
|
{
|
2021-11-20 09:38:03 -05:00
|
|
|
protected function rawContent(array $request = [])
|
2020-10-13 00:23:17 -04:00
|
|
|
{
|
|
|
|
if (!isset($_GET['p']) || !isset($_GET['item'])) {
|
2022-05-17 22:13:54 -04:00
|
|
|
System::exit();
|
2020-10-13 00:23:17 -04:00
|
|
|
}
|
|
|
|
|
2021-11-14 17:19:25 -05:00
|
|
|
$this->parseRequest($_GET);
|
2020-10-13 00:23:17 -04:00
|
|
|
|
|
|
|
$profile_uid = intval($_GET['p']);
|
|
|
|
|
|
|
|
$o = '';
|
|
|
|
|
|
|
|
if (!DI::pConfig()->get($profile_uid, 'system', 'no_auto_update') || ($_GET['force'] == 1)) {
|
|
|
|
if (!empty($_GET['item'])) {
|
2021-01-15 23:16:09 -05:00
|
|
|
$item = Post::selectFirst(['parent'], ['id' => $_GET['item']]);
|
2020-10-13 00:23:17 -04:00
|
|
|
$parent = $item['parent'] ?? 0;
|
|
|
|
} else {
|
|
|
|
$parent = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$conditionFields = [];
|
|
|
|
if (!empty($parent)) {
|
|
|
|
// Load only a single thread
|
|
|
|
$conditionFields['parent'] = $parent;
|
|
|
|
} elseif (self::$order === 'received') {
|
|
|
|
// Only load new toplevel posts
|
|
|
|
$conditionFields['unseen'] = true;
|
2022-09-12 17:12:11 -04:00
|
|
|
$conditionFields['gravity'] = Item::GRAVITY_PARENT;
|
2020-10-13 00:23:17 -04:00
|
|
|
} else {
|
|
|
|
// Load all unseen items
|
|
|
|
$conditionFields['unseen'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$params = ['limit' => 100];
|
|
|
|
$table = 'network-item-view';
|
|
|
|
|
|
|
|
$items = self::getItems($table, $params, $conditionFields);
|
|
|
|
|
|
|
|
if (self::$order === 'received') {
|
|
|
|
$ordering = '`received`';
|
2022-04-20 17:03:33 -04:00
|
|
|
} elseif (self::$order === 'created') {
|
|
|
|
$ordering = '`created`';
|
2020-10-13 00:23:17 -04:00
|
|
|
} else {
|
|
|
|
$ordering = '`commented`';
|
|
|
|
}
|
|
|
|
|
2022-10-19 00:43:47 -04:00
|
|
|
$o = DI::conversation()->create($items, 'network', $profile_uid, false, $ordering, Session::getLocalUser());
|
2020-10-13 00:23:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
System::htmlUpdateExit($o);
|
|
|
|
}
|
|
|
|
}
|