From b59a2101b460200e4276a05f9b8cb4ae7a2e9b62 Mon Sep 17 00:00:00 2001 From: rupak Date: Fri, 30 Jan 2026 02:19:35 +0545 Subject: Add option to enable notifications (#8458) Closes https://github.com/FreshRSS/FreshRSS/issues/7330 - Default behavior is same - Added FreshRSS_Context::userConf()->html5_disable_notif so that, it determines weather user wants notification. (will not show any even it has permission) (i want default false so disable, so old configs get proper default values) - Added button such that checking it makes it request permission too image - test notification actually happening (how can i trigger it, do i have to wait it), this code fixes permissions. --- app/Controllers/configureController.php | 1 + app/Models/UserConfiguration.php | 1 + app/i18n/cs/conf.php | 3 +++ app/i18n/de/conf.php | 3 +++ app/i18n/el/conf.php | 3 +++ app/i18n/en-US/conf.php | 3 +++ app/i18n/en/conf.php | 11 +++++++---- app/i18n/es/conf.php | 3 +++ app/i18n/fa/conf.php | 3 +++ app/i18n/fi/conf.php | 3 +++ app/i18n/fr/conf.php | 3 +++ app/i18n/he/conf.php | 3 +++ app/i18n/hu/conf.php | 3 +++ app/i18n/id/conf.php | 3 +++ app/i18n/it/conf.php | 3 +++ app/i18n/ja/conf.php | 3 +++ app/i18n/ko/conf.php | 3 +++ app/i18n/lv/conf.php | 3 +++ app/i18n/nl/conf.php | 3 +++ app/i18n/oc/conf.php | 3 +++ app/i18n/pl/conf.php | 3 +++ app/i18n/pt-BR/conf.php | 3 +++ app/i18n/pt-PT/conf.php | 3 +++ app/i18n/ru/conf.php | 3 +++ app/i18n/sk/conf.php | 3 +++ app/i18n/tr/conf.php | 3 +++ app/i18n/uk/conf.php | 3 +++ app/i18n/zh-CN/conf.php | 3 +++ app/i18n/zh-TW/conf.php | 3 +++ app/views/configure/display.phtml | 10 ++++++++++ app/views/helpers/javascript_vars.phtml | 1 + 31 files changed, 98 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 893fa5478..3153cb8c8 100644 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -75,6 +75,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController { FreshRSS_Context::userConf()->bottomline_link = Minz_Request::paramBoolean('bottomline_link'); FreshRSS_Context::userConf()->show_nav_buttons = Minz_Request::paramBoolean('show_nav_buttons'); FreshRSS_Context::userConf()->html5_notif_timeout = max(0, Minz_Request::paramInt('html5_notif_timeout')); + FreshRSS_Context::userConf()->html5_enable_notif = Minz_Request::paramBoolean('html5_enable_notif'); FreshRSS_Context::userConf()->good_notification_timeout = max(0, Minz_Request::paramInt('good_notification_timeout')); FreshRSS_Context::userConf()->bad_notification_timeout = max(1, Minz_Request::paramInt('bad_notification_timeout')); FreshRSS_Context::userConf()->save(); diff --git a/app/Models/UserConfiguration.php b/app/Models/UserConfiguration.php index 644b27bab..d12316141 100644 --- a/app/Models/UserConfiguration.php +++ b/app/Models/UserConfiguration.php @@ -28,6 +28,7 @@ declare(strict_types=1); * @property string $feverKey * @property bool $hide_read_feeds * @property int $html5_notif_timeout + * @property bool $html5_enable_notif * @property int $good_notification_timeout * @property int $bad_notification_timeout * @property-read bool $is_admin diff --git a/app/i18n/cs/conf.php b/app/i18n/cs/conf.php index 73fb94220..140e03cb9 100644 --- a/app/i18n/cs/conf.php +++ b/app/i18n/cs/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'None', // TODO 'small' => 'Small', // TODO ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Show warning banner', // TODO diff --git a/app/i18n/de/conf.php b/app/i18n/de/conf.php index e73ed001f..3f57416f4 100644 --- a/app/i18n/de/conf.php +++ b/app/i18n/de/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'Keine', 'small' => 'Klein', ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Zeige Warnbanner', diff --git a/app/i18n/el/conf.php b/app/i18n/el/conf.php index 8b0a4236d..0d1ba6620 100644 --- a/app/i18n/el/conf.php +++ b/app/i18n/el/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'None', // TODO 'small' => 'Small', // TODO ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Show warning banner', // TODO diff --git a/app/i18n/en-US/conf.php b/app/i18n/en-US/conf.php index ba9b55b24..99272f190 100644 --- a/app/i18n/en-US/conf.php +++ b/app/i18n/en-US/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'None', // IGNORE 'small' => 'Small', // IGNORE ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // IGNORE + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Show warning banner', // IGNORE diff --git a/app/i18n/en/conf.php b/app/i18n/en/conf.php index 2e4c20d32..bfc32ec3a 100644 --- a/app/i18n/en/conf.php +++ b/app/i18n/en/conf.php @@ -105,14 +105,17 @@ return array( 'none' => 'None', 'small' => 'Small', ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', + ), 'notification_timeout' => array( 'bad' => array( - 'label' => 'Show warning banner', // TODO - 'seconds' => 'seconds (at least 1)', // TODO + 'label' => 'Show warning banner', + 'seconds' => 'seconds (at least 1)', ), 'good' => array( - 'label' => 'Show acknowledgement banner', // TODO - 'seconds' => 'seconds (0 means not shown)', // TODO + 'label' => 'Show acknowledgement banner', + 'seconds' => 'seconds (0 means not shown)', ), ), 'privacy' => array( diff --git a/app/i18n/es/conf.php b/app/i18n/es/conf.php index b82e3a364..13c991008 100644 --- a/app/i18n/es/conf.php +++ b/app/i18n/es/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'Nada', 'small' => 'Pequeño', ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Mostrar mensaje de advertencia', diff --git a/app/i18n/fa/conf.php b/app/i18n/fa/conf.php index 870b49dc8..28ed5039d 100644 --- a/app/i18n/fa/conf.php +++ b/app/i18n/fa/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'هیچ', 'small' => 'کوچک', ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Show warning banner', // TODO diff --git a/app/i18n/fi/conf.php b/app/i18n/fi/conf.php index 7261d270f..790e0a92b 100644 --- a/app/i18n/fi/conf.php +++ b/app/i18n/fi/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'Ei mitään', 'small' => 'Pieni', ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Näytä varoituspalkki', diff --git a/app/i18n/fr/conf.php b/app/i18n/fr/conf.php index 27950983c..e43ee3fd0 100644 --- a/app/i18n/fr/conf.php +++ b/app/i18n/fr/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'Aucun', 'small' => 'Petit', ), + 'notification' => array( + 'html5_enable_notif' => 'Activer les notifications', + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Afficher la bannière d’avertissement', diff --git a/app/i18n/he/conf.php b/app/i18n/he/conf.php index f7018c582..7f66859c3 100644 --- a/app/i18n/he/conf.php +++ b/app/i18n/he/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'None', // TODO 'small' => 'Small', // TODO ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Show warning banner', // TODO diff --git a/app/i18n/hu/conf.php b/app/i18n/hu/conf.php index d6a362324..b1b9ee2a0 100644 --- a/app/i18n/hu/conf.php +++ b/app/i18n/hu/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'Egyik sem', 'small' => 'Kicsi', ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Figyelmeztető sáv megjelenítése', diff --git a/app/i18n/id/conf.php b/app/i18n/id/conf.php index 9163067f9..3c3a9a281 100644 --- a/app/i18n/id/conf.php +++ b/app/i18n/id/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'Tidak ditampilkan', 'small' => 'Kecil', ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Show warning banner', // TODO diff --git a/app/i18n/it/conf.php b/app/i18n/it/conf.php index 60f9c451c..feb4c98a6 100644 --- a/app/i18n/it/conf.php +++ b/app/i18n/it/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'Nessuno', 'small' => 'Piccolo', ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Mostra banner con le segnalazioni', diff --git a/app/i18n/ja/conf.php b/app/i18n/ja/conf.php index 9340bfaef..a0e523786 100644 --- a/app/i18n/ja/conf.php +++ b/app/i18n/ja/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'None', // TODO 'small' => 'Small', // TODO ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Show warning banner', // TODO diff --git a/app/i18n/ko/conf.php b/app/i18n/ko/conf.php index 9ad972740..b26c72112 100644 --- a/app/i18n/ko/conf.php +++ b/app/i18n/ko/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'None', // TODO 'small' => 'Small', // TODO ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Show warning banner', // TODO diff --git a/app/i18n/lv/conf.php b/app/i18n/lv/conf.php index a9eced70b..f6c14d4ce 100644 --- a/app/i18n/lv/conf.php +++ b/app/i18n/lv/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'None', // TODO 'small' => 'Small', // TODO ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Show warning banner', // TODO diff --git a/app/i18n/nl/conf.php b/app/i18n/nl/conf.php index 315a92f22..b18210bf3 100644 --- a/app/i18n/nl/conf.php +++ b/app/i18n/nl/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'Geen', 'small' => 'Klein', ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Waarschuwingsbalk tonen', diff --git a/app/i18n/oc/conf.php b/app/i18n/oc/conf.php index 77317d612..16bd0e33f 100644 --- a/app/i18n/oc/conf.php +++ b/app/i18n/oc/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'None', // TODO 'small' => 'Small', // TODO ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Show warning banner', // TODO diff --git a/app/i18n/pl/conf.php b/app/i18n/pl/conf.php index d99faeb84..e45a9cb84 100644 --- a/app/i18n/pl/conf.php +++ b/app/i18n/pl/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'Brak', 'small' => 'Mały', ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Pokaż baner ostrzeżenia', diff --git a/app/i18n/pt-BR/conf.php b/app/i18n/pt-BR/conf.php index 06d6bf467..92fdb167d 100644 --- a/app/i18n/pt-BR/conf.php +++ b/app/i18n/pt-BR/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'Nenhum', 'small' => 'Pequeno', ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Mostrar banner de aviso', diff --git a/app/i18n/pt-PT/conf.php b/app/i18n/pt-PT/conf.php index ce3c66760..a4f4e4a5c 100644 --- a/app/i18n/pt-PT/conf.php +++ b/app/i18n/pt-PT/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'None', // TODO 'small' => 'Small', // TODO ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Show warning banner', // TODO diff --git a/app/i18n/ru/conf.php b/app/i18n/ru/conf.php index 351f29a1a..82dce384f 100644 --- a/app/i18n/ru/conf.php +++ b/app/i18n/ru/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'Отсутствует', 'small' => 'Маленькая', ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Показывать баннер предупреждения', diff --git a/app/i18n/sk/conf.php b/app/i18n/sk/conf.php index 93fc8681d..27e669067 100644 --- a/app/i18n/sk/conf.php +++ b/app/i18n/sk/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'None', // TODO 'small' => 'Small', // TODO ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Show warning banner', // TODO diff --git a/app/i18n/tr/conf.php b/app/i18n/tr/conf.php index 9d62dc975..8e50ff93d 100644 --- a/app/i18n/tr/conf.php +++ b/app/i18n/tr/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'Yok', 'small' => 'Küçük', ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Show warning banner', // TODO diff --git a/app/i18n/uk/conf.php b/app/i18n/uk/conf.php index afcf26c98..91c4ce61f 100644 --- a/app/i18n/uk/conf.php +++ b/app/i18n/uk/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'Не показувати', 'small' => 'Мала', ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Show warning banner', // TODO diff --git a/app/i18n/zh-CN/conf.php b/app/i18n/zh-CN/conf.php index a1e332db3..7f9bc736f 100644 --- a/app/i18n/zh-CN/conf.php +++ b/app/i18n/zh-CN/conf.php @@ -105,6 +105,9 @@ return array( 'none' => '无', 'small' => '小', ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => '显示警告横幅', diff --git a/app/i18n/zh-TW/conf.php b/app/i18n/zh-TW/conf.php index 0e5249683..636f8c024 100644 --- a/app/i18n/zh-TW/conf.php +++ b/app/i18n/zh-TW/conf.php @@ -105,6 +105,9 @@ return array( 'none' => 'None', // TODO 'small' => 'Small', // TODO ), + 'notification' => array( + 'html5_enable_notif' => 'Enable notification', // TODO + ), 'notification_timeout' => array( 'bad' => array( 'label' => 'Show warning banner', // TODO diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index 6f8e3e1b4..64dcf1b84 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -231,6 +231,16 @@ +
+
+ +
+
+
diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml index 73e047e11..f2203f56e 100644 --- a/app/views/helpers/javascript_vars.phtml +++ b/app/views/helpers/javascript_vars.phtml @@ -24,6 +24,7 @@ echo json_encode([ 'does_lazyload' => !!FreshRSS_Context::userConf()->lazyload , 'sides_close_article' => !!FreshRSS_Context::userConf()->sides_close_article, 'sticky_post' => !!FreshRSS_Context::isStickyPostEnabled(), + 'html5_enable_notif' => FreshRSS_Context::userConf()->html5_enable_notif, 'html5_notif_timeout' => FreshRSS_Context::userConf()->html5_notif_timeout, 'closeNotification' => [ 'good' => FreshRSS_Context::userConf()->good_notification_timeout * 1000, -- cgit v1.2.3