diff options
author | Mario <mario@mariovavti.com> | 2024-07-20 13:08:52 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2024-07-20 13:08:52 +0000 |
commit | 3fca63a15f50743952ce87672974145a0c2b4abb (patch) | |
tree | a2830e990b59d976e8aa602ee6e0b56490dc8b50 /Zotlabs | |
parent | c47900f36684c0d7e470240a6d7c1f26cefb4e81 (diff) | |
download | volse-hubzilla-3fca63a15f50743952ce87672974145a0c2b4abb.tar.gz volse-hubzilla-3fca63a15f50743952ce87672974145a0c2b4abb.tar.bz2 volse-hubzilla-3fca63a15f50743952ce87672974145a0c2b4abb.zip |
Revert "Revert "more work on sse sys messages""
This reverts commit c22f633ae0d42b5a0076a11dd08952817a613342
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Module/Login.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Sse.php | 78 |
2 files changed, 60 insertions, 20 deletions
diff --git a/Zotlabs/Module/Login.php b/Zotlabs/Module/Login.php index 6430939b4..721ac15ac 100644 --- a/Zotlabs/Module/Login.php +++ b/Zotlabs/Module/Login.php @@ -12,5 +12,5 @@ class Login extends \Zotlabs\Web\Controller { return login(true); } - + } 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); } |