From 2cfdbbd956c510071b57a776b38580a2b5971cc7 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 17 Jul 2024 14:34:46 +0000 Subject: sse: revert removing of reset after 30 seconds and save a db lookup if we have just reset --- boot.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'boot.php') diff --git a/boot.php b/boot.php index 3e07bcaaf..b20acb18f 100644 --- a/boot.php +++ b/boot.php @@ -1928,7 +1928,18 @@ function notice($s) { } } - $x = get_xconfig($hash, 'sse', 'notifications', []); + $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; @@ -1980,7 +1991,18 @@ function info($s) { } } - $x = get_xconfig($hash, 'sse', 'notifications', []); + $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; -- cgit v1.2.3