aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Sse_bs.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-10-22 11:33:25 +0000
committerMario <mario@mariovavti.com>2020-10-22 11:33:25 +0000
commit96de38a1f06193d674f8fe89cb1852e0e4abb4cf (patch)
tree8ae120d73a0e59c4e581d7b63b659ad106b1b672 /Zotlabs/Module/Sse_bs.php
parentcef0c2ebb2b16b006eca7dce8ec0b1a95d916dba (diff)
downloadvolse-hubzilla-96de38a1f06193d674f8fe89cb1852e0e4abb4cf.tar.gz
volse-hubzilla-96de38a1f06193d674f8fe89cb1852e0e4abb4cf.tar.bz2
volse-hubzilla-96de38a1f06193d674f8fe89cb1852e0e4abb4cf.zip
adapt notifications and mark item seen handling to play well with client side page caching
Diffstat (limited to 'Zotlabs/Module/Sse_bs.php')
-rw-r--r--Zotlabs/Module/Sse_bs.php39
1 files changed, 34 insertions, 5 deletions
diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php
index 0189c4695..e3439e7dd 100644
--- a/Zotlabs/Module/Sse_bs.php
+++ b/Zotlabs/Module/Sse_bs.php
@@ -36,12 +36,15 @@ class Sse_bs extends Controller {
self::$vnotify = get_pconfig(self::$uid, 'system', 'vnotify', -1);
self::$evdays = intval(get_pconfig(self::$uid, 'system', 'evdays'));
- self::$limit = 30;
+ self::$limit = 50;
self::$offset = 0;
self::$xchans = '';
- if(!empty($_GET['nquery']) && $_GET['nquery'] !== '%') {
- $nquery = $_GET['nquery'];
+ if($_REQUEST['sse_rmids'])
+ self::mark_read($_REQUEST['sse_rmids']);
+
+ if(!empty($_REQUEST['nquery']) && $_REQUEST['nquery'] !== '%') {
+ $nquery = $_REQUEST['nquery'];
$x = q("SELECT xchan_hash FROM xchan WHERE xchan_name LIKE '%s' OR xchan_addr LIKE '%s'",
dbesc($nquery . '%'),
@@ -108,6 +111,31 @@ class Sse_bs extends Controller {
json_return_and_die($result);
}
+ function mark_read($arr) {
+
+ if(! self::$uid)
+ return;
+
+ $mids = [];
+ $str = '';
+
+ foreach($arr as $a) {
+ $mids[] = '\'' . dbesc(@base64url_decode(substr($a,4))) . '\'';
+ }
+
+ $str = implode($mids, ',');
+
+ $x = [ 'channel_id' => self::$uid, 'update' => 'unset' ];
+ call_hooks('update_unseen',$x);
+
+ if($x['update'] === 'unset' || intval($x['update'])) {
+ q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND mid in (". $str . ") AND item_unseen = 1",
+ intval(self::$uid)
+ );
+ }
+
+ }
+
function bs_network($notifications) {
$result['network']['notifications'] = [];
@@ -163,9 +191,10 @@ class Sse_bs extends Controller {
$r = q("SELECT count(id) as total FROM item
WHERE uid = %d and item_unseen = 1 AND item_wall = 0 AND item_private IN (0, 1)
+ AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image')
+ AND author_xchan != '%s'
$item_normal
- $sql_extra
- AND author_xchan != '%s'",
+ $sql_extra",
intval(self::$uid),
dbesc(self::$ob_hash)
);