From 137ba9a885be5f268d74f95b5859c44ad782da3c Mon Sep 17 00:00:00 2001
From: thom <thom@amsterdamtech.nl>
Date: Fri, 23 Oct 2020 18:07:33 +0200
Subject: [PATCH] Send overtraffic warning only when web is not disabled
 (#3937)

---
 server/conf/mail/web_traffic_notification_warn_en.txt |  8 ++++++++
 server/conf/mail/web_traffic_notification_warn_nl.txt |  8 ++++++++
 server/lib/classes/cron.d/300-quota_notify.inc.php    | 10 +++++++++-
 3 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 server/conf/mail/web_traffic_notification_warn_en.txt
 create mode 100644 server/conf/mail/web_traffic_notification_warn_nl.txt

diff --git a/server/conf/mail/web_traffic_notification_warn_en.txt b/server/conf/mail/web_traffic_notification_warn_en.txt
new file mode 100644
index 0000000000..f69d906dab
--- /dev/null
+++ b/server/conf/mail/web_traffic_notification_warn_en.txt
@@ -0,0 +1,8 @@
+MIME-Version: 1.0
+Content-type: text/plain; charset=utf-8
+Content-Transfer-Encoding: 8bit
+From: {admin_mail}
+Reply-To: {admin_mail}
+Subject: Website traffic notification
+
+The website {domain} is over traffic.
diff --git a/server/conf/mail/web_traffic_notification_warn_nl.txt b/server/conf/mail/web_traffic_notification_warn_nl.txt
new file mode 100644
index 0000000000..02d9a03c2f
--- /dev/null
+++ b/server/conf/mail/web_traffic_notification_warn_nl.txt
@@ -0,0 +1,8 @@
+MIME-Version: 1.0
+Content-type: text/plain; charset=utf-8
+Content-Transfer-Encoding: 8bit
+From: {admin_mail}
+Reply-To: {admin_mail}
+Subject: Webverkeerslimiet bereikt
+
+De website {domain} heeft het verkeerslimiet voor deze maand bereikt.
diff --git a/server/lib/classes/cron.d/300-quota_notify.inc.php b/server/lib/classes/cron.d/300-quota_notify.inc.php
index ad18f17c9b..bd6a410309 100644
--- a/server/lib/classes/cron.d/300-quota_notify.inc.php
+++ b/server/lib/classes/cron.d/300-quota_notify.inc.php
@@ -86,6 +86,9 @@ class cronjob_quota_notify extends cronjob {
 							$app->dbmaster->datalogUpdate('web_domain', array("traffic_quota_lock" => 'y', "active" => 'n'), 'domain_id', $rec['domain_id']);
 							$app->log('Traffic quota for '.$rec['domain'].' exceeded. Disabling website.', LOGLEVEL_DEBUG);
 						}
+						else {
+							$app->log('Traffic quota for '.$rec['domain'].' exceeded.', LOGLEVEL_DEBUG);
+						}
 						//* Send traffic notifications
 						if($rec['traffic_quota_lock'] != 'y' && ($web_config['overtraffic_notify_admin'] == 'y' || $web_config['overtraffic_notify_client'] == 'y')) {
 
@@ -111,7 +114,12 @@ class cronjob_quota_notify extends cronjob {
 								}
 							}
 
-							$this->_tools->send_notification_email('web_traffic_notification', $placeholders, $recipients);
+							if ($web_config['overtraffic_disable_web'] == 'y') {
+								$this->_tools->send_notification_email('web_traffic_notification', $placeholders, $recipients);
+							}
+							else {
+								$this->_tools->send_notification_email('web_traffic_notification_warn', $placeholders, $recipients);
+							}
 						}
 
 					} else {
-- 
GitLab