From 0f4b40c7fbb3d67e32983db81392fcce144087e3 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 30 Jul 2020 12:10:53 +0200 Subject: [PATCH] * Mail: new preference to disable notifications for new arriving mails (requires push for mail) --- mail/inc/class.mail_hooks.inc.php | 21 +++++++++++++++++++++ mail/js/app.js | 19 ++++++++++++++++++- mail/lang/egw_de.lang | 5 +++++ mail/lang/egw_en.lang | 5 +++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/mail/inc/class.mail_hooks.inc.php b/mail/inc/class.mail_hooks.inc.php index 6dd54cc62a..ec2ed3209b 100644 --- a/mail/inc/class.mail_hooks.inc.php +++ b/mail/inc/class.mail_hooks.inc.php @@ -325,6 +325,20 @@ class mail_hooks 'values' => $GLOBALS['egw_info']['user']['preferences']['mail']['allowExternalDomains'], 'no_sel_options' => true ), + 'new_mail_notification' => [ + 'type' => 'select', + 'label' => 'Show notification for new arriving mails', + 'help' => 'Shows a temporary visible notification including from address, subject and a snippet of the mail', + 'name' => 'new_mail_notification', + 'values' => [ + 'always' => lang('Always show notifiction'), + 'not-mail' => lang('Only if currently in an other app'), + 'never' => lang('Never show notification'), + ], + 'xmlrpc' => True, + 'admin' => False, + 'default'=> 'always', + ], array( 'type' => 'section', 'title' => lang('Configuration settings'), @@ -439,6 +453,13 @@ class mail_hooks ) ); if (!$GLOBALS['egw_info']['apps']['stylite']) unset($settingsArray['attachVCardAtCompose']); + + // if no push configured, do NOT show new-mail-notification preference + $config = Api\Config::read('mail'); + if (empty($GLOBALS['egw_info']['server']['imap_hosts_with_push']) && empty($config['imap_hosts_with_push'])) + { + unset($settingsArray['new_mail_notification']); + } return $settingsArray; } diff --git a/mail/js/app.js b/mail/js/app.js index d755dc61a2..0e634b54d8 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -402,10 +402,11 @@ app.classes.mail = AppJS.extend( // notify user a new mail arrived if (pushData.type === 'add') { - this.egw.message(this.egw.lang('New mail from %1', pushData.acl.from)+'\n'+pushData.acl.subject+'\n'+pushData.acl.snippet, 'success'); // increment notification counter on (closed) mail tab let framework = egw_getFramework(); if (framework) framework.notifyAppTab('mail'); + // check if user wants a new mail notification + this.notifyNew(pushData); } // check if we might not see it because we are on a different mail account or folder let nm = this.et2 ? this.et2.getWidgetById('nm') : null; @@ -429,6 +430,22 @@ app.classes.mail = AppJS.extend( } }, + /** + * Check if user want's new mail notification + * + * @param pushData + */ + notifyNew: function(pushData) + { + let framework = egw_getFramework(); + let notify = this.egw.preference('new_mail_notification', 'mail'); + if (typeof notify === 'undefined' || notify === 'always' || + notify === 'not-mail' && framework && framework.activeApp.appName !== 'mail') + { + this.egw.message(egw.lang('New mail from %1', pushData.acl.from)+'\n'+pushData.acl.subject+'\n'+pushData.acl.snippet, 'success'); + } + }, + /** * Observer method receives update notifications from all applications * diff --git a/mail/lang/egw_de.lang b/mail/lang/egw_de.lang index f2790a3ec7..a97d2055cb 100644 --- a/mail/lang/egw_de.lang +++ b/mail/lang/egw_de.lang @@ -50,6 +50,7 @@ allways a new window mail de immer in einem neuen Fenster always mail de Immer always allow external sources from %1 mail de Erlaube externe Bildquellen von %1 always show html emails mail de HTML-E-Mails immer anzeigen +always show notifiction mail de Benachrichtigungen immer anzeigen an error happend while trying to remove acl rights from the account %1! mail de Ein Fehler trat auf beim Versuch die Zugriffskontrollrechte vom Konto %1 zu entfernen! and the rule with priority %1, now got the priority %2 mail de Die Regel mit Priorität %1 hat jetzt die Priorität %2 any of mail de mit einem @@ -363,6 +364,7 @@ name of account mail de Konten-Bezeichnung name of imap servers (space separated host or host:port) mail de Name der IMAP Server (Leerzeichen getrennt Host oder Host:Port) never display html emails mail de niemals anzeigen never show mail de Nie anzeigen +never show notification mail de Benachrichtigungen nie anzeigen new mail from %1 mail de Neue Mail von %1 new mail notification mail de Benachrichtigung über neue E-Mails in: new message type mail de Neue E-Mails verfassen als @@ -393,6 +395,7 @@ notify when new mails arrive in these folders mail de Benachrichtigung, sobald n on mail de am on behalf of mail de Im Namen von one address is not valid mail de Eine Adresse ist ungültig +only if currently in an other app mail de Nur anzeigen wenn aktuell in einer anderen Anwendung only makes sense, if you transport password through a different channel / outside of this mail to recipients! mail de Macht nur dann Sinn, wenn das Passwort auf einem anderen Weg, außerhalb dieser Mail, den Empfängern mitgeteilt wird! only needed for some servers, that do not return all folders on root level queries to retrieve all folders for that level mail de wird nur für bestimmte Server gebraucht, die NICHT alle Ordner für Root-Knoten-Abfragen zurückgeben (damit wird in diesem Fall explizit auf Ordner in den Prefixes der Namespaces geprüft) only one window mail de nur ein einziges Fenster @@ -546,11 +549,13 @@ show all folders, (subscribed and unsubscribed) in main screen folder pane mail show horizontal mail de Horizontal anzeigen show horizontal, hide if none selected mail de Horizontal anzeigen, ausblenden wenn nichts ausgewählt show new messages on home page mail de Anzeigen von neuen E-Mails auf der Startseite +show notification for new arriving mails mail de Zeige Benachrichtigungen für neu eintreffende Mails show test connection section and control the level of info displayed? mail de Zeige Verbindungstest Link an und spezifiziere das Ausmaß der angezeigten Information? show test connection section and control the level of info displayed?? mail de Soll der Verbindungstest und die dazugehörigen Informationen angezeigt werden? show them this time only mail de Einmalig externe Inhalte anzeigen show vertical mail de Vertikal anzeigen (3-Spalten-Ansicht) show/hide preview pane in mail list view mail de Mailvorschau anzeigen oder ausblenden +shows a temporary visible notification including from address, subject and a snippet of the mail mail de Zeigt eine kurze Zeit sichtbare Benachrichtigung einschließlich Absender, Betreff und Auszug der Mail sieve mail de Sieve sieve connection status mail de Sieve Verbindungsstatus sieve not activated mail de Sieve nicht aktiviert diff --git a/mail/lang/egw_en.lang b/mail/lang/egw_en.lang index 8b4509e365..99403cb111 100644 --- a/mail/lang/egw_en.lang +++ b/mail/lang/egw_en.lang @@ -50,6 +50,7 @@ allways a new window mail en allways a new window always mail en Always always allow external sources from %1 mail en Always allow external sources from %1 always show html emails mail en always show HTML emails +always show notifiction mail en Always show notifiction an error happend while trying to remove acl rights from the account %1! mail en An error happend while trying to remove ACL rights from the account %1! and the rule with priority %1, now got the priority %2 mail en And the rule with priority %1, now got the priority %2 any of mail en any of @@ -363,6 +364,7 @@ name of account mail en Name of account name of imap servers (space separated host or host:port) mail en Name of IMAP servers (space separated host or host:port) never display html emails mail en never display HTML emails never show mail en never show +never show notification mail en Never show notification new mail from %1 mail en New mail from %1 new mail notification mail en New mail notification new message type mail en New message type @@ -393,6 +395,7 @@ notify when new mails arrive in these folders mail en notify when new mails arri on mail en on on behalf of mail en On behalf of one address is not valid mail en One address is not valid +only if currently in an other app mail en Only if currently in an other app only makes sense, if you transport password through a different channel / outside of this mail to recipients! mail en Only makes sense, if you transport password through a different channel / outside of this mail to recipients! only needed for some servers, that do not return all folders on root level queries to retrieve all folders for that level mail en only needed for some servers, that do not return all folders on root level queries to retrieve all folders for that level only one window mail en only one window @@ -546,11 +549,13 @@ show all folders, (subscribed and unsubscribed) in main screen folder pane mail show horizontal mail en show horizontal show horizontal, hide if none selected mail en show horizontal, hide if none selected show new messages on home page mail en show new messages on home page +show notification for new arriving mails mail en Show notification for new arriving mails show test connection section and control the level of info displayed? mail en Show Test Connection section and control the level of info displayed? show test connection section and control the level of info displayed?? mail en Show Test Connection section and control the level of info displayed?? show them this time only mail en Show them this time only show vertical mail en show vertical show/hide preview pane in mail list view mail en Show/Hide preview pane in mail list view +shows a temporary visible notification including from address, subject and a snippet of the mail mail en Shows a temporary visible notification including from address, subject and a snippet of the mail sieve mail en Sieve sieve connection status mail en Sieve Connection Status sieve not activated mail en Sieve not activated