From f427b4a325e3db897afc33a09fb04d9af765a53f Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 6 Oct 2017 16:46:27 +0200 Subject: introduce public stream notifications --- Zotlabs/Module/Ping.php | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module/Ping.php') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 3cda6a277..0acd720d6 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -19,6 +19,7 @@ class Ping extends \Zotlabs\Web\Controller { * @result JSON */ function init() { + $result = array(); $notifs = array(); @@ -139,8 +140,8 @@ class Ping extends \Zotlabs\Web\Controller { db_utcnow(), db_quoteinterval('3 MINUTE') ); - $disable_discover_tab = get_config('system','disable_discover_tab') || get_config('system','disable_discover_tab') === false; - $notify_pubs = ((local_channel()) ? ($vnotify & VNOTIFY_PUBS) && !$disable_discover_tab : !$disable_discover_tab); + $discover_tab_on = ((get_config('system','disable_discover_tab') != 1) ? true : false); + $notify_pubs = ((local_channel()) ? ($vnotify & VNOTIFY_PUBS) && $discover_tab_on : $discover_tab_on); if($notify_pubs) { $sys = get_sys_channel(); @@ -161,6 +162,36 @@ class Ping extends \Zotlabs\Web\Controller { $result['pubs'] = intval($pubs[0]['total']); } + if((argc() > 1) && (argv(1) === 'pubs') && ($notify_pubs)) { + $sys = get_sys_channel(); + $result = array(); + + $r = q("SELECT * FROM item + WHERE uid = %d + AND author_xchan != '%s' + AND obj_type != '%s' + AND item_unseen = 1 + AND created > '" . datetime_convert('UTC','UTC',$_SESSION['static_loadtime']) . "' + $item_normal + ORDER BY created DESC + LIMIT 300", + intval($sys['channel_id']), + dbesc(get_observer_hash()), + dbesc(ACTIVITY_OBJ_FILE) + ); + + if($r) { + xchan_query($r); + foreach($r as $rr) { + $result[] = \Zotlabs\Lib\Enotify::format($rr); + } + } + +// logger('ping (network||home): ' . print_r($result, true), LOGGER_DATA); + echo json_encode(array('notify' => $result)); + killme(); + } + $t1 = dba_timer(); if((! local_channel()) || ($result['invalid'])) { @@ -206,6 +237,9 @@ class Ping extends \Zotlabs\Web\Controller { intval(local_channel()) ); break; + case 'pubs': + unset($_SESSION['static_loadtime']); + break; default: break; } -- cgit v1.2.3