Ver código fonte

Update Pages\PostValidatorTrait

Add an external variable to calculate the interval.
Visman 4 anos atrás
pai
commit
2629842326
1 arquivos alterados com 3 adições e 2 exclusões
  1. 3 2
      app/Models/Pages/PostValidatorTrait.php

+ 3 - 2
app/Models/Pages/PostValidatorTrait.php

@@ -80,13 +80,14 @@ trait PostValidatorTrait
     /**
      * Проверка времени ограничения флуда
      */
-    public function vCheckTimeout(Validator $v, $submit)
+    public function vCheckTimeout(Validator $v, $submit, $attr, ?int $last)
     {
         if ($v->noValue($submit)) {
             return null;
         }
 
-        $time = \time() - (int) $this->user->last_post;
+        $last = $last > 0 ? $last : $this->user->last_post;
+        $time = \time() - $last;
 
         if ($time < $this->user->g_post_flood) {
             $v->addError(['Flood message', $this->user->g_post_flood - $time], 'e');