| @@ 86-92 (lines=7) @@ | ||
| 83 | ->first(); |
|
| 84 | ||
| 85 | // something is founded :D |
|
| 86 | if ($query !== null) { |
|
| 87 | $answerTime = Date::convertToTimestamp($query->created_at); |
|
| 88 | $delay = $answerTime + $this->_configs['delay'] - time(); |
|
| 89 | if ($delay > 0) { // sounds like config time is not passed now |
|
| 90 | throw new JsonException(__('Spam protection: please, wait %sec% seconds', ['sec' => $delay])); |
|
| 91 | } |
|
| 92 | } |
|
| 93 | } else { // sounds like post, lets try to check latest post |
|
| 94 | $query = CommentPost::where(function($q) { |
|
| 95 | $q->where('user_id', '=', $this->user_id) |
|
| @@ 101-107 (lines=7) @@ | ||
| 98 | ->first(); |
|
| 99 | ||
| 100 | // check if latest post time for this user is founded |
|
| 101 | if ($query !== null) { |
|
| 102 | $postTime = Date::convertToTimestamp($query->created_at); |
|
| 103 | $delay = $postTime + $this->_configs['delay'] - time(); |
|
| 104 | if ($delay > 0) { |
|
| 105 | throw new JsonException(__('Spam protection: please, wait %sec% seconds', ['sec' => $delay])); |
|
| 106 | } |
|
| 107 | } |
|
| 108 | } |
|
| 109 | } |
|
| 110 | ||
| @@ 79-85 (lines=7) @@ | ||
| 76 | ->first(); |
|
| 77 | ||
| 78 | // something is founded :D |
|
| 79 | if ($query !== null) { |
|
| 80 | $answerTime = Date::convertToTimestamp($query->created_at); |
|
| 81 | $delay = $answerTime + $this->_configs['delay'] - time(); |
|
| 82 | if ($delay > 0) { // sounds like config time is not passed now |
|
| 83 | throw new JsonException(__('Spam protection: please, wait %sec% seconds', ['sec' => $delay])); |
|
| 84 | } |
|
| 85 | } |
|
| 86 | ||
| 87 | return true; |
|
| 88 | } |
|
| @@ 84-90 (lines=7) @@ | ||
| 81 | ->first(); |
|
| 82 | ||
| 83 | // check if latest post time for this user is founded |
|
| 84 | if ($query !== null) { |
|
| 85 | $postTime = Date::convertToTimestamp($query->created_at); |
|
| 86 | $delay = $postTime + $this->_configs['delay'] - time(); |
|
| 87 | if ($delay > 0) { |
|
| 88 | throw new JsonException(__('Spam protection: please, wait %sec% seconds', ['sec' => $delay])); |
|
| 89 | } |
|
| 90 | } |
|
| 91 | ||
| 92 | return true; |
|
| 93 | } |
|