Fix id null schedule bug
This commit is contained in:
parent
7c184498bb
commit
fedac9592b
|
@ -200,6 +200,7 @@ App::post('/v1/functions')
|
||||||
'events' => $events,
|
'events' => $events,
|
||||||
'schedule' => $schedule,
|
'schedule' => $schedule,
|
||||||
'scheduleInternalId' => '',
|
'scheduleInternalId' => '',
|
||||||
|
'scheduleId' => '',
|
||||||
'timeout' => $timeout,
|
'timeout' => $timeout,
|
||||||
'entrypoint' => $entrypoint,
|
'entrypoint' => $entrypoint,
|
||||||
'commands' => $commands,
|
'commands' => $commands,
|
||||||
|
@ -215,6 +216,22 @@ App::post('/v1/functions')
|
||||||
'providerSilentMode' => $providerSilentMode,
|
'providerSilentMode' => $providerSilentMode,
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
$schedule = Authorization::skip(
|
||||||
|
fn () => $dbForConsole->createDocument('schedules', new Document([
|
||||||
|
'region' => App::getEnv('_APP_REGION', 'default'), // Todo replace with projects region
|
||||||
|
'resourceType' => 'function',
|
||||||
|
'resourceId' => $function->getId(),
|
||||||
|
'resourceInternalId' => $function->getInternalId(),
|
||||||
|
'resourceUpdatedAt' => DateTime::now(),
|
||||||
|
'projectId' => $project->getId(),
|
||||||
|
'schedule' => $function->getAttribute('schedule'),
|
||||||
|
'active' => false,
|
||||||
|
]))
|
||||||
|
);
|
||||||
|
|
||||||
|
$function->setAttribute('scheduleId', $schedule->getId());
|
||||||
|
$function->setAttribute('scheduleInternalId', $schedule->getInternalId());
|
||||||
|
|
||||||
// Git connect logic
|
// Git connect logic
|
||||||
if (!empty($providerRepositoryId)) {
|
if (!empty($providerRepositoryId)) {
|
||||||
$repository = $dbForConsole->createDocument('repositories', new Document([
|
$repository = $dbForConsole->createDocument('repositories', new Document([
|
||||||
|
@ -235,23 +252,11 @@ App::post('/v1/functions')
|
||||||
'providerPullRequestIds' => []
|
'providerPullRequestIds' => []
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$function = $dbForProject->updateDocument('functions', $function->getId(), $function
|
$function->setAttribute('repositoryId', $repository->getId());
|
||||||
->setAttribute('repositoryId', $repository->getId())
|
$function->setAttribute('repositoryInternalId', $repository->getInternalId());
|
||||||
->setAttribute('repositoryInternalId', $repository->getInternalId()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$schedule = Authorization::skip(
|
$function = $dbForProject->updateDocument('functions', $function->getId(), $function);
|
||||||
fn () => $dbForConsole->createDocument('schedules', new Document([
|
|
||||||
'region' => App::getEnv('_APP_REGION', 'default'), // Todo replace with projects region
|
|
||||||
'resourceType' => 'function',
|
|
||||||
'resourceId' => $function->getId(),
|
|
||||||
'resourceInternalId' => $function->getInternalId(),
|
|
||||||
'resourceUpdatedAt' => DateTime::now(),
|
|
||||||
'projectId' => $project->getId(),
|
|
||||||
'schedule' => $function->getAttribute('schedule'),
|
|
||||||
'active' => false,
|
|
||||||
]))
|
|
||||||
);
|
|
||||||
|
|
||||||
// Redeploy vcs logic
|
// Redeploy vcs logic
|
||||||
if (!empty($providerRepositoryId)) {
|
if (!empty($providerRepositoryId)) {
|
||||||
|
@ -320,10 +325,6 @@ App::post('/v1/functions')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$function->setAttribute('scheduleId', $schedule->getId());
|
|
||||||
$function->setAttribute('scheduleInternalId', $schedule->getInternalId());
|
|
||||||
$dbForProject->updateDocument('functions', $function->getId(), $function);
|
|
||||||
|
|
||||||
$eventsInstance->setParam('functionId', $function->getId());
|
$eventsInstance->setParam('functionId', $function->getId());
|
||||||
|
|
||||||
$response
|
$response
|
||||||
|
|
|
@ -41,6 +41,11 @@ App::post('/v1/proxy/rules')
|
||||||
->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, Event $events, Database $dbForConsole, Database $dbForProject) {
|
||||||
|
$mainDomain = App::getEnv('_APP_DOMAIN', '');
|
||||||
|
if ($domain === $mainDomain || $domain === 'localhost' || $domain === APP_HOSTNAME_INTERNAL) {
|
||||||
|
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'This domain name is not allowed for security reasons.');
|
||||||
|
}
|
||||||
|
|
||||||
$document = $dbForConsole->findOne('rules', [
|
$document = $dbForConsole->findOne('rules', [
|
||||||
Query::equal('domain', [$domain]),
|
Query::equal('domain', [$domain]),
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in a new issue