[Rspamd] Dynamic ratelimit fixed, removed async redis request; Ready to implement per-user ratelimits via UI (tbd)

This commit is contained in:
andryyy
2017-08-30 21:42:39 +02:00
parent 66ae588445
commit b1213c51d7
8 changed files with 565 additions and 396 deletions

View File

@@ -238,7 +238,6 @@ if (isset($_SESSION['mailcow_cc_role'])) {
}
?>
<hr>
<!--
<form data-id="domratelimit" class="form-inline well" method="post">
<div class="form-group">
<label class="control-label">Ratelimit</label>
@@ -256,7 +255,6 @@ if (isset($_SESSION['mailcow_cc_role'])) {
</div>
</form>
<hr>
-->
<div class="row">
<div class="col-sm-6">
<h4><?=$lang['user']['spamfilter_wl'];?></h4>
@@ -316,7 +314,7 @@ if (isset($_SESSION['mailcow_cc_role'])) {
!empty($_GET["aliasdomain"])) {
$alias_domain = $_GET["aliasdomain"];
$result = mailbox('get', 'alias_domain_details', $alias_domain);
// $rl = mailbox('get', 'domain_ratelimit', $alias_domain);
$rl = mailbox('get', 'domain_ratelimit', $alias_domain);
if (!empty($result)) {
?>
<h4><?=$lang['edit']['edit_alias_domain'];?></h4>
@@ -341,7 +339,6 @@ if (isset($_SESSION['mailcow_cc_role'])) {
</div>
</div>
</form>
<!--
<hr>
<form data-id="domratelimit" class="form-inline well" method="post">
<div class="form-group">
@@ -359,7 +356,6 @@ if (isset($_SESSION['mailcow_cc_role'])) {
<button class="btn btn-default" id="edit_selected" data-id="domratelimit" data-item="<?=$alias_domain;?>" data-api-url='edit/domain-ratelimit' data-api-attr='{}' href="#"><?=$lang['admin']['save'];?></button>
</div>
</form>
-->
<?php
if (!empty($dkim = dkim('details', $alias_domain))) {
?>

View File

@@ -1214,7 +1214,6 @@ function mailbox($_action, $_type, $_data = null) {
}
if (empty($rl_value)) {
try {
$redis->hDel('RL_OBJECT', $domain);
$redis->hDel('RL_VALUE', $domain);
}
catch (RedisException $e) {
@@ -1227,7 +1226,6 @@ function mailbox($_action, $_type, $_data = null) {
}
else {
try {
$redis->hSet('RL_OBJECT', $domain, '1');
$redis->hSet('RL_VALUE', $domain, $rl_value . ' / 1' . $rl_frame);
}
catch (RedisException $e) {
@@ -2389,7 +2387,7 @@ function mailbox($_action, $_type, $_data = null) {
return false;
}
try {
if (($rl_value = $redis->hGet('RL_VALUE', $_data)) && $redis->hGet('RL_OBJECT', $_data)) {
if ($rl_value = $redis->hGet('RL_VALUE', $_data)) {
$rl = explode(' / 1', $rl_value);
$data['value'] = $rl[0];
$data['frame'] = $rl[1];