diff options
author | Mario Vavti <mario@mariovavti.com> | 2021-01-22 11:12:39 +0100 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2021-01-22 11:12:39 +0100 |
commit | e6aed4fb8ef5853f27100a2b9e2903323c874ce8 (patch) | |
tree | 46169f6b8df8dd5f29d13de663ed80e1df037542 | |
parent | bdd6d878f1d83c1cc7b84ead5e171bf2c3a73b7c (diff) | |
download | volse-hubzilla-e6aed4fb8ef5853f27100a2b9e2903323c874ce8.tar.gz volse-hubzilla-e6aed4fb8ef5853f27100a2b9e2903323c874ce8.tar.bz2 volse-hubzilla-e6aed4fb8ef5853f27100a2b9e2903323c874ce8.zip |
implement externals via zot6 and zotfeed - part 2
-rw-r--r-- | Zotlabs/Module/Zotfeed.php | 42 | ||||
-rwxr-xr-x | boot.php | 2 | ||||
-rwxr-xr-x | include/items.php | 54 |
3 files changed, 66 insertions, 32 deletions
diff --git a/Zotlabs/Module/Zotfeed.php b/Zotlabs/Module/Zotfeed.php index 6f4cd9fc4..e838ae34c 100644 --- a/Zotlabs/Module/Zotfeed.php +++ b/Zotlabs/Module/Zotfeed.php @@ -19,19 +19,11 @@ class Zotfeed extends Controller { killme(); } - if (argc() < 2) { - killme(); - } - - $channel = channelx_by_nick(argv(1)); + $channel = ((argv(1)) ? channelx_by_nick(argv(1)) : get_sys_channel()); if (!$channel) { killme(); } - if (intval($channel['channel_system'])) { - killme(); - } - $sigdata = HTTPSig::verify(($_SERVER['REQUEST_METHOD'] === 'POST') ? file_get_contents('php://input') : EMPTY_STR); if ($sigdata['portable_id'] && $sigdata['header_valid']) { $portable_id = $sigdata['portable_id']; @@ -60,10 +52,32 @@ class Zotfeed extends Controller { $params['cat'] = ((x($_REQUEST, 'cat')) ? escape_tags($_REQUEST['cat']) : ''); $params['compat'] = 1; + if (intval($channel['channel_system'])) { + $total = zot_feed($channel['channel_id'], $observer_hash, ['total' => true]); + + if ($total) { + App::set_pager_total($total); + App::set_pager_itemspage(30); + } + + if (App::$pager['unset'] && $total > 30) { + $ret = Activity::paged_collection_init($total, App::$query_string); + + } + else { + $items = zot_feed($channel['channel_id'], $observer_hash, []); + $ret = Activity::encode_item_collection($items, App::$query_string, 'OrderedCollection', $total); + } + + as_return_and_die($ret, $channel); + + return; + } + $total = items_fetch( [ 'total' => true, - 'wall' => '1', + 'wall' => 1, 'datequery' => $params['end'], 'datequery2' => $params['begin'], 'direction' => dbesc($params['direction']), @@ -77,16 +91,17 @@ class Zotfeed extends Controller { if ($total) { App::set_pager_total($total); - App::set_pager_itemspage(100); + App::set_pager_itemspage(30); } - if (App::$pager['unset'] && $total > 100) { + if (App::$pager['unset'] && $total > 30) { $ret = Activity::paged_collection_init($total, App::$query_string); } else { + $items = items_fetch( [ - 'wall' => '1', + 'wall' => 1, 'datequery' => $params['end'], 'datequery2' => $params['begin'], 'records' => intval(App::$pager['itemspage']), @@ -99,7 +114,6 @@ class Zotfeed extends Controller { 'compat' => $params['compat'] ], $channel, $observer_hash, CLIENT_MODE_NORMAL, App::$module ); - $ret = Activity::encode_item_collection($items, App::$query_string, 'OrderedCollection', $total); } @@ -50,7 +50,7 @@ require_once('include/attach.php'); require_once('include/bbcode.php'); define ( 'PLATFORM_NAME', 'hubzilla' ); -define ( 'STD_VERSION', '5.3.1' ); +define ( 'STD_VERSION', '5.3.2' ); define ( 'ZOT_REVISION', '6.0' ); define ( 'DB_UPDATE_VERSION', 1240 ); diff --git a/include/items.php b/include/items.php index 5b9bbd1f9..370aa5a93 100755 --- a/include/items.php +++ b/include/items.php @@ -4354,6 +4354,7 @@ function zot_feed($uid, $observer_hash, $arr) { if(! is_sys_channel($uid)) $sql_extra = item_permissions_sql($uid,$observer_hash); + $limit = " LIMIT 5000 "; if($mindate > NULL_DATE) { @@ -4375,17 +4376,38 @@ function zot_feed($uid, $observer_hash, $arr) { $item_normal = item_normal(); if(is_sys_channel($uid)) { - $nonsys_uids = q("SELECT channel_id FROM channel WHERE channel_system = 0"); $nonsys_uids_str = ids_to_querystr($nonsys_uids,'channel_id'); - $r = q("SELECT parent, postopts FROM item + if ($arr['total']) { + $items = q("SELECT count(created) AS total FROM item + WHERE uid IN ( %s ) + AND item_private = 0 + $sql_extra $item_normal", + dbesc($nonsys_uids_str) + ); + if ($items) { + return intval($items[0]['total']); + } + return 0; + } + + $itemspage = (($channel) ? get_pconfig($uid,'system','itemspage') : 30); + App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 30)); + $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start'])); + + $items = q("SELECT item.*, item.id AS item_id FROM item WHERE uid IN ( %s ) AND item_private = 0 - $item_normal - $sql_extra ORDER BY created ASC $limit", - intval($nonsys_uids_str) + $item_normal $sql_extra + ORDER BY item.created DESC $pager_sql", + dbesc($nonsys_uids_str) ); + + xchan_query($items); + $items = fetch_post_tags($items,true); + + return $items; } else { $r = q("SELECT parent, postopts FROM item @@ -4411,7 +4433,6 @@ function zot_feed($uid, $observer_hash, $arr) { $parents_str = ids_to_querystr($parents,'parent'); $sys_query = ((is_sys_channel($uid)) ? $sql_extra : ''); - $item_normal = item_normal(); $items = q("SELECT item.*, item.id AS item_id FROM item WHERE item.parent IN ( %s ) $item_normal $sys_query ", @@ -4563,8 +4584,8 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $pager_sql = ''; } else { if(! $arr['total']) { - $itemspage = (($channel) ? get_pconfig($uid,'system','itemspage') : 20); - App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); + $itemspage = (($channel) ? get_pconfig($uid,'system','itemspage') : 10); + App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 10)); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start'])); } } @@ -4602,7 +4623,6 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C require_once('include/security.php'); $sql_extra .= item_permissions_sql($channel['channel_id'],$observer_hash); - if($arr['pages']) $item_restrict = " AND item_type = " . ITEM_TYPE_WEBPAGE . " "; else @@ -4616,7 +4636,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C // "New Item View" - show all items unthreaded in reverse created date order if ($arr['total']) { - $items = q("SELECT count(item.id) AS total FROM item + $items = dbq("SELECT count(item.id) AS total FROM item WHERE $item_uids $item_restrict $simple_update $sql_extra $sql_nets $sql_extra3" @@ -4627,11 +4647,11 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C return 0; } - $items = q("SELECT item.*, item.id AS item_id FROM item - WHERE $item_uids $item_restrict - $simple_update - $sql_extra $sql_nets $sql_extra3 - ORDER BY item.received DESC $pager_sql" + $items = dbq("SELECT item.*, item.id AS item_id FROM item + WHERE $item_uids $item_restrict + $simple_update + $sql_extra $sql_nets $sql_extra3 + ORDER BY item.received DESC $pager_sql" ); require_once('include/items.php'); @@ -4652,7 +4672,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C // Fetch a page full of parent items for this page - $r = q("SELECT distinct item.id AS item_id, item.$ordering FROM item + $r = dbq("SELECT distinct item.id AS item_id, item.$ordering FROM item left join abook on item.author_xchan = abook.abook_xchan WHERE $item_uids $item_restrict AND item.parent = item.id @@ -4663,7 +4683,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C } else { // update - $r = q("SELECT item.parent AS item_id FROM item + $r = dbq("SELECT item.parent AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan WHERE $item_uids $item_restrict $simple_update and (abook.abook_blocked = 0 or abook.abook_flags is null) |