aboutsummaryrefslogtreecommitdiffstats
path: root/boot.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-11-11 21:30:38 +0100
committerMax Kostikov <max@kostikov.co>2019-11-11 21:30:38 +0100
commitb033597ada02ef045bc9fbdb2237f81935b73e47 (patch)
treeecc8af0a821436c576e01627ee3c76c6c8ba254d /boot.php
parent89342ca9fbf329d5e84839c51f26db19bdd4ac8c (diff)
downloadvolse-hubzilla-b033597ada02ef045bc9fbdb2237f81935b73e47.tar.gz
volse-hubzilla-b033597ada02ef045bc9fbdb2237f81935b73e47.tar.bz2
volse-hubzilla-b033597ada02ef045bc9fbdb2237f81935b73e47.zip
sse notifications
Diffstat (limited to 'boot.php')
-rwxr-xr-xboot.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/boot.php b/boot.php
index a9d93b5ae..9588d2c2a 100755
--- a/boot.php
+++ b/boot.php
@@ -1811,6 +1811,8 @@ function can_view_public_stream() {
* @param string $s Text to display
*/
function notice($s) {
+
+/*
if(! session_id())
return;
@@ -1826,6 +1828,34 @@ function notice($s) {
if(App::$interactive) {
$_SESSION['sysmsg'][] = $s;
}
+*/
+
+ $hash = get_observer_hash();
+
+ if (! $hash)
+ return;
+
+
+ $t = get_xconfig($hash, 'sse', 'timestamp');
+
+ if(datetime_convert('UTC', 'UTC', $t) < datetime_convert('UTC', 'UTC', '- 30 seconds')) {
+ del_xconfig($hash, 'sse', 'notifications');
+ }
+
+ $x = get_xconfig($hash, 'sse', 'notifications');
+
+ if ($x === false)
+ $x = [];
+
+ if (isset($x['notice']) && in_array($s, $x['notice']['notifications']))
+ return;
+
+ if (App::$interactive) {
+ $x['notice']['notifications'][] = $s;
+ set_xconfig($hash, 'sse', 'timestamp', datetime_convert());
+ set_xconfig($hash, 'sse', 'notifications', $x);
+ }
+
}
/**
@@ -1839,8 +1869,11 @@ function notice($s) {
* @param string $s Text to display
*/
function info($s) {
+
+/*
if(! session_id())
return;
+
if(! x($_SESSION, 'sysmsg_info'))
$_SESSION['sysmsg_info'] = array();
@@ -1849,6 +1882,33 @@ function info($s) {
if(App::$interactive)
$_SESSION['sysmsg_info'][] = $s;
+*/
+
+ $hash = get_observer_hash();
+
+ if (! $hash)
+ return;
+
+ $t = get_xconfig($hash, 'sse', 'timestamp');
+
+ if(datetime_convert('UTC', 'UTC', $t) < datetime_convert('UTC', 'UTC', '- 30 seconds')) {
+ del_xconfig($hash, 'sse', 'notifications');
+ }
+
+ $x = get_xconfig($hash, 'sse', 'notifications');
+
+ if($x === false)
+ $x = [];
+
+ if(isset($x['info']) && in_array($s, $x['info']['notifications']))
+ return;
+
+ if(App::$interactive) {
+ $x['info']['notifications'][] = $s;
+ set_xconfig($hash, 'sse', 'timestamp', datetime_convert());
+ set_xconfig($hash, 'sse', 'notifications', $x);
+ }
+
}
/**