aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2023-09-10 19:09:55 +0000
committerMario <mario@mariovavti.com>2023-09-10 19:09:55 +0000
commit75e75b93cff5b2fb5d6243a908ee003b3faf010a (patch)
tree6169ce5d7e0857f6ecb32275672c9e7238864700 /Zotlabs/Module
parent0e8ecbc9fc108b4903eb013ca0a4a1f4beb5fbe1 (diff)
downloadvolse-hubzilla-75e75b93cff5b2fb5d6243a908ee003b3faf010a.tar.gz
volse-hubzilla-75e75b93cff5b2fb5d6243a908ee003b3faf010a.tar.bz2
volse-hubzilla-75e75b93cff5b2fb5d6243a908ee003b3faf010a.zip
an attempt to cache seen item mids for the purpose that we can hide seen pubstream items from the notifications - might revert if it turns out that it does not scale
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Pubstream.php3
-rw-r--r--Zotlabs/Module/Sse_bs.php40
2 files changed, 33 insertions, 10 deletions
diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php
index 4bd1faeff..4b1cd6afb 100644
--- a/Zotlabs/Module/Pubstream.php
+++ b/Zotlabs/Module/Pubstream.php
@@ -99,9 +99,6 @@ class Pubstream extends \Zotlabs\Web\Controller {
nav_set_selected(t('Public Stream'));
- if(!$mid)
- $_SESSION['static_loadtime'] = datetime_convert();
-
$maxheight = get_config('system','home_divmore_height');
if(! $maxheight)
$maxheight = 400;
diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php
index fdaab4ab8..78adf1859 100644
--- a/Zotlabs/Module/Sse_bs.php
+++ b/Zotlabs/Module/Sse_bs.php
@@ -7,6 +7,7 @@ use Zotlabs\Lib\Apps;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Enotify;
use Zotlabs\Lib\XConfig;
+use Zotlabs\Lib\Cache;
class Sse_bs extends Controller {
@@ -117,14 +118,29 @@ class Sse_bs extends Controller {
function mark_read($arr) {
- if(! self::$uid)
- return;
-
$mids = [];
$str = '';
+ $mids_all_json = Cache::get('sse_mids_all_' . session_id());
+
+ if (!$mids_all_json)
+ $mids_all_json = '[]';
+
+ $mids_all = json_decode($mids_all_json, true);
+
foreach($arr as $a) {
- $mids[] = '\'' . dbesc(unpack_link_id($a)) . '\'';
+ $mid_str = '\'' . dbesc(unpack_link_id($a)) . '\'';
+ $mids[] = $mid_str;
+
+ if (!in_array($mid_str, $mids_all)) {
+ $mids_all[] = $mid_str;
+ }
+ }
+
+ Cache::set('sse_mids_all_' . session_id(), json_encode($mids_all));
+
+ if(! self::$uid) {
+ return;
}
$str = implode(',', $mids);
@@ -411,8 +427,9 @@ class Sse_bs extends Controller {
}
}
- if(! isset($_SESSION['static_loadtime']))
+ if(!isset($_SESSION['static_loadtime'])) {
$_SESSION['static_loadtime'] = datetime_convert();
+ }
$limit = intval(self::$limit);
$offset = self::$offset;
@@ -430,6 +447,13 @@ class Sse_bs extends Controller {
if(self::$xchans)
$sql_extra2 = " AND CASE WHEN verb = '" . ACTIVITY_SHARE . "' THEN owner_xchan ELSE author_xchan END IN (" . self::$xchans . ") ";
+ $sql_extra3 = '';
+ $sse_mids_all_json = Cache::get('sse_mids_all_' . session_id());
+ if ($sse_mids_all_json) {
+ $sse_mids_all = json_decode($sse_mids_all_json, true);
+ $sql_extra3 = " AND mid NOT IN (" . protect_sprintf(implode(',', $sse_mids_all)) . ") ";
+ }
+
$uids = " AND uid IN ( " . $sys['channel_id'] . " ) ";
$site_firehose = get_config('system', 'site_firehose', 0);
@@ -452,10 +476,11 @@ class Sse_bs extends Controller {
$item_normal
$sql_extra
$sql_extra2
+ $sql_extra3
ORDER BY created DESC LIMIT $limit OFFSET $offset",
dbescdate($_SESSION['sse_loadtime']),
dbesc(self::$ob_hash),
- dbescdate($_SESSION['static_loadtime'])
+ dbescdate($_SESSION['last_login_date'] ?? $_SESSION['static_loadtime'])
);
if($items) {
@@ -478,8 +503,9 @@ class Sse_bs extends Controller {
AND created > '%s'
$item_normal
$sql_extra
+ $sql_extra3
AND author_xchan != '%s' LIMIT 100",
- dbescdate($_SESSION['static_loadtime']),
+ dbescdate($_SESSION['last_login_date'] ?? $_SESSION['static_loadtime']),
dbesc(self::$ob_hash)
);