AntonLV 8 년 전
부모
커밋
c86f647599

+ 1 - 1
inc/classes/BxDolCronQueueEmail.php

@@ -11,7 +11,7 @@ class BxDolCronQueueEmail extends BxDolCron
 {
     public function processing()
     {
-    	BxDolQueueEmail::getInstance()->send((int)getParam('sys_eq_send_per_start'));
+    	BxDolQueueEmail::getInstance()->send();
     }
 }
 

+ 1 - 1
inc/classes/BxDolCronQueuePush.php

@@ -11,7 +11,7 @@ class BxDolCronQueuePush extends BxDolCron
 {
     public function processing()
     {
-    	BxDolQueuePush::getInstance()->send((int)getParam('sys_push_queue_send_per_start'));
+    	BxDolQueuePush::getInstance()->send();
     }
 }
 

+ 18 - 10
inc/classes/BxDolQueue.php

@@ -11,6 +11,11 @@ class BxDolQueue extends BxDolFactory
 {
     protected $_oQuery;
 
+    protected $_iLimitSend;
+    protected $_iLimitSendPerRecipient;
+
+    protected $_aSentTo;
+
     protected function __construct()
     {
         if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
@@ -28,19 +33,22 @@ class BxDolQueue extends BxDolFactory
             trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR);
     }
 
-	/**
-	 * Send some number of email form mail queue
-	 *
-	 * @param int $iLimit - number of emails to send
-	 * @return real number of sent emails
-	 */
-    public function send($iLimit = 1)
+    /**
+     * Send some number of items (email/push) from queue
+     *
+     * @param int $iLimit - number of queue items to send
+     * @return real number of sent queue items
+     */
+    public function send($iLimit = 0)
     {
         $aSent = array();
 
-    	$aMails = $this->_oQuery->getItems(array('type' => 'to_send', 'start' => 0, 'per_page' => $iLimit));
-    	foreach($aMails as $iId => $aMail)
-    	    if(call_user_func_array(array($this, '_send'), array_slice($aMail, 1)))
+        if(empty($iLimit))
+            $iLimit = $this->_iLimitSend;
+
+    	$aItems = $this->_oQuery->getItems(array('type' => 'to_send', 'start' => 0, 'per_page' => $iLimit));
+    	foreach($aItems as $iId => $aItem)
+    	    if(call_user_func_array(array($this, '_send'), array_slice($aItem, 1)))
     	        $aSent[] = $iId;
 
         if(!empty($aSent) && is_array($aSent))

+ 15 - 2
inc/classes/BxDolQueueEmail.php

@@ -14,6 +14,9 @@ class BxDolQueueEmail extends BxDolQueue implements iBxDolSingleton
         parent::__construct();
 
         $this->_oQuery = new BxDolQueueEmailQuery();
+
+        $this->_iLimitSend = (int)getParam('sys_eq_send_per_start');
+        $this->_iLimitSendPerRecipient = (int)getParam('sys_eq_send_per_start_to_recipient');
     }
 
     /**
@@ -49,12 +52,22 @@ class BxDolQueueEmail extends BxDolQueue implements iBxDolSingleton
      * Internal method which performs sending using predefined list of params.
      */
     protected function _send($sEmail, $sSubject, $sBody, $sParams = '')
-    {
+    {           
+        if(isset($this->_aSentTo[$sEmail]) && (int)$this->_aSentTo[$sEmail] >= $this->_iLimitSendPerRecipient)
+            return false;
+            
         $aParams = array();
         if(!empty($sParams))
             $aParams = unserialize($sParams);
 
-        return call_user_func_array('sendMail', array_merge(array($sEmail, $sSubject, $sBody), $aParams));
+        if(!call_user_func_array('sendMail', array_merge(array($sEmail, $sSubject, $sBody), $aParams)))
+            return false;
+
+        if(!isset($this->_aSentTo[$sEmail]))
+            $this->_aSentTo[$sEmail] = 0;
+        $this->_aSentTo[$sEmail] += 1;
+
+        return true;
     }
 }
 

+ 14 - 1
inc/classes/BxDolQueuePush.php

@@ -14,6 +14,9 @@ class BxDolQueuePush extends BxDolQueue implements iBxDolSingleton
         parent::__construct();
 
         $this->_oQuery = new BxDolQueuePushQuery();
+
+        $this->_iLimitSend = (int)getParam('sys_push_queue_send_per_start');
+        $this->_iLimitSendPerRecipient = (int)getParam('sys_push_queue_send_per_start_to_recipient');
     }
 
     /**
@@ -47,7 +50,17 @@ class BxDolQueuePush extends BxDolQueue implements iBxDolSingleton
      */
     protected function _send($iProfileId, $sMessage)
     {
-        return BxDolPush::getInstance()->send($iProfileId, unserialize($sMessage));
+        if(isset($this->_aSentTo[$iProfileId]) && (int)$this->_aSentTo[$iProfileId] >= $this->_iLimitSendPerRecipient)
+            return false;
+
+        if(!BxDolPush::getInstance()->send($iProfileId, unserialize($sMessage)))
+            return false;
+
+        if(!isset($this->_aSentTo[$iProfileId]))
+            $this->_aSentTo[$iProfileId] = 0;
+        $this->_aSentTo[$iProfileId] += 1;
+
+        return true;
     }
 }
 

+ 4 - 2
install/sql/system.sql

@@ -503,7 +503,8 @@ INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `ex
 (@iCategoryId, 'enable_notification_pruning', '_adm_stg_cpt_option_enable_notification_pruning', '', 'checkbox', '', '', '', 1),
 (@iCategoryId, 'enable_notification_account', '_adm_stg_cpt_option_enable_notification_account', 'on', 'checkbox', '', '', '', 2),
 
-(@iCategoryId, 'sys_eq_send_per_start', '_adm_stg_cpt_option_sys_eq_send_per_start', '500',  'digit', '', '', '', 10);
+(@iCategoryId, 'sys_eq_send_per_start', '_adm_stg_cpt_option_sys_eq_send_per_start', '500',  'digit', '', '', '', 10),
+(@iCategoryId, 'sys_eq_send_per_start_to_recipient', '_adm_stg_cpt_option_sys_eq_send_per_start_to_recipient', '2',  'digit', '', '', '', 11);
 
 --
 -- CATEGORY: Push Notifications
@@ -517,7 +518,8 @@ INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `ex
 (@iCategoryId, 'sys_push_short_name', '_adm_stg_cpt_option_sys_push_short_name', '', 'digit', '', '', '', 3),
 (@iCategoryId, 'sys_push_safari_id', '_adm_stg_cpt_option_sys_push_safari_id', '', 'digit', '', '', '', 4),
 
-(@iCategoryId, 'sys_push_queue_send_per_start', '_adm_stg_cpt_option_sys_push_queue_send_per_start', '500',  'digit', '', '', '', 10);
+(@iCategoryId, 'sys_push_queue_send_per_start', '_adm_stg_cpt_option_sys_push_queue_send_per_start', '500',  'digit', '', '', '', 10),
+(@iCategoryId, 'sys_push_queue_send_per_start_to_recipient', '_adm_stg_cpt_option_sys_push_queue_send_per_start_to_recipient', '2',  'digit', '', '', '', 11);
 
 
 --

+ 2 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -1303,6 +1303,7 @@
 	<string name="_adm_stg_cpt_option_sys_embedly_api_pattern"><![CDATA[Embed.ly API pattern (fill in to use instead of Iframely)]]></string>
 	<string name="_adm_stg_cpt_option_sys_iframely_api_key"><![CDATA[Iframely API key]]></string>
 	<string name="_adm_stg_cpt_option_sys_eq_send_per_start"><![CDATA[Number of messages to send from mail queue per run]]></string>
+        <string name="_adm_stg_cpt_option_sys_eq_send_per_start_to_recipient"><![CDATA[Number of messages to send from mail queue per run to some recipient]]></string>
 	<string name="_adm_stg_cpt_option_sys_oauth_key"><![CDATA[UNA account key]]></string>
 	<string name="_adm_stg_cpt_option_sys_oauth_secret"><![CDATA[UNA account secret]]></string>
 	<string name="_adm_stg_cpt_option_sys_page_cache_enable"><![CDATA[Enable Page cache]]></string>
@@ -1316,6 +1317,7 @@
     <string name="_adm_stg_cpt_option_sys_push_short_name"><![CDATA[Short name (required only for http sites. It must match the Subdomain you entered on the Web Push settings on the OneSignal dashboard)]]></string>
     <string name="_adm_stg_cpt_option_sys_push_safari_id"><![CDATA[Apple Safari Web ID on the Web Push settings]]></string>
     <string name="_adm_stg_cpt_option_sys_push_queue_send_per_start"><![CDATA[Number of messages to send from Push queue per run]]></string>
+    <string name="_adm_stg_cpt_option_sys_push_queue_send_per_start_to_recipient"><![CDATA[Number of messages to send from Push queue per run to some recipient]]></string>
 	<string name="_adm_stg_cpt_option_sys_twilio_gate_sid"><![CDATA[Account SID]]></string>
 	<string name="_adm_stg_cpt_option_sys_twilio_gate_token"><![CDATA[Auth token]]></string>
 	<string name="_adm_stg_cpt_option_sys_twilio_gate_from_number"><![CDATA[Default 'From' number for SMS]]></string>    

+ 2 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -1301,6 +1301,7 @@
     <string name="_adm_stg_cpt_option_sys_embedly_api_pattern"><![CDATA[Шаблон Embed.ly API (заполните, чтобы использовать вместо Iframely)]]></string>
     <string name="_adm_stg_cpt_option_sys_iframely_api_key"><![CDATA[Ключ Iframely API]]></string>
     <string name="_adm_stg_cpt_option_sys_eq_send_per_start"><![CDATA[Количество сообщенией, отправляемое из имейл очереди при каждом запуске]]></string>
+    <string name="_adm_stg_cpt_option_sys_eq_send_per_start_to_recipient"><![CDATA[Количество сообщенией, отправляемое из имейл очереди одному и тому же получателю при каждом запуске]]></string>
 	<string name="_adm_stg_cpt_option_sys_oauth_key"><![CDATA[UNA-аккаунт - Key (ключ)]]></string>
 	<string name="_adm_stg_cpt_option_sys_oauth_secret"><![CDATA[UNA-аккаунт - Secret (секретное слово)]]></string>
 	<string name="_adm_stg_cpt_option_sys_page_cache_enable"><![CDATA[Задействовать кэш для страниц]]></string>
@@ -1314,6 +1315,7 @@
     <string name="_adm_stg_cpt_option_sys_push_short_name"><![CDATA[Короткое имя (требуется только если у вас https сайт. Оно должно совпадать с поддоменом, введёным, в настройках пуш оповещений на OneSignal)]]></string>
     <string name="_adm_stg_cpt_option_sys_push_safari_id"><![CDATA[Apple Safari Web ID в натройках Web Push]]></string>
     <string name="_adm_stg_cpt_option_sys_push_queue_send_per_start"><![CDATA[Количество сообщенией, отправляемое из Push очереди при каждом запуске]]></string>
+    <string name="_adm_stg_cpt_option_sys_push_queue_send_per_start_to_recipient"><![CDATA[Количество сообщенией, отправляемое из Push очереди одному и тому же получателю при каждом запуске]]></string>
 	<string name="_adm_stg_cpt_option_sys_twilio_gate_sid"><![CDATA[Account SID]]></string>
 	<string name="_adm_stg_cpt_option_sys_twilio_gate_token"><![CDATA[Auth token]]></string>
 	<string name="_adm_stg_cpt_option_sys_twilio_gate_from_number"><![CDATA[Номер для отправки SMS по умолчанию]]></string>