mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 00:49:02 +00:00
update: simplify setting events context param.
This commit is contained in:
parent
5022a052ce
commit
fbe2609f7b
9 changed files with 50 additions and 27 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue