aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Sse.php
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/Sse.php
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/Sse.php')
-rw-r--r--Zotlabs/Module/Sse.php26
1 files changed, 7 insertions, 19 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;
}