diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php index 4d54d0bdf3..a07a4be561 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php @@ -465,6 +465,15 @@ abstract class Action extends UtopiaAction $dbForProject->purgeCachedCollection('database_' . $db->getSequence() . '_collection_' . $relatedCollection->getSequence()); } + $queueForEvents + ->setContext('database', $db) + ->setParam('databaseId', $databaseId) + ->setParam('collectionId', $collection->getId()) + ->setParam('tableId', $collection->getId()) + ->setParam('attributeId', $attribute->getId()) + ->setParam('columnId', $attribute->getId()) + ->setContext($this->getCollectionsEventsContext(), $collection); + $publisherForDatabase->enqueue(new DatabaseMessage( project: $queueForEvents->getProject(), user: $queueForEvents->getUser(), @@ -477,15 +486,6 @@ abstract class Action extends UtopiaAction events: Event::generateEvents($queueForEvents->getEvent(), $queueForEvents->getParams()), )); - $queueForEvents - ->setContext('database', $db) - ->setParam('databaseId', $databaseId) - ->setParam('collectionId', $collection->getId()) - ->setParam('tableId', $collection->getId()) - ->setParam('attributeId', $attribute->getId()) - ->setParam('columnId', $attribute->getId()) - ->setContext($this->getCollectionsEventsContext(), $collection); - $response->setStatusCode(SwooleResponse::STATUS_CODE_CREATED); return $attribute; diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Delete.php index 93fbbf3277..ff1636ae60 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Delete.php @@ -130,18 +130,6 @@ class Delete extends Action } } - $publisherForDatabase->enqueue(new DatabaseMessage( - project: $queueForEvents->getProject(), - user: $queueForEvents->getUser(), - type: DATABASE_TYPE_DELETE_ATTRIBUTE, - database: $db, - collection: $this->isCollectionsAPI() ? null : $collection, - document: $this->isCollectionsAPI() ? null : $attribute, - table: $this->isCollectionsAPI() ? $collection : null, - row: $this->isCollectionsAPI() ? $attribute : null, - events: Event::generateEvents($queueForEvents->getEvent(), $queueForEvents->getParams()), - )); - $type = $attribute->getAttribute('type'); $format = $attribute->getAttribute('format'); @@ -157,6 +145,18 @@ class Delete extends Action ->setPayload($response->output($attribute, $model)) ->setContext($this->getCollectionsEventsContext(), $collection); + $publisherForDatabase->enqueue(new DatabaseMessage( + project: $queueForEvents->getProject(), + user: $queueForEvents->getUser(), + type: DATABASE_TYPE_DELETE_ATTRIBUTE, + database: $db, + collection: $this->isCollectionsAPI() ? null : $collection, + document: $this->isCollectionsAPI() ? null : $attribute, + table: $this->isCollectionsAPI() ? $collection : null, + row: $this->isCollectionsAPI() ? $attribute : null, + events: Event::generateEvents($queueForEvents->getEvent(), $queueForEvents->getParams()), + )); + $response->noContent(); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Delete.php index 531ceff37a..87171fb2fe 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Delete.php @@ -90,6 +90,12 @@ class Delete extends Action $dbForDatabases = $getDatabasesDB($database); $dbForDatabases->purgeCachedCollection('database_' . $database->getSequence() . '_collection_' . $collection->getSequence()); + $queueForEvents + ->setParam('databaseId', $databaseId) + ->setContext('database', $database) + ->setParam($this->getEventsParamKey(), $collection->getId()) + ->setPayload($response->output($collection, $this->getResponseModel())); + $publisherForDatabase->enqueue(new DatabaseMessage( project: $queueForEvents->getProject(), user: $queueForEvents->getUser(), @@ -100,12 +106,6 @@ class Delete extends Action events: Event::generateEvents($queueForEvents->getEvent(), $queueForEvents->getParams()), )); - $queueForEvents - ->setParam('databaseId', $databaseId) - ->setContext('database', $database) - ->setParam($this->getEventsParamKey(), $collection->getId()) - ->setPayload($response->output($collection, $this->getResponseModel())); - $response->noContent(); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php index 7dee44700e..6c13a5c33c 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php @@ -229,6 +229,14 @@ class Create extends Action $dbForProject->purgeCachedDocument('database_' . $db->getSequence(), $collectionId); + $queueForEvents + ->setContext('database', $db) + ->setParam('databaseId', $databaseId) + ->setParam('indexId', $index->getId()) + ->setParam('collectionId', $collection->getId()) + ->setParam('tableId', $collection->getId()) + ->setContext($this->getCollectionsEventsContext(), $collection); + $publisherForDatabase->enqueue(new DatabaseMessage( project: $queueForEvents->getProject(), user: $queueForEvents->getUser(), @@ -241,14 +249,6 @@ class Create extends Action events: Event::generateEvents($queueForEvents->getEvent(), $queueForEvents->getParams()), )); - $queueForEvents - ->setContext('database', $db) - ->setParam('databaseId', $databaseId) - ->setParam('indexId', $index->getId()) - ->setParam('collectionId', $collection->getId()) - ->setParam('tableId', $collection->getId()) - ->setContext($this->getCollectionsEventsContext(), $collection); - $response ->setStatusCode(SwooleResponse::STATUS_CODE_ACCEPTED) ->dynamic($index, $this->getResponseModel()); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Delete.php index ab630c5629..82cada6e0d 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Delete.php @@ -104,6 +104,15 @@ class Delete extends Action $dbForProject->purgeCachedDocument('database_' . $db->getSequence(), $collectionId); + $queueForEvents + ->setContext('database', $db) + ->setParam('databaseId', $databaseId) + ->setParam('indexId', $index->getId()) + ->setParam('tableId', $collection->getId()) + ->setParam('collectionId', $collection->getId()) + ->setContext($this->getCollectionsEventsContext(), $collection) + ->setPayload($response->output($index, $this->getResponseModel())); + $publisherForDatabase->enqueue(new DatabaseMessage( project: $queueForEvents->getProject(), user: $queueForEvents->getUser(), @@ -116,15 +125,6 @@ class Delete extends Action events: Event::generateEvents($queueForEvents->getEvent(), $queueForEvents->getParams()), )); - $queueForEvents - ->setContext('database', $db) - ->setParam('databaseId', $databaseId) - ->setParam('indexId', $index->getId()) - ->setParam('tableId', $collection->getId()) - ->setParam('collectionId', $collection->getId()) - ->setContext($this->getCollectionsEventsContext(), $collection) - ->setPayload($response->output($index, $this->getResponseModel())); - $response->noContent(); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Delete.php index 87f200728f..058c48d68f 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Delete.php @@ -79,6 +79,10 @@ class Delete extends Action $dbForProject->purgeCachedDocument('databases', $database->getId()); $dbForProject->purgeCachedCollection('databases_' . $database->getSequence()); + $queueForEvents + ->setParam('databaseId', $database->getId()) + ->setPayload($response->output($database, UtopiaResponse::MODEL_DATABASE)); + $publisherForDatabase->enqueue(new DatabaseMessage( project: $queueForEvents->getProject(), user: $queueForEvents->getUser(), @@ -87,10 +91,6 @@ class Delete extends Action events: Event::generateEvents($queueForEvents->getEvent(), $queueForEvents->getParams()), )); - $queueForEvents - ->setParam('databaseId', $database->getId()) - ->setPayload($response->output($database, UtopiaResponse::MODEL_DATABASE)); - $response->noContent(); } }