set server to 0 if no servers available
authorAlan <alan@roojs.com>
Thu, 2 Nov 2023 08:31:01 +0000 (16:31 +0800)
committerAlan <alan@roojs.com>
Thu, 2 Nov 2023 08:31:01 +0000 (16:31 +0800)
DataObjects/Core_notify_server.php
NotifySend.php

index da6b946..33b73d1 100644 (file)
@@ -84,6 +84,11 @@ class Pman_Core_DataObjects_Core_notify_server extends DB_DataObject
         }
         
         $ns = DB_DataObject::factory('core_notify_server');
         }
         
         $ns = DB_DataObject::factory('core_notify_server');
+        if (!$ns->count()) {
+            $ns->id = 0;
+            return $ns;
+        }
+        
         
         $ns->poolname = $notify->poolname;
         $ns->is_active = 1;
         
         $ns->poolname = $notify->poolname;
         $ns->is_active = 1;
@@ -111,6 +116,10 @@ class Pman_Core_DataObjects_Core_notify_server extends DB_DataObject
     
     function isFirstServer()
     {
     
     function isFirstServer()
     {
+        if (!$this->id) {
+            return true;
+        }
+        
         $servers = $this->availableServers();
         if (empty($servers)) {
             return false;
         $servers = $this->availableServers();
         if (empty($servers)) {
             return false;
@@ -123,7 +132,9 @@ class Pman_Core_DataObjects_Core_notify_server extends DB_DataObject
     // called on current server.
     function assignQueues($notify)
     {
     // called on current server.
     function assignQueues($notify)
     {
-         
+        if (!$this->id) {
+            return true;
+        }
         
         $servers = $this->availableServers();
         $ids = array();
         
         $servers = $this->availableServers();
         $ids = array();
@@ -265,6 +276,10 @@ class Pman_Core_DataObjects_Core_notify_server extends DB_DataObject
     
     function updateNotifyToNextServer( $cn , $when = false, $allow_same = false)
     {
     
     function updateNotifyToNextServer( $cn , $when = false, $allow_same = false)
     {
+        if (!$this->id) {
+            return;
+        }
+        
         // fixme - this should take into account blacklisted - and return false if no more servers are available
         $email = empty($cn->to_email) ? ($cn->person() ? $cn->person()->email : $cn->to_email) : $cn->to_email;
 
         // fixme - this should take into account blacklisted - and return false if no more servers are available
         $email = empty($cn->to_email) ? ($cn->person() ? $cn->person()->email : $cn->to_email) : $cn->to_email;
 
@@ -310,6 +325,10 @@ class Pman_Core_DataObjects_Core_notify_server extends DB_DataObject
     
     function isBlacklisted($email)
     {
     
     function isBlacklisted($email)
     {
+        if (!$this->id) {
+            return false;
+        }
+        
         // return current server id..
         static $cache = array();
          // get the domain..
         // return current server id..
         static $cache = array();
          // get the domain..
@@ -333,12 +352,18 @@ class Pman_Core_DataObjects_Core_notify_server extends DB_DataObject
     }
     function initHelo()
     {
     }
     function initHelo()
     {
+        if (!$this->id) {
+            return;
+        }
         $ff = HTML_FlexyFramework::get();
         $ff->Mail['helo'] = $this->helo;
         
     }
     function checkSmtpResponse($errmsg, $core_domain)
     {
         $ff = HTML_FlexyFramework::get();
         $ff->Mail['helo'] = $this->helo;
         
     }
     function checkSmtpResponse($errmsg, $core_domain)
     {
+        if (!$this->id) {
+            return false;
+        }
         $bl = DB_DataObject::factory('core_notify_blacklist');
         $bl->server_id = $this->id;
         $bl->domain_id = $core_domain->id;
         $bl = DB_DataObject::factory('core_notify_blacklist');
         $bl->server_id = $this->id;
         $bl->domain_id = $core_domain->id;
index 0621f3d..0ba7692 100644 (file)
@@ -242,7 +242,7 @@ class Pman_Core_NotifySend extends Pman
          
         
         if (isset($email['later'])) {
          
         
         if (isset($email['later'])) {
-            
+             
             $this->server->updateNotifyToNextServer($w, $email['later'],true);
              
             $this->errorHandler("Delivery postponed by email creator to {$email['later']}");
             $this->server->updateNotifyToNextServer($w, $email['later'],true);
              
             $this->errorHandler("Delivery postponed by email creator to {$email['later']}");