aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Sse.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-07-19 19:35:21 +0000
committerMario <mario@mariovavti.com>2024-07-19 19:35:21 +0000
commit983fc84f283f34783b281ab047dc47c581cb937c (patch)
tree22399a48ba094c6a871cedc2ac8cbeb5f214c0bc /Zotlabs/Module/Sse.php
parent1861eeeb0acbcd7b22b8b447e47207959f54043e (diff)
downloadvolse-hubzilla-983fc84f283f34783b281ab047dc47c581cb937c.tar.gz
volse-hubzilla-983fc84f283f34783b281ab047dc47c581cb937c.tar.bz2
volse-hubzilla-983fc84f283f34783b281ab047dc47c581cb937c.zip
more work on sse sys messages
Diffstat (limited to 'Zotlabs/Module/Sse.php')
-rw-r--r--Zotlabs/Module/Sse.php78
1 files changed, 59 insertions, 19 deletions
diff --git a/Zotlabs/Module/Sse.php b/Zotlabs/Module/Sse.php
index df4a74f7b..a5b5c7e35 100644
--- a/Zotlabs/Module/Sse.php
+++ b/Zotlabs/Module/Sse.php
@@ -23,14 +23,7 @@ class Sse extends Controller {
killme();
}
- if(! intval(Config::Get('system','open_pubstream',1))) {
- if(! get_observer_hash()) {
- killme();
- }
- }
-
// this is important!
- session_write_close();
ignore_user_abort(true);
self::$uid = local_channel();
@@ -48,6 +41,8 @@ class Sse extends Controller {
}
}
+
+
if (self::$uid) {
self::$vnotify = get_pconfig(self::$uid, 'system', 'vnotify');
}
@@ -102,7 +97,6 @@ class Sse extends Controller {
}
}
-
$result = [];
XConfig::Load(self::$ob_hash);
@@ -110,9 +104,19 @@ class Sse extends Controller {
$lock = XConfig::Get(self::$ob_hash, 'sse', 'lock');
if (!$lock) {
- $result = XConfig::Get(self::$ob_hash, 'sse', 'notifications', []);
+ $result_db = XConfig::Get(self::$ob_hash, 'sse', 'notifications', []);
+ }
+
+ if (!empty($_SESSION['sysmsg'])) {
+ $result['notice']['notifications'] = $_SESSION['sysmsg'];
+ }
+
+ if (!empty($_SESSION['sysmsg_info'])) {
+ $result['info']['notifications'] = $_SESSION['sysmsg_info'];
}
+ $result = array_merge($result, $result_db);
+
// We do not have the local_channel in the addon.
// Reset pubs here if the app is not installed.
if (self::$uid && (!(self::$vnotify & VNOTIFY_PUBS) || !Apps::system_app_installed(self::$uid, 'Public Stream'))) {
@@ -133,22 +137,36 @@ class Sse extends Controller {
echo "\n\n";
}
- if (ob_get_length() > 0) {
- ob_end_flush();
- }
-
- flush();
-
if (connection_status() != CONNECTION_NORMAL || connection_aborted()) {
XConfig::Set(self::$ob_hash, 'sse', 'timestamp', NULL_DATE);
XConfig::Set(self::$ob_hash, 'sse', 'notifications', []);
+ $_SESSION['sysmsg'] = [];
+ $_SESSION['sysmsg_info'] = [];
+
+ if (ob_get_length() > 0) {
+ ob_end_flush();
+ }
+
+ flush();
+
exit;
}
+ if (ob_get_length() > 0) {
+ ob_flush();
+ }
+
+ flush();
+
usleep($sleep);
if ($result) {
- XConfig::Set(self::$ob_hash, 'sse', 'notifications', []);
+ if ($result_db) {
+ XConfig::Set(self::$ob_hash, 'sse', 'notifications', []);
+ }
+
+ $_SESSION['sysmsg'] = [];
+ $_SESSION['sysmsg_info'] = [];
}
$i++;
@@ -186,13 +204,35 @@ class Sse extends Controller {
}
}
+ $result = [];
+ $result_db = [];
+
XConfig::Load(self::$ob_hash);
- $result = XConfig::Get(self::$ob_hash, 'sse', 'notifications', []);
$lock = XConfig::Get(self::$ob_hash, 'sse', 'lock');
- if($result && !$lock) {
- XConfig::Set(self::$ob_hash, 'sse', 'notifications', []);
+ if (!$lock) {
+ $result_db = XConfig::Get(self::$ob_hash, 'sse', 'notifications', []);
+ }
+
+ if (!empty($_SESSION['sysmsg'])) {
+ $result['notice']['notifications'] = $_SESSION['sysmsg'];
+ }
+
+ if (!empty($_SESSION['sysmsg_info'])) {
+ $result['info']['notifications'] = $_SESSION['sysmsg_info'];
+ }
+
+ $result = array_merge($result, $result_db);
+
+ if($result) {
+ if ($result_db) {
+ XConfig::Set(self::$ob_hash, 'sse', 'notifications', []);
+ }
+
+ $_SESSION['sysmsg'] = [];
+ $_SESSION['sysmsg_info'] = [];
+
json_return_and_die($result);
}