aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-11-28 08:22:53 +0000
committerMario <mario@mariovavti.com>2019-11-28 08:22:53 +0000
commit2b08519f5ad2cf7803736b42159f92f754acb0bd (patch)
treed496894f37f05e0ef8d09b4c084a4e2cb75f7363 /Zotlabs/Module
parentfcb065bcb2f8e61d1d9e804f8f251967732ee037 (diff)
downloadvolse-hubzilla-2b08519f5ad2cf7803736b42159f92f754acb0bd.tar.gz
volse-hubzilla-2b08519f5ad2cf7803736b42159f92f754acb0bd.tar.bz2
volse-hubzilla-2b08519f5ad2cf7803736b42159f92f754acb0bd.zip
sse: improve caching fix an issue with removing notifications and move chatpresence expiration to cron
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Sse.php26
-rw-r--r--Zotlabs/Module/Sse_bs.php7
2 files changed, 11 insertions, 22 deletions
diff --git a/Zotlabs/Module/Sse.php b/Zotlabs/Module/Sse.php
index b227a396d..b68fe6705 100644
--- a/Zotlabs/Module/Sse.php
+++ b/Zotlabs/Module/Sse.php
@@ -6,6 +6,7 @@ use App;
use Zotlabs\Lib\Apps;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Enotify;
+use Zotlabs\Lib\XConfig;
class Sse extends Controller {
@@ -83,30 +84,17 @@ class Sse extends Controller {
}
}
- /**
- * Chatpresence continued... if somebody hasn't pinged recently, they've most likely left the page
- * and shouldn't count as online anymore. We allow an expection for bots.
- */
- q("delete from chatpresence where cp_last < %s - INTERVAL %s and cp_client != 'auto' ",
- db_utcnow(),
- db_quoteinterval('3 MINUTE')
- );
+ XConfig::Load(self::$ob_hash);
- $x = q("SELECT v FROM xconfig WHERE xchan = '%s' AND cat = 'sse' AND k = 'notifications'",
- dbesc(self::$ob_hash)
- );
-
- if($x) {
- $result = unserialize($x[0]['v']);
- }
+ $result = XConfig::Get(self::$ob_hash, 'sse', 'notifications', []);
+ $lock = XConfig::Get(self::$ob_hash, 'sse', 'lock');
- if($result) {
+ if($result && !$lock) {
echo "event: notifications\n";
echo 'data: ' . json_encode($result);
echo "\n\n";
- set_xconfig(self::$ob_hash, 'sse', 'notifications', []);
- set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert());
+ XConfig::Set(self::$ob_hash, 'sse', 'notifications', []);
unset($result);
}
@@ -120,7 +108,7 @@ class Sse extends Controller {
if(connection_status() != CONNECTION_NORMAL || connection_aborted()) {
//TODO: this does not seem to be triggered
- set_xconfig(self::$ob_hash, 'sse', 'timestamp', NULL_DATE);
+ XConfig::Set(self::$ob_hash, 'sse', 'timestamp', NULL_DATE);
break;
}
diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php
index 270e8b9b9..5e00593ef 100644
--- a/Zotlabs/Module/Sse_bs.php
+++ b/Zotlabs/Module/Sse_bs.php
@@ -40,9 +40,6 @@ class Sse_bs extends Controller {
self::$offset = 0;
self::$xchans = '';
- set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert());
- set_xconfig(self::$ob_hash, 'sse', 'language', App::$language);
-
if(!empty($_GET['nquery']) && $_GET['nquery'] !== '%') {
$nquery = $_GET['nquery'];
@@ -80,6 +77,10 @@ class Sse_bs extends Controller {
default:
}
+ set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert());
+ set_xconfig(self::$ob_hash, 'sse', 'notifications', []); // reset the cache
+ set_xconfig(self::$ob_hash, 'sse', 'language', App::$language);
+
if(self::$offset && $f) {
$result = self::$f(true);
json_return_and_die($result);