From a8dc08a21903b48fb2e43f60b4d71acea3f3ae32 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 29 Jan 2023 09:54:01 +0100 Subject: [PATCH] [ticket/17010] Add prune notification support to webpush PHPBB3-17010 --- phpBB/phpbb/notification/method/webpush.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/phpBB/phpbb/notification/method/webpush.php b/phpBB/phpbb/notification/method/webpush.php index 994ccc35ac..d11959319c 100644 --- a/phpBB/phpbb/notification/method/webpush.php +++ b/phpBB/phpbb/notification/method/webpush.php @@ -292,6 +292,19 @@ class webpush extends messenger_base $this->db->sql_query($sql); } + /** + * {@inheritDoc} + */ + public function prune_notifications($timestamp, $only_read = true): void + { + $sql = 'DELETE FROM ' . $this->notification_webpush_table . ' + WHERE notification_time < ' . (int) $timestamp . + (($only_read) ? ' AND notification_read = 1' : ''); + $this->db->sql_query($sql); + + $this->config->set('read_notification_last_gc', (string) time(), false); + } + /** * Clean data to contain only what we need for webpush notifications table *