Merge pull request #6958 from appwrite/fix-events-queue-proxy
Fix events queue
This commit is contained in:
commit
a8ee31f9ae
1 changed files with 15 additions and 15 deletions
|
@ -37,10 +37,11 @@ App::post('/v1/proxy/rules')
|
||||||
->param('resourceId', '', new UID(), 'ID of resource for the action type. If resourceType is "api", leave empty. If resourceType is "function", provide ID of the function.', true)
|
->param('resourceId', '', new UID(), 'ID of resource for the action type. If resourceType is "api", leave empty. If resourceType is "function", provide ID of the function.', true)
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->inject('project')
|
->inject('project')
|
||||||
->inject('events')
|
->inject('queueForCertificates')
|
||||||
|
->inject('queueForEvents')
|
||||||
->inject('dbForConsole')
|
->inject('dbForConsole')
|
||||||
->inject('dbForProject')
|
->inject('dbForProject')
|
||||||
->action(function (string $domain, string $resourceType, string $resourceId, Response $response, Document $project, Event $events, Database $dbForConsole, Database $dbForProject) {
|
->action(function (string $domain, string $resourceType, string $resourceId, Response $response, Document $project, Certificate $queueForCertificates, Event $queueForEvents, Database $dbForConsole, Database $dbForProject) {
|
||||||
$mainDomain = App::getEnv('_APP_DOMAIN', '');
|
$mainDomain = App::getEnv('_APP_DOMAIN', '');
|
||||||
if ($domain === $mainDomain) {
|
if ($domain === $mainDomain) {
|
||||||
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your main domain to specific resource. Please use subdomain or a different domain.');
|
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your main domain to specific resource. Please use subdomain or a different domain.');
|
||||||
|
@ -113,8 +114,7 @@ App::post('/v1/proxy/rules')
|
||||||
if ($validator->isValid($domain->get())) {
|
if ($validator->isValid($domain->get())) {
|
||||||
$status = 'verifying';
|
$status = 'verifying';
|
||||||
|
|
||||||
$event = new Certificate();
|
$queueForCertificates
|
||||||
$event
|
|
||||||
->setDomain(new Document([
|
->setDomain(new Document([
|
||||||
'domain' => $rule->getAttribute('domain')
|
'domain' => $rule->getAttribute('domain')
|
||||||
]))
|
]))
|
||||||
|
@ -125,7 +125,7 @@ App::post('/v1/proxy/rules')
|
||||||
$rule->setAttribute('status', $status);
|
$rule->setAttribute('status', $status);
|
||||||
$rule = $dbForConsole->createDocument('rules', $rule);
|
$rule = $dbForConsole->createDocument('rules', $rule);
|
||||||
|
|
||||||
$events->setParam('ruleId', $rule->getId());
|
$queueForEvents->setParam('ruleId', $rule->getId());
|
||||||
|
|
||||||
$rule->setAttribute('logs', '');
|
$rule->setAttribute('logs', '');
|
||||||
|
|
||||||
|
@ -235,9 +235,9 @@ App::delete('/v1/proxy/rules/:ruleId')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->inject('project')
|
->inject('project')
|
||||||
->inject('dbForConsole')
|
->inject('dbForConsole')
|
||||||
->inject('deletes')
|
->inject('queueForDeletes')
|
||||||
->inject('events')
|
->inject('queueForEvents')
|
||||||
->action(function (string $ruleId, Response $response, Document $project, Database $dbForConsole, Delete $deletes, Event $events) {
|
->action(function (string $ruleId, Response $response, Document $project, Database $dbForConsole, Delete $queueForDeletes, Event $queueForEvents) {
|
||||||
$rule = $dbForConsole->getDocument('rules', $ruleId);
|
$rule = $dbForConsole->getDocument('rules', $ruleId);
|
||||||
|
|
||||||
if ($rule->isEmpty() || $rule->getAttribute('projectInternalId') !== $project->getInternalId()) {
|
if ($rule->isEmpty() || $rule->getAttribute('projectInternalId') !== $project->getInternalId()) {
|
||||||
|
@ -246,11 +246,11 @@ App::delete('/v1/proxy/rules/:ruleId')
|
||||||
|
|
||||||
$dbForConsole->deleteDocument('rules', $rule->getId());
|
$dbForConsole->deleteDocument('rules', $rule->getId());
|
||||||
|
|
||||||
$deletes
|
$queueForDeletes
|
||||||
->setType(DELETE_TYPE_DOCUMENT)
|
->setType(DELETE_TYPE_DOCUMENT)
|
||||||
->setDocument($rule);
|
->setDocument($rule);
|
||||||
|
|
||||||
$events->setParam('ruleId', $rule->getId());
|
$queueForEvents->setParam('ruleId', $rule->getId());
|
||||||
|
|
||||||
$response->noContent();
|
$response->noContent();
|
||||||
});
|
});
|
||||||
|
@ -270,10 +270,11 @@ App::patch('/v1/proxy/rules/:ruleId/verification')
|
||||||
->label('sdk.response.model', Response::MODEL_PROXY_RULE)
|
->label('sdk.response.model', Response::MODEL_PROXY_RULE)
|
||||||
->param('ruleId', '', new UID(), 'Rule ID.')
|
->param('ruleId', '', new UID(), 'Rule ID.')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->inject('events')
|
->inject('queueForCertificates')
|
||||||
|
->inject('queueForEvents')
|
||||||
->inject('project')
|
->inject('project')
|
||||||
->inject('dbForConsole')
|
->inject('dbForConsole')
|
||||||
->action(function (string $ruleId, Response $response, Event $events, Document $project, Database $dbForConsole) {
|
->action(function (string $ruleId, Response $response, Certificate $queueForCertificates, Event $queueForEvents, Document $project, Database $dbForConsole) {
|
||||||
$rule = $dbForConsole->getDocument('rules', $ruleId);
|
$rule = $dbForConsole->getDocument('rules', $ruleId);
|
||||||
|
|
||||||
if ($rule->isEmpty() || $rule->getAttribute('projectInternalId') !== $project->getInternalId()) {
|
if ($rule->isEmpty() || $rule->getAttribute('projectInternalId') !== $project->getInternalId()) {
|
||||||
|
@ -300,14 +301,13 @@ App::patch('/v1/proxy/rules/:ruleId/verification')
|
||||||
$dbForConsole->updateDocument('rules', $rule->getId(), $rule->setAttribute('status', 'verifying'));
|
$dbForConsole->updateDocument('rules', $rule->getId(), $rule->setAttribute('status', 'verifying'));
|
||||||
|
|
||||||
// Issue a TLS certificate when domain is verified
|
// Issue a TLS certificate when domain is verified
|
||||||
$event = new Certificate();
|
$queueForCertificates
|
||||||
$event
|
|
||||||
->setDomain(new Document([
|
->setDomain(new Document([
|
||||||
'domain' => $rule->getAttribute('domain')
|
'domain' => $rule->getAttribute('domain')
|
||||||
]))
|
]))
|
||||||
->trigger();
|
->trigger();
|
||||||
|
|
||||||
$events->setParam('ruleId', $rule->getId());
|
$queueForEvents->setParam('ruleId', $rule->getId());
|
||||||
|
|
||||||
$certificate = $dbForConsole->getDocument('certificates', $rule->getAttribute('certificateId', ''));
|
$certificate = $dbForConsole->getDocument('certificates', $rule->getAttribute('certificateId', ''));
|
||||||
$rule->setAttribute('logs', $certificate->getAttribute('logs', ''));
|
$rule->setAttribute('logs', $certificate->getAttribute('logs', ''));
|
||||||
|
|
Loading…
Reference in a new issue