}
$ns = DB_DataObject::factory('core_notify_server');
+ if (!$ns->count()) {
+ $ns->id = 0;
+ return $ns;
+ }
+
$ns->poolname = $notify->poolname;
$ns->is_active = 1;
function isFirstServer()
{
+ if (!$this->id) {
+ return true;
+ }
+
$servers = $this->availableServers();
if (empty($servers)) {
return false;
// called on current server.
function assignQueues($notify)
{
-
+ if (!$this->id) {
+ return true;
+ }
$servers = $this->availableServers();
$ids = array();
+ $up = array();
foreach($servers as $s) {
$ids[] = $s->id;
}
$target_len = floor( ($totalq + $total_add) / $num_servers );
foreach($in_q as $sid => $cq) {
- if ( $target_len - $cq < 1) {
+ if ( $cq > $target_len) {
continue;
}
$up[ $sid ] = array_slice($to_add, 0, $target_len - $cq);
}
- foreach($to_add as $i) {
- $up[ $ids[0] ][] = $i;
+
+ // add the reminder evently
+ foreach($to_add as $n=>$i) {
+
+ $up[ $ids[$n % $num_servers] ][] = $i;
}
// distribution needs to go to ones that have the shortest queues. - so to balance out the queues
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;
function isBlacklisted($email)
{
+ if (!$this->id) {
+ return false;
+ }
+
// return current server id..
static $cache = array();
// get the domain..
}
function initHelo()
{
+ if (!$this->id) {
+ return;
+ }
$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;