mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
update: simplify setting events context param.
This commit is contained in:
+14
-6
@@ -204,6 +204,14 @@ abstract class Action extends UtopiaAction
|
||||
: Exception::COLUMN_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the correct collections context for Events queue.
|
||||
*/
|
||||
final protected function getCollectionsEventsContext(): string
|
||||
{
|
||||
return $this->isCollectionsAPI() ? 'collection' : 'table';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the proper column/attribute type based on set context.
|
||||
*/
|
||||
@@ -407,11 +415,11 @@ abstract class Action extends UtopiaAction
|
||||
$queueForEvents
|
||||
->setContext('database', $db)
|
||||
->setParam('databaseId', $databaseId)
|
||||
->setParam('collectionId', $collection->getId())
|
||||
->setParam('tableId', $collection->getId())
|
||||
->setParam('attributeId', $attribute->getId())
|
||||
->setParam('columnId', $attribute->getId())
|
||||
->setParam('tableId', $collection->getId())
|
||||
->setParam('collectionId', $collection->getId())
|
||||
->setContext($this->isCollectionsAPI() ? 'collection' : 'table', $collection);
|
||||
->setContext($this->getCollectionsEventsContext(), $collection);
|
||||
|
||||
$response->setStatusCode(SwooleResponse::STATUS_CODE_CREATED);
|
||||
|
||||
@@ -608,11 +616,11 @@ abstract class Action extends UtopiaAction
|
||||
$queueForEvents
|
||||
->setContext('database', $db)
|
||||
->setParam('databaseId', $databaseId)
|
||||
->setParam('collectionId', $collection->getId())
|
||||
->setParam('tableId', $collection->getId())
|
||||
->setParam('attributeId', $attribute->getId())
|
||||
->setParam('columnId', $attribute->getId())
|
||||
->setParam('tableId', $collection->getId())
|
||||
->setParam('collectionId', $collection->getId())
|
||||
->setContext($this->isCollectionsAPI() ? 'collection' : 'table', $collection);
|
||||
->setContext($this->getCollectionsEventsContext(), $collection);
|
||||
|
||||
return $attribute;
|
||||
}
|
||||
|
||||
+4
-5
@@ -145,13 +145,12 @@ class Delete extends Action
|
||||
$queueForEvents
|
||||
->setContext('database', $db)
|
||||
->setParam('databaseId', $databaseId)
|
||||
->setPayload($response->output($attribute, $model))
|
||||
->setParam('attributeId', $attribute->getId())
|
||||
->setParam('columnId', $attribute->getId())
|
||||
->setParam('collectionId', $collection->getId())
|
||||
->setParam('tableId', $collection->getId())
|
||||
// set proper context
|
||||
->setContext($this->isCollectionsAPI() ? 'collection' : 'table', $collection);
|
||||
->setParam('attributeId', $attribute->getId())
|
||||
->setParam('columnId', $attribute->getId())
|
||||
->setPayload($response->output($attribute, $model))
|
||||
->setContext($this->getCollectionsEventsContext(), $collection);
|
||||
|
||||
$response->noContent();
|
||||
}
|
||||
|
||||
+8
@@ -127,4 +127,12 @@ abstract class Action extends UtopiaAction
|
||||
? Exception::DOCUMENT_MISSING_PAYLOAD
|
||||
: Exception::ROW_MISSING_PAYLOAD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the correct collections context for Events queue.
|
||||
*/
|
||||
final protected function getCollectionsEventsContext(): string
|
||||
{
|
||||
return $this->isCollectionsAPI() ? 'collection' : 'table';
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -309,11 +309,11 @@ class Create extends Action
|
||||
$queueForEvents
|
||||
->setParam('databaseId', $databaseId)
|
||||
->setContext('database', $database)
|
||||
->setParam('rowId', $document->getId())
|
||||
->setParam('documentId', $document->getId())
|
||||
->setParam('tableId', $collection->getId())
|
||||
->setParam('collectionId', $collection->getId())
|
||||
->setParam('tableId', $collection->getId())
|
||||
->setParam('documentId', $document->getId())
|
||||
->setParam('rowId', $document->getId())
|
||||
->setPayload($response->getPayload(), sensitive: $relationships)
|
||||
->setContext($this->isCollectionsAPI() ? 'collection' : 'table', $collection);
|
||||
->setContext($this->getCollectionsEventsContext(), $collection);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -164,11 +164,11 @@ class Delete extends Action
|
||||
$queueForEvents
|
||||
->setParam('databaseId', $databaseId)
|
||||
->setContext('database', $database)
|
||||
->setParam('rowId', $document->getId())
|
||||
->setParam('documentId', $document->getId())
|
||||
->setParam('tableId', $collection->getId())
|
||||
->setParam('collectionId', $collection->getId())
|
||||
->setContext($this->isCollectionsAPI() ? 'collection' : 'table', $collection)
|
||||
->setParam('tableId', $collection->getId())
|
||||
->setParam('documentId', $document->getId())
|
||||
->setParam('rowId', $document->getId())
|
||||
->setContext($this->getCollectionsEventsContext(), $collection)
|
||||
->setPayload($response->output($document, $this->getResponseModel()), sensitive: $relationships);
|
||||
|
||||
$response->noContent();
|
||||
|
||||
+4
-4
@@ -297,11 +297,11 @@ class Update extends Action
|
||||
$queueForEvents
|
||||
->setParam('databaseId', $databaseId)
|
||||
->setContext('database', $database)
|
||||
->setParam('rowId', $document->getId())
|
||||
->setParam('documentId', $document->getId())
|
||||
->setParam('tableId', $collection->getId())
|
||||
->setParam('collectionId', $collection->getId())
|
||||
->setContext($this->isCollectionsAPI() ? 'collection' : 'table', $collection)
|
||||
->setParam('tableId', $collection->getId())
|
||||
->setParam('documentId', $document->getId())
|
||||
->setParam('rowId', $document->getId())
|
||||
->setContext($this->getCollectionsEventsContext(), $collection)
|
||||
->setPayload($response->getPayload(), sensitive: $relationships);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,4 +152,12 @@ abstract class Action extends UtopiaAction
|
||||
? Exception::ATTRIBUTE_NOT_AVAILABLE
|
||||
: Exception::COLUMN_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the correct collections context for Events queue.
|
||||
*/
|
||||
final protected function getCollectionsEventsContext(): string
|
||||
{
|
||||
return $this->isCollectionsAPI() ? 'collection' : 'table';
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -221,9 +221,9 @@ class Create extends Action
|
||||
->setContext('database', $db)
|
||||
->setParam('databaseId', $databaseId)
|
||||
->setParam('indexId', $index->getId())
|
||||
->setParam('tableId', $collection->getId())
|
||||
->setParam('collectionId', $collection->getId())
|
||||
->setContext($this->isCollectionsAPI() ? 'collection' : 'table', $collection);
|
||||
->setParam('tableId', $collection->getId())
|
||||
->setContext($this->getCollectionsEventsContext(), $collection);
|
||||
|
||||
$response
|
||||
->setStatusCode(SwooleResponse::STATUS_CODE_ACCEPTED)
|
||||
|
||||
+2
-2
@@ -118,8 +118,8 @@ class Delete extends Action
|
||||
->setParam('indexId', $index->getId())
|
||||
->setParam('tableId', $collection->getId())
|
||||
->setParam('collectionId', $collection->getId())
|
||||
->setPayload($response->output($index, $this->getResponseModel()))
|
||||
->setContext($this->isCollectionsAPI() ? 'collection' : 'table', $collection);
|
||||
->setContext($this->getCollectionsEventsContext(), $collection)
|
||||
->setPayload($response->output($index, $this->getResponseModel()));
|
||||
|
||||
$response->noContent();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user