Merge branch 'copilot/add-reset-method-to-abuse-interface' of https://github.com/utopia-php/abuse into copilot/add-reset-method-to-abuse-interface

This commit is contained in:
Matej Bačo committed 2026-01-05 22:20:46 +01:00
commit b9aa1351c9
3 files changed
+21 -34

No files matched your search

@@ -262,43 +262,32 @@ class TablesDB extends TimeLimit
{
$timestamp = $this->toDateTime($timestamp);
$response = $this->tablesDB->listRows($this->databaseId, self::TABLE_ID, [
Query::equal('key', [$key]),
Query::equal('time', [$timestamp]),
]);
$rows = $response['rows'];
$data = $rows[0] ?? null;
$data = [
'key' => $key,
'time' => $timestamp,
'count' => $value,
];
if (\is_null($data)) {
$data = [
'key' => $key,
'time' => $timestamp,
'count' => $value,
];
try {
$this->tablesDB->createRow($this->databaseId, self::TABLE_ID, ID::unique(), $data);
} catch (AppwriteException $err) {
if ($err->getType() !== 'row_already_exists') {
throw $err;
}
try {
$this->tablesDB->createRow($this->databaseId, self::TABLE_ID, ID::unique(), $data);
} catch (AppwriteException $err) {
if ($err->getType() !== 'row_already_exists') {
throw $err;
}
$response = $this->tablesDB->listRows($this->databaseId, self::TABLE_ID, [
Query::equal('key', [$key]),
Query::equal('time', [$timestamp]),
]);
$rows = $response['rows'];
$response = $this->tablesDB->listRows($this->databaseId, self::TABLE_ID, [
Query::equal('key', [$key]),
Query::equal('time', [$timestamp]),
]);
$rows = $response['rows'];
$data = $rows[0] ?? null;
$data = $rows[0] ?? null;
if (!is_null($data)) {
$this->tablesDB->updateRow($this->databaseId, self::TABLE_ID, $data['$id'], ['count' => $value]);
} else {
throw new \Exception('Unable to find abuse tracking row after race condition handling');
}
if (!is_null($data)) {
$this->tablesDB->updateRow($this->databaseId, self::TABLE_ID, $data['$id'], ['count' => $value]);
} else {
throw new \Exception('Unable to find abuse tracking row after race condition handling');
}
} else {
$this->tablesDB->updateRow($this->databaseId, self::TABLE_ID, $data['$id'], ['count' => $value]);
}
$this->count = $value;
@@ -225,7 +225,6 @@ class Database extends TimeLimit
*/
protected function set(string $key, int $timestamp, int $value): void
{
$timestamp = $this->toDateTime($timestamp);
Authorization::skip(function () use ($timestamp, $key, $value) {
$data = $this->db->findOne(self::COLLECTION, [
-1
View File
@@ -87,7 +87,6 @@ class Redis extends TimeLimit
*/
protected function set(string $key, int $timestamp, int $value): void
{
$key = self::NAMESPACE . '__' . $key . '__' . $timestamp;
$this->redis->multi()
->set($key, (string)$value)