9namespace Bitrix\Sender\Integration\Bitrix24\Limitation;
11use Bitrix\Main\Config;
12use Bitrix\Main\Type\Date;
13use Bitrix\Main\Localization\Loc;
15use Bitrix\Sender\Message;
16use Bitrix\Sender\Dispatch\Semantics;
17use Bitrix\Sender\Entity\Letter;
18use Bitrix\Sender\Integration\Im\Notification;
19use Bitrix\Sender\Internals\Model;
21Loc::loadMessages(__FILE__);
40 if ($ratio >= self::getBlockRate())
53 $updateTimestamp = (int) self::getParam(
'date_update', 0);
54 $dateToday =
new Date();
55 if ($dateToday->getTimestamp() <= $updateTimestamp)
59 self::setParam(
'date_update', $dateToday->getTimestamp());
60 if (!$updateTimestamp)
73 $countSent = (int) $yesterdayData[
'SENT_CNT'];
74 $countError = (int) $yesterdayData[
'ERROR_CNT'];
75 if ($countSent > 0 && ($countError / $countSent) > 0.1)
77 $countSent -= $countError;
81 if ($ratio >= self::getBlockRate())
85 elseif ($ratio >= self::getDownRate())
103 $limit = $limit ?: self::getInitialLimit();
104 $limit = $limit * self::getLimitMultiplier();
105 if ($limit > self::getMaxLimit())
113 ->withMessage(self::getNotifyText(
'upgraded'))
131 ->withMessage(self::getNotifyText(
'downgraded'))
144 $letters = Model\LetterTable::getList(
array(
145 'select' =>
array(
'ID'),
147 '=STATUS' => Semantics::getWorkStates(),
148 '=MESSAGE_CODE' =>
Message\iBase::CODE_MAIL
153 foreach ($letters as $letterData)
155 $letter->load($letterData[
'ID']);
156 if (!$letter->getId())
161 $state = $letter->getState();
162 if ($state->canPause())
166 else if ($state->canReady())
170 else if ($state->canStop())
176 self::downgrade(
false);
177 self::setParam(
'blocked',
'Y');
180 ->withMessage(self::getNotifyText(
'blocked'))
192 return self::getParam(
'blocked',
'N') ===
'Y';
202 return round(self::getParam(
'down_over_abuses', 8) / self::$base, 3);
212 $abusesPer1000Mails = self::getParam(
'block_over_abuses', 20);
213 return round($abusesPer1000Mails / self::$base, 3);
223 return (
int) self::getParam(
'initial', 1000);
233 return (
int) self::getParam(
'max', 16000);
243 return (
float) self::getParam(
'multiplier', 2);
257 if (!$sentCount || $sentCount < 200 || !$abuseCount)
262 return round($abuseCount / $sentCount, 3);
298 return Loc::getMessage(
"SENDER_INTEGRATION_BITRIX24_RATING_{$code}1");
if($_SERVER $defaultValue['REQUEST_METHOD']==="GET" &&!empty($RestoreDefaults) && $bizprocPerms==="W" &&check_bitrix_sessid())
static get($moduleId, $name, $default="", $siteId=false)
static set($moduleId, $name, $value="", $siteId="")
static getNotifyText($code)
static getParam($name, $defaultValue=0)
static getRatio($daysLeft=0)
static getLimitMultiplier()
static setParam($name, $value)
static downgrade($isNotify=true)
static getRowByDate($daysLeft=0)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)