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') 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 From 27f83203531606f6dca99bc89f7cd31e5e296528 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 6 Oct 2017 16:51:39 +0200 Subject: mod display: if we have a local channel we should still be allowed to see sys channel items --- Zotlabs/Module/Display.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 0ea55102e..d405a14b5 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -203,11 +203,12 @@ class Display extends \Zotlabs\Web\Controller { if(local_channel()) { $r = q("SELECT item.id as item_id from item - WHERE uid = %d + WHERE (uid = %d or uid = %d) and mid = '%s' $item_normal limit 1", intval(local_channel()), + intval($sysid), dbesc($target_item['parent_mid']) ); if($r) { -- cgit v1.2.3 From 5468ebbb436a2abe70eea28185209bbd9838f390 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 6 Oct 2017 21:05:37 +0200 Subject: Revert "mod display: if we have a local channel we should still be allowed to see sys channel items" This reverts commit 27f83203531606f6dca99bc89f7cd31e5e296528. --- Zotlabs/Module/Display.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index d405a14b5..0ea55102e 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -203,12 +203,11 @@ class Display extends \Zotlabs\Web\Controller { if(local_channel()) { $r = q("SELECT item.id as item_id from item - WHERE (uid = %d or uid = %d) + WHERE uid = %d and mid = '%s' $item_normal limit 1", intval(local_channel()), - intval($sysid), dbesc($target_item['parent_mid']) ); if($r) { -- cgit v1.2.3 From b883b9c983773f51965680af813dd7e930823460 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 6 Oct 2017 21:30:44 +0200 Subject: enable anonymous comments also in /display --- Zotlabs/Lib/ThreadItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index d916ce2c1..67a507025 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -758,7 +758,7 @@ class ThreadItem { '$cipher' => $conv->get_cipher(), '$sourceapp' => \App::$sourcename, '$observer' => get_observer_hash(), - '$anoncomments' => (($conv->get_mode() === 'channel' && perm_is_allowed($conv->get_profile_owner(),'','post_comments')) ? true : false), + '$anoncomments' => ((($conv->get_mode() === 'channel' || $conv->get_mode() === 'display') && perm_is_allowed($conv->get_profile_owner(),'','post_comments')) ? true : false), '$anonname' => [ 'anonname', t('Your full name (required)') ], '$anonmail' => [ 'anonmail', t('Your email address (required)') ], '$anonurl' => [ 'anonurl', t('Your website URL (optional)') ] -- cgit v1.2.3 From 9bd30eb8bf0299e62a975f4f8ba0a868e5789417 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 6 Oct 2017 21:32:06 +0200 Subject: to find out if a comment is to be moderated we need to look at the actual comment not at its parent --- Zotlabs/Lib/Enotify.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 9f3347d19..6513bcda7 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -97,6 +97,7 @@ class Enotify { $title = $i['title']; $body = $i['body']; $private = (($i['item_private']) || intval($i['item_obscured'])); + $moderated = (($i['item_blocked'] == ITEM_MODERATED) ? true : false); } else { $title = $params['item']['title']; @@ -170,8 +171,6 @@ class Enotify { xchan_query($p); - $moderated = (($p[0]['item_blocked'] == ITEM_MODERATED) ? true : false); - $item_post_type = item_post_type($p[0]); // $private = $p[0]['item_private']; $parent_id = $p[0]['id']; -- cgit v1.2.3 From e7c8012794ffe6ac746223a9d67fa338f7360c57 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 6 Oct 2017 22:25:53 +0200 Subject: no need to move $modrated check up --- Zotlabs/Lib/Enotify.php | 5 +++-- Zotlabs/Module/Moderate.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 6513bcda7..e82c11a35 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -97,7 +97,6 @@ class Enotify { $title = $i['title']; $body = $i['body']; $private = (($i['item_private']) || intval($i['item_obscured'])); - $moderated = (($i['item_blocked'] == ITEM_MODERATED) ? true : false); } else { $title = $params['item']['title']; @@ -131,7 +130,9 @@ class Enotify { if ($params['type'] == NOTIFY_COMMENT) { // logger("notification: params = " . print_r($params, true), LOGGER_DEBUG); - $itemlink = $params['link']; + $moderated = (($params['item']['item_blocked'] == ITEM_MODERATED) ? true : false); + + $itemlink = $params['link']; // ignore like/unlike activity on posts - they probably require a separate notification preference diff --git a/Zotlabs/Module/Moderate.php b/Zotlabs/Module/Moderate.php index 9af43420d..8aaa0897a 100644 --- a/Zotlabs/Module/Moderate.php +++ b/Zotlabs/Module/Moderate.php @@ -73,4 +73,4 @@ class Moderate extends \Zotlabs\Web\Controller { } -} \ No newline at end of file +} -- cgit v1.2.3 From 4c0e8a61aecc5c90d532016dc42f13ab07646335 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 7 Oct 2017 15:40:34 +0200 Subject: provide single post view for pubstream and rewrite llink to point to /pubstream/?f=&mid=some_mid instead of /display/some_mid for pubs notifications --- Zotlabs/Module/Ping.php | 1 + Zotlabs/Module/Pubstream.php | 68 ++++++++++++++++++++++++++++---------------- 2 files changed, 45 insertions(+), 24 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 0acd720d6..e3f430861 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -183,6 +183,7 @@ class Ping extends \Zotlabs\Web\Controller { if($r) { xchan_query($r); foreach($r as $rr) { + $rr['llink'] = str_replace('display/', 'pubstream/?f=&mid=', $rr['llink']); $result[] = \Zotlabs\Lib\Enotify::format($rr); } } diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 72d5f80fa..4583f912b 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -19,7 +19,9 @@ class Pubstream extends \Zotlabs\Web\Controller { $disable_discover_tab = get_config('system','disable_discover_tab') || get_config('system','disable_discover_tab') === false; if($disable_discover_tab) return; - + + $mid = ((x($_REQUEST,'mid')) ? $_REQUEST['mid'] : ''); + $item_normal = item_normal(); $item_normal_update = item_normal_update(); @@ -30,7 +32,8 @@ class Pubstream extends \Zotlabs\Web\Controller { nav_set_selected(t('Public Stream')); - $_SESSION['static_loadtime'] = datetime_convert(); + if(!$mid) + $_SESSION['static_loadtime'] = datetime_convert(); $static = ((local_channel()) ? channel_manual_conv_update(local_channel()) : 1); @@ -68,7 +71,7 @@ class Pubstream extends \Zotlabs\Web\Controller { '$cats' => '', '$tags' => '', '$dend' => '', - '$mid' => '', + '$mid' => $mid, '$verb' => '', '$dbegin' => '' )); @@ -119,29 +122,46 @@ class Pubstream extends \Zotlabs\Web\Controller { $ordering = "commented"; if($load) { - - // Fetch a page full of parent items for this page - - $r = q("SELECT distinct item.id AS item_id, $ordering FROM item - left join abook on item.author_xchan = abook.abook_xchan - WHERE true $uids $item_normal - AND item.parent = item.id - and (abook.abook_blocked = 0 or abook.abook_flags is null) - $sql_extra3 $sql_extra $sql_nets - ORDER BY $ordering DESC $pager_sql " - ); - - + if($mid) { + $r = q("SELECT parent AS item_id FROM item + left join abook on item.author_xchan = abook.abook_xchan + WHERE mid like '%s' $uids $item_normal + and (abook.abook_blocked = 0 or abook.abook_flags is null) + $sql_extra3 $sql_extra $sql_nets", + dbesc($mid . '%') + ); + } + else { + // Fetch a page full of parent items for this page + $r = q("SELECT distinct item.id AS item_id, $ordering FROM item + left join abook on item.author_xchan = abook.abook_xchan + WHERE true $uids $item_normal + AND item.parent = item.id + and (abook.abook_blocked = 0 or abook.abook_flags is null) + $sql_extra3 $sql_extra $sql_nets + ORDER BY $ordering DESC $pager_sql " + ); + } } elseif($update) { - - $r = q("SELECT distinct item.id AS item_id, $ordering FROM item - left join abook on item.author_xchan = abook.abook_xchan - WHERE true $uids $item_normal_update - AND item.parent = item.id $simple_update - and (abook.abook_blocked = 0 or abook.abook_flags is null) - $sql_extra3 $sql_extra $sql_nets" - ); + if($mid) { + $r = q("SELECT parent AS item_id FROM item + left join abook on item.author_xchan = abook.abook_xchan + WHERE mid like '%s' $uids $item_normal_update $simple_update + and (abook.abook_blocked = 0 or abook.abook_flags is null) + $sql_extra3 $sql_extra $sql_nets", + dbesc($mid . '%') + ); + } + else { + $r = q("SELECT distinct item.id AS item_id, $ordering FROM item + left join abook on item.author_xchan = abook.abook_xchan + WHERE true $uids $item_normal_update + AND item.parent = item.id $simple_update + and (abook.abook_blocked = 0 or abook.abook_flags is null) + $sql_extra3 $sql_extra $sql_nets" + ); + } $_SESSION['loadtime'] = datetime_convert(); } // Then fetch all the children of the parents that are on this page -- cgit v1.2.3 From 71c206fdb9d8ccdd0b65feb49db93a58ea51e0e6 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 7 Oct 2017 16:40:43 +0200 Subject: pubstream single view fixes --- Zotlabs/Module/Pubstream.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 4583f912b..15e2d8a74 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -22,13 +22,18 @@ class Pubstream extends \Zotlabs\Web\Controller { $mid = ((x($_REQUEST,'mid')) ? $_REQUEST['mid'] : ''); + if(strpos($mid,'b64.') === 0) + $decoded = @base64url_decode(substr($mid,4)); + if($decoded) + $mid = $decoded; + $item_normal = item_normal(); $item_normal_update = item_normal_update(); $static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0); - if(! $update) { + if(! $update && !$load) { nav_set_selected(t('Public Stream')); @@ -46,6 +51,10 @@ class Pubstream extends \Zotlabs\Web\Controller { . "; var profile_page = " . \App::$pager['page'] . "; divmore_height = " . intval($maxheight) . "; \r\n"; + //if we got a decoded hash we must encode it again before handing to javascript + if($decoded) + $mid = 'b64.' . base64url_encode($mid); + \App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array( '$baseurl' => z_root(), '$pgtype' => 'pubstream', @@ -127,7 +136,7 @@ class Pubstream extends \Zotlabs\Web\Controller { left join abook on item.author_xchan = abook.abook_xchan WHERE mid like '%s' $uids $item_normal and (abook.abook_blocked = 0 or abook.abook_flags is null) - $sql_extra3 $sql_extra $sql_nets", + $sql_extra3 $sql_extra $sql_nets LIMIT 1", dbesc($mid . '%') ); } @@ -149,7 +158,7 @@ class Pubstream extends \Zotlabs\Web\Controller { left join abook on item.author_xchan = abook.abook_xchan WHERE mid like '%s' $uids $item_normal_update $simple_update and (abook.abook_blocked = 0 or abook.abook_flags is null) - $sql_extra3 $sql_extra $sql_nets", + $sql_extra3 $sql_extra $sql_nets LIMIT 1", dbesc($mid . '%') ); } @@ -193,6 +202,9 @@ class Pubstream extends \Zotlabs\Web\Controller { $mode = ('network'); $o .= conversation($items,$mode,$update,$page_mode); + + if($mid) + $o .= '
'; if(($items) && (! $update)) $o .= alt_pager($a,count($items)); -- cgit v1.2.3 From 991db280be4c3cbbff4fb1e4dae8f303a487ed3f Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 8 Oct 2017 17:19:29 +0200 Subject: experimental new notifications - needs pconfig experimental_notif set to 1 for your channel to work. --- Zotlabs/Web/WebServer.php | 2 +- Zotlabs/Widget/Notifications.php | 152 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 Zotlabs/Widget/Notifications.php (limited to 'Zotlabs') diff --git a/Zotlabs/Web/WebServer.php b/Zotlabs/Web/WebServer.php index 0ee735818..9e6af8c4c 100644 --- a/Zotlabs/Web/WebServer.php +++ b/Zotlabs/Web/WebServer.php @@ -107,7 +107,7 @@ class WebServer { check_config(); } - nav_set_selected('nothing'); + //nav_set_selected('nothing'); $Router = new Router($a); diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php new file mode 100644 index 000000000..85e8e6cac --- /dev/null +++ b/Zotlabs/Widget/Notifications.php @@ -0,0 +1,152 @@ + 'network', + 'icon' => 'th', + 'severity' => 'secondary', + 'label' => t('Activity'), + 'title' => t('Network Activity Notifications'), + 'viewall' => [ + 'url' => 'network', + 'label' => t('View your network activity') + ], + 'markall' => [ + 'url' => '#', + 'label' => t('Mark all notifications seen') + ] + ]; + + $notifications[] = [ + 'type' => 'home', + 'icon' => 'home', + 'severity' => 'danger', + 'label' => t('Home'), + 'title' => t('Channel Home Notifications'), + 'viewall' => [ + 'url' => 'channel/' . $channel['channel_address'], + 'label' => t('View your home activity') + ], + 'markall' => [ + 'url' => '#', + 'label' => t('Mark all notifications seen') + ] + ]; + + $notifications[] = [ + 'type' => 'messages', + 'icon' => 'envelope', + 'severity' => 'danger', + 'label' => t('Mail'), + 'title' => t('Private mail'), + 'viewall' => [ + 'url' => 'mail/combined', + 'label' => t('View your private mails') + ], + 'markall' => [ + 'url' => '#', + 'label' => t('Mark all messages seen') + ] + ]; + + $notifications[] = [ + 'type' => 'all_events', + 'icon' => 'calendar', + 'severity' => 'secondary', + 'label' => t('Events'), + 'title' => t('Event Calendar'), + 'viewall' => [ + 'url' => 'mail/combined', + 'label' => t('View events') + ], + 'markall' => [ + 'url' => '#', + 'label' => t('Mark all events seen') + ] + ]; + + $notifications[] = [ + 'type' => 'intros', + 'icon' => 'users', + 'severity' => 'danger', + 'label' => t('New Connections'), + 'title' => t('New Connections'), + 'viewall' => [ + 'url' => 'connections', + 'label' => t('View all connections') + ] + ]; + + $notifications[] = [ + 'type' => 'files', + 'icon' => 'folder', + 'severity' => 'danger', + 'label' => t('New Files'), + 'title' => t('New files shared with me'), + ]; + + $notifications[] = [ + 'type' => 'notify', + 'icon' => 'exclamation', + 'severity' => 'danger', + 'label' => t('Notices'), + 'title' => t('Notices'), + 'viewall' => [ + 'url' => 'notifications/system', + 'label' => t('View all notices') + ], + 'markall' => [ + 'url' => '#', + 'label' => t('Mark all notices seen') + ] + ]; + } + + if(local_channel() && is_site_admin()) { + $notifications[] = [ + 'type' => 'register', + 'icon' => 'user-o', + 'severity' => 'danger', + 'label' => t('New Registrations'), + 'title' => t('New Registrations'), + ]; + } + + $notifications[] = [ + 'type' => 'pubs', + 'icon' => 'globe', + 'severity' => 'secondary', + 'label' => t('Public Stream'), + 'title' => t('Public Stream Notifications'), + 'viewall' => [ + 'url' => 'pubstream', + 'label' => t('View the public stream') + ], + 'markall' => [ + 'url' => '#', + 'label' => t('Mark all notifications seen') + ] + ]; + + + $o = replace_macros(get_markup_template('notifications_widget.tpl'), array( + '$notifications' => $notifications, + '$loading' => t('Loading...') + )); + + return $o; + + } +} + -- cgit v1.2.3