aboutsummaryrefslogtreecommitdiffstats
path: root/boot.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-07-28 18:44:07 +0000
committerMario <mario@mariovavti.com>2024-07-28 18:44:07 +0000
commit241cc1ad634cd7999bcac882b9fc9a5e06873818 (patch)
tree007effd91b9e26a9347655c6d8534ba7e994579e /boot.php
parentb26db5bde602db31bdd3016b1395fe5143d924f4 (diff)
downloadvolse-hubzilla-241cc1ad634cd7999bcac882b9fc9a5e06873818.tar.gz
volse-hubzilla-241cc1ad634cd7999bcac882b9fc9a5e06873818.tar.bz2
volse-hubzilla-241cc1ad634cd7999bcac882b9fc9a5e06873818.zip
storing info and notice messages in the session has some disadvantages if the functions are called via ajax. revert to storing them in xconfig.
Diffstat (limited to 'boot.php')
-rw-r--r--boot.php76
1 files changed, 75 insertions, 1 deletions
diff --git a/boot.php b/boot.php
index f40f5e39d..dcda705f0 100644
--- a/boot.php
+++ b/boot.php
@@ -1897,6 +1897,8 @@ function can_view_public_stream() {
*/
function notice($s) {
+/*
+
if (!session_id()) {
return;
}
@@ -1914,6 +1916,42 @@ function notice($s) {
if (App::$interactive) {
$_SESSION['sysmsg'][] = $s;
}
+*/
+
+ $hash = get_observer_hash();
+ $sse_id = false;
+
+ if (!$hash) {
+ if (session_id()) {
+ $sse_id = true;
+ $hash = 'sse_id.' . session_id();
+ }
+ else {
+ return;
+ }
+ }
+
+ $x = null;
+
+ $t = get_xconfig($hash, 'sse', 'timestamp', NULL_DATE);
+
+ if (datetime_convert('UTC', 'UTC', $t) < datetime_convert('UTC', 'UTC', '- 30 seconds')) {
+ set_xconfig($hash, 'sse', 'notifications', []);
+ $x = [];
+ }
+
+ if ($x === null) {
+ $x = get_xconfig($hash, 'sse', 'notifications', []);
+ }
+
+ if (isset($x['notice']) && in_array($s, $x['notice']['notifications'])) {
+ return;
+ }
+
+ if (App::$interactive) {
+ $x['notice']['notifications'][] = $s;
+ set_xconfig($hash, 'sse', 'notifications', $x);
+ }
}
@@ -1928,7 +1966,7 @@ function notice($s) {
* @param string $s Text to display
*/
function info($s) {
-
+/*
if (!session_id()) {
return;
}
@@ -1946,6 +1984,42 @@ function info($s) {
if (App::$interactive) {
$_SESSION['sysmsg_info'][] = $s;
}
+*/
+
+ $hash = get_observer_hash();
+ $sse_id = false;
+
+ if (!$hash) {
+ if (session_id()) {
+ $sse_id = true;
+ $hash = 'sse_id.' . session_id();
+ }
+ else {
+ return;
+ }
+ }
+
+ $x = null;
+
+ $t = get_xconfig($hash, 'sse', 'timestamp', NULL_DATE);
+
+ if (datetime_convert('UTC', 'UTC', $t) < datetime_convert('UTC', 'UTC', '- 30 seconds')) {
+ set_xconfig($hash, 'sse', 'notifications', []);
+ $x = [];
+ }
+
+ if ($x === null) {
+ $x = get_xconfig($hash, 'sse', 'notifications', []);
+ }
+
+ if (isset($x['info']) && in_array($s, $x['info']['notifications'])) {
+ return;
+ }
+
+ if (App::$interactive) {
+ $x['info']['notifications'][] = $s;
+ set_xconfig($hash, 'sse', 'notifications', $x);
+ }
}