mirror of
https://github.com/openvk/openvk
synced 2025-07-01 13:38:15 +03:00
draft v.0.99
This commit is contained in:
parent
c3b1e46909
commit
636a9e5b67
4 changed files with 17 additions and 5 deletions
|
@ -1755,11 +1755,11 @@ class User extends RowModel
|
|||
$counters = unpack("S*", base64_decode($ev_str));
|
||||
}
|
||||
|
||||
$i = 1;
|
||||
$_i = 0;
|
||||
|
||||
foreach ($list as $name => $value) {
|
||||
$compared_counters[$name] = $counters[$i] ?? 0;
|
||||
$i += 1;
|
||||
$compared_counters[$name] = $counters[$_i] ?? 0;
|
||||
$_i += 1;
|
||||
}
|
||||
|
||||
bdump($counters);
|
||||
|
@ -1773,7 +1773,7 @@ class User extends RowModel
|
|||
public function stateEvents(array $state_list): void
|
||||
{
|
||||
bdump($state_list);
|
||||
$this->stateChanges("events_counters", base64_encode(pack("S*", ...array_values($state_list))));
|
||||
$this->stateChanges("events_counters", base64_encode(pack("S*", array_values($state_list))));
|
||||
|
||||
if (!$this->getRecord()->events_refresh_time) {
|
||||
$this->stateChanges("events_refresh_time", time());
|
||||
|
|
|
@ -108,6 +108,12 @@ final class GroupPresenter extends OpenVKPresenter
|
|||
$this->flashFail("err", tr("error"), tr("forbidden"));
|
||||
}
|
||||
|
||||
if (!$club->getSubscriptionStatus($this->user->identity)) {
|
||||
if (\openvk\Web\Util\EventRateLimiter::i()->tryToLimit($this->user->identity, "groups.sub")) {
|
||||
$this->flashFail("err", tr("error"), tr("limit_exceed_exception"));
|
||||
}
|
||||
}
|
||||
|
||||
$club->toggleSubscription($this->user->identity);
|
||||
|
||||
$this->redirect($club->getURL());
|
||||
|
|
|
@ -418,6 +418,12 @@ final class UserPresenter extends OpenVKPresenter
|
|||
if ($this->postParam("act") == "rej") {
|
||||
$user->changeFlags($this->user->identity, 0b10000000, true);
|
||||
} else {
|
||||
if ($user->getSubscriptionStatus($this->user->identity) == \openvk\Web\Models\Entities\User::SUBSCRIPTION_ABSENT) {
|
||||
if (\openvk\Web\Util\EventRateLimiter::i()->tryToLimit($this->user->identity, "friends.outgoing_sub")) {
|
||||
$this->flashFail("err", tr("error"), tr("limit_exceed_exception"));
|
||||
}
|
||||
}
|
||||
|
||||
$user->toggleSubscription($this->user->identity);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,8 +48,8 @@ class EventRateLimiter
|
|||
return false;
|
||||
}
|
||||
|
||||
$limitForThatEvent = $eventsList[$event_type];
|
||||
$eventsStats = $user->getEventCounters($eventsList);
|
||||
$limitForThatEvent = $eventsList[$event_type];
|
||||
|
||||
$counters = $eventsStats["counters"];
|
||||
$refresh_time = $eventsStats["refresh_time"];
|
||||
|
|
Loading…
Reference in a new issue