diff options
| author | 2026-01-30 02:19:35 +0545 | |
|---|---|---|
| committer | 2026-01-29 21:34:35 +0100 | |
| commit | b59a2101b460200e4276a05f9b8cb4ae7a2e9b62 (patch) | |
| tree | ef2fec4a132bce5c11b35f7285ecf17ef64b09f8 | |
| parent | edc750fe444b6af65eccee879a048cf3e0cdd215 (diff) | |
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
<img width="707" height="119" alt="image" src="https://github.com/user-attachments/assets/a0fdbc4d-9f15-4644-8753-f0e6c979677f" />
- test notification actually happening (how can i trigger it, do i have to wait it), this code fixes permissions.
36 files changed, 161 insertions, 25 deletions
diff --git a/README.fr.md b/README.fr.md index 2654d195c..6a54bd0ce 100644 --- a/README.fr.md +++ b/README.fr.md @@ -226,13 +226,13 @@ Voir le [dépôt dédié à ces extensions](https://github.com/FreshRSS/Extensio | Langage | Progression | | | - | - | - | -| Čeština (cs) | ■■■■■■■■・・ 84% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fcs+%2F%28TODO%7CDIRTY%29%24%2F) | +| Čeština (cs) | ■■■■■■■■・・ 83% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fcs+%2F%28TODO%7CDIRTY%29%24%2F) | | Deutsch (de) | ■■■■■■■■■・ 95% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fde+%2F%28TODO%7CDIRTY%29%24%2F) | | Ελληνικά (el) | ■■■・・・・・・・ 38% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fel+%2F%28TODO%7CDIRTY%29%24%2F) | | English (en) | ■■■■■■■■■■ 100% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fen+%2F%28TODO%7CDIRTY%29%24%2F) | | English (United States) (en-US) | ■■■■■■■■■■ 100% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fen-US+%2F%28TODO%7CDIRTY%29%24%2F) | -| Español (es) | ■■■■■■■■■■ 100% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fes+%2F%28TODO%7CDIRTY%29%24%2F) | -| فارسی (fa) | ■■■■■■■■■・ 93% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffa+%2F%28TODO%7CDIRTY%29%24%2F) | +| Español (es) | ■■■■■■■■■・ 99% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fes+%2F%28TODO%7CDIRTY%29%24%2F) | +| فارسی (fa) | ■■■■■■■■■・ 92% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffa+%2F%28TODO%7CDIRTY%29%24%2F) | | Suomi (fi) | ■■■■■■■■■・ 95% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffi+%2F%28TODO%7CDIRTY%29%24%2F) | | Français (fr) | ■■■■■■■■■■ 100% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffr+%2F%28TODO%7CDIRTY%29%24%2F) | | עברית (he) | ■■■■・・・・・・ 42% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fhe+%2F%28TODO%7CDIRTY%29%24%2F) | @@ -240,8 +240,8 @@ Voir le [dépôt dédié à ces extensions](https://github.com/FreshRSS/Extensio | Bahasa Indonesia (id) | ■■■■■■■■■・ 92% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fid+%2F%28TODO%7CDIRTY%29%24%2F) | | Italiano (it) | ■■■■■■■■■・ 99% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fit+%2F%28TODO%7CDIRTY%29%24%2F) | | 日本語 (ja) | ■■■■■■■■■・ 90% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fja+%2F%28TODO%7CDIRTY%29%24%2F) | -| 한국어 (ko) | ■■■■■■■■・・ 84% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fko+%2F%28TODO%7CDIRTY%29%24%2F) | -| Latviešu (lv) | ■■■■■■■・・・ 78% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Flv+%2F%28TODO%7CDIRTY%29%24%2F) | +| 한국어 (ko) | ■■■■■■■■・・ 83% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fko+%2F%28TODO%7CDIRTY%29%24%2F) | +| Latviešu (lv) | ■■■■■■■・・・ 77% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Flv+%2F%28TODO%7CDIRTY%29%24%2F) | | Nederlands (nl) | ■■■■■■■■■・ 99% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fnl+%2F%28TODO%7CDIRTY%29%24%2F) | | Occitan (oc) | ■■■■■■■・・・ 76% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Foc+%2F%28TODO%7CDIRTY%29%24%2F) | | Polski (pl) | ■■■■■■■■■・ 99% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fpl+%2F%28TODO%7CDIRTY%29%24%2F) | @@ -252,7 +252,7 @@ Voir le [dépôt dédié à ces extensions](https://github.com/FreshRSS/Extensio | Türkçe (tr) | ■■■■■■■■■・ 91% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ftr+%2F%28TODO%7CDIRTY%29%24%2F) | | Українська (uk) | ■■■■■■■■■・ 94% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fuk+%2F%28TODO%7CDIRTY%29%24%2F) | | 简体中文 (zh-CN) | ■■■■■■■■■・ 99% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fzh-CN+%2F%28TODO%7CDIRTY%29%24%2F) | -| 正體中文 (zh-TW) | ■■■■■■■■・・ 84% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fzh-TW+%2F%28TODO%7CDIRTY%29%24%2F) | +| 正體中文 (zh-TW) | ■■■■■■■■・・ 83% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fzh-TW+%2F%28TODO%7CDIRTY%29%24%2F) | </translations> @@ -122,13 +122,13 @@ See the [repository dedicated to those extensions](https://github.com/FreshRSS/E | Language | Progress | | | - | - | - | -| Čeština (cs) | ■■■■■■■■・・ 84% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fcs+%2F%28TODO%7CDIRTY%29%24%2F) | +| Čeština (cs) | ■■■■■■■■・・ 83% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fcs+%2F%28TODO%7CDIRTY%29%24%2F) | | Deutsch (de) | ■■■■■■■■■・ 95% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fde+%2F%28TODO%7CDIRTY%29%24%2F) | | Ελληνικά (el) | ■■■・・・・・・・ 38% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fel+%2F%28TODO%7CDIRTY%29%24%2F) | | English (en) | ■■■■■■■■■■ 100% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fen+%2F%28TODO%7CDIRTY%29%24%2F) | | English (United States) (en-US) | ■■■■■■■■■■ 100% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fen-US+%2F%28TODO%7CDIRTY%29%24%2F) | -| Español (es) | ■■■■■■■■■■ 100% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fes+%2F%28TODO%7CDIRTY%29%24%2F) | -| فارسی (fa) | ■■■■■■■■■・ 93% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffa+%2F%28TODO%7CDIRTY%29%24%2F) | +| Español (es) | ■■■■■■■■■・ 99% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fes+%2F%28TODO%7CDIRTY%29%24%2F) | +| فارسی (fa) | ■■■■■■■■■・ 92% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffa+%2F%28TODO%7CDIRTY%29%24%2F) | | Suomi (fi) | ■■■■■■■■■・ 95% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffi+%2F%28TODO%7CDIRTY%29%24%2F) | | Français (fr) | ■■■■■■■■■■ 100% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffr+%2F%28TODO%7CDIRTY%29%24%2F) | | עברית (he) | ■■■■・・・・・・ 42% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fhe+%2F%28TODO%7CDIRTY%29%24%2F) | @@ -136,8 +136,8 @@ See the [repository dedicated to those extensions](https://github.com/FreshRSS/E | Bahasa Indonesia (id) | ■■■■■■■■■・ 92% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fid+%2F%28TODO%7CDIRTY%29%24%2F) | | Italiano (it) | ■■■■■■■■■・ 99% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fit+%2F%28TODO%7CDIRTY%29%24%2F) | | 日本語 (ja) | ■■■■■■■■■・ 90% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fja+%2F%28TODO%7CDIRTY%29%24%2F) | -| 한국어 (ko) | ■■■■■■■■・・ 84% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fko+%2F%28TODO%7CDIRTY%29%24%2F) | -| Latviešu (lv) | ■■■■■■■・・・ 78% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Flv+%2F%28TODO%7CDIRTY%29%24%2F) | +| 한국어 (ko) | ■■■■■■■■・・ 83% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fko+%2F%28TODO%7CDIRTY%29%24%2F) | +| Latviešu (lv) | ■■■■■■■・・・ 77% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Flv+%2F%28TODO%7CDIRTY%29%24%2F) | | Nederlands (nl) | ■■■■■■■■■・ 99% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fnl+%2F%28TODO%7CDIRTY%29%24%2F) | | Occitan (oc) | ■■■■■■■・・・ 76% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Foc+%2F%28TODO%7CDIRTY%29%24%2F) | | Polski (pl) | ■■■■■■■■■・ 99% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fpl+%2F%28TODO%7CDIRTY%29%24%2F) | @@ -148,7 +148,7 @@ See the [repository dedicated to those extensions](https://github.com/FreshRSS/E | Türkçe (tr) | ■■■■■■■■■・ 91% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ftr+%2F%28TODO%7CDIRTY%29%24%2F) | | Українська (uk) | ■■■■■■■■■・ 94% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fuk+%2F%28TODO%7CDIRTY%29%24%2F) | | 简体中文 (zh-CN) | ■■■■■■■■■・ 99% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fzh-CN+%2F%28TODO%7CDIRTY%29%24%2F) | -| 正體中文 (zh-TW) | ■■■■■■■■・・ 84% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fzh-TW+%2F%28TODO%7CDIRTY%29%24%2F) | +| 正體中文 (zh-TW) | ■■■■■■■■・・ 83% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fzh-TW+%2F%28TODO%7CDIRTY%29%24%2F) | </translations> 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 @@ -232,6 +232,16 @@ </div> <div class="form-group"> + <div class="group-controls"> + <label class="checkbox" for="html5_enable_notif"> + <input type="checkbox" name="html5_enable_notif" id="html5_enable_notif" value="1"<?= + FreshRSS_Context::userConf()->html5_enable_notif ? ' checked="checked"' : '' ?> /> + <?= _t('conf.notification.html5_enable_notif') ?> + </label> + </div> + </div> + + <div class="form-group"> <label class="group-name" for="html5_notif_timeout"><?= _t('conf.display.notif_html5.timeout') ?></label> <div class="group-controls"> <input type="number" min="0" max="60" id="html5_notif_timeout" name="html5_notif_timeout" value="<?= 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, diff --git a/config-user.default.php b/config-user.default.php index c838a7117..90b7af209 100644 --- a/config-user.default.php +++ b/config-user.default.php @@ -127,6 +127,7 @@ return array ( 'queries' => array ( ), 'html5_notif_timeout' => 0, + 'html5_enable_notif' => true, 'good_notification_timeout' => 3, 'bad_notification_timeout' => 8, 'show_nav_buttons' => true, diff --git a/p/scripts/extra.js b/p/scripts/extra.js index 43bbd89f5..fb1df94db 100644 --- a/p/scripts/extra.js +++ b/p/scripts/extra.js @@ -1,6 +1,6 @@ // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0 'use strict'; -/* globals context, openNotification, xmlHttpRequestJson */ +/* globals context, notifs_html5_is_supported, openNotification, xmlHttpRequestJson */ // <crypto form (Web login)> function poormanSalt() { // If crypto.getRandomValues is not available @@ -581,6 +581,35 @@ function init_user_stats() { document.querySelectorAll('tr[data-need-ajax]').forEach(row => observer.observe(row)); } +function init_enable_notify_button() { + const notify_button = document.getElementById('html5_enable_notif'); + if (!notify_button) return; + // it means unsupported in browser + if (!notifs_html5_is_supported()) { + notify_button.checked = false; + return; + } + + // Not granted, uncheck even if it is saved in server so browser asks for permission + if (Notification.permission !== 'granted') { + notify_button.checked = false; + } + + notify_button.addEventListener('change', async function () { + if (this.checked) { + const permission = await Notification.requestPermission(); + context.notifs_html5_permission = permission; + // Uncheck if user denied + if (permission !== 'granted') { + notify_button.checked = false; + } + } else { + // User disabled notifications + context.notifs_html5_permission = 'denied'; + } + }); +} + function init_extra_afterDOM() { if (!window.context) { if (window.console) { @@ -602,6 +631,7 @@ function init_extra_afterDOM() { init_update_feed(); init_details_attributes(); init_user_stats(); + init_enable_notify_button(); data_auto_leave_validation(document.body); diff --git a/p/scripts/main.js b/p/scripts/main.js index 0ff9e609c..3241c127f 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1965,23 +1965,26 @@ function init_notifications() { // </notification> // <notifs html5> -let notifs_html5_permission = 'denied'; +context.notifs_html5_permission = 'denied'; function notifs_html5_is_supported() { return window.Notification !== undefined; } -function notifs_html5_ask_permission() { +async function notifs_html5_ask_permission() { try { - window.Notification.requestPermission(function () { - notifs_html5_permission = window.Notification.permission; - }); + context.notifs_html5_permission = await window.Notification.requestPermission(); } catch (e) { + // User denied + context.notifs_html5_permission = 'denied'; } } function notifs_html5_show(nb, nb_new) { - if (notifs_html5_permission !== 'granted') { + if (!context.html5_enable_notif) { + return; // from config + } + if (context.notifs_html5_permission !== 'granted') { return; } @@ -2013,8 +2016,16 @@ function init_notifs_html5() { if (!notifs_html5_is_supported()) { return; } - - notifs_html5_permission = notifs_html5_ask_permission(); + // from config, 1st run this should be true + if (!context.html5_enable_notif) { + return; + } + context.notifs_html5_permission = Notification.permission; + // Only ask if the user hasn’t answered yet + // otherwise they need to ask from settings > display + if (context.notifs_html5_permission === 'default') { + notifs_html5_ask_permission(); + } } // </notifs html5> |
