diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 78c56191..c31fe048 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -1742,9 +1742,9 @@ class User extends RowModel public function getEventCounters(array $list): array { + $count_of_keys = sizeof(array_keys($list)); $ev_str = $this->getRecord()->events_counters; $counters = []; - $compared_counters = []; if (!$ev_str) { bdump(sizeof(array_keys($list))); @@ -1752,28 +1752,33 @@ class User extends RowModel $counters[] = 0; } } else { - $counters = unpack("S*", base64_decode($ev_str)); - } - - $_i = 0; - - foreach ($list as $name => $value) { - $compared_counters[$name] = $counters[$_i] ?? 0; - $_i += 1; + $counters = unpack("S".$count_of_keys, base64_decode($ev_str, true)); + } + bdump(array_keys($list)); bdump($counters); - bdump($compared_counters); return [ - 'counters' => $compared_counters, + 'counters' => array_combine(array_keys($list), $counters), 'refresh_time' => $this->getRecord()->events_refresh_time, ]; } public function stateEvents(array $state_list): void { - bdump($state_list); - $this->stateChanges("events_counters", base64_encode(pack("S*", array_values($state_list)))); + $_ = ""; + $i = 0; + + foreach ($state_list as $item => $id) { + bdump($i); + $_ .= "S"; + $i += 1; + } + + bdump($_); + bdump(array_values($state_list)); + + $this->stateChanges("events_counters", base64_encode(pack($_, ...array_values($state_list)))); if (!$this->getRecord()->events_refresh_time) { $this->stateChanges("events_refresh_time", time()); diff --git a/Web/Util/EventRateLimiter.php b/Web/Util/EventRateLimiter.php index 072b11c7..3257bc4e 100644 --- a/Web/Util/EventRateLimiter.php +++ b/Web/Util/EventRateLimiter.php @@ -65,7 +65,7 @@ class EventRateLimiter return false; } - $is_limit_exceed = $event_counter > $limitForThatEvent; + $is_limit_exceed = $event_counter >= $limitForThatEvent; bdump($is_limit_exceed); if (!$is_limit_exceed && $is_update) { diff --git a/openvk-example.yml b/openvk-example.yml index c92d0e2f..548ec9b7 100644 --- a/openvk-example.yml +++ b/openvk-example.yml @@ -50,7 +50,7 @@ openvk: groups.sub: 50 friends.outgoing_sub: 25 wall.post: 5000 - gifts.send: 20 + gifts.send: 30 blacklists: limit: 100 applyToAdmins: true