mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
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:
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, [
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user