|
|
|
@@ -19,7 +19,6 @@ use Appwrite\Utopia\Database\Validator\ProjectId;
|
|
|
|
|
use Appwrite\Utopia\Database\Validator\Queries\Projects;
|
|
|
|
|
use Appwrite\Utopia\Request;
|
|
|
|
|
use Appwrite\Utopia\Response;
|
|
|
|
|
use Cron\CronExpression;
|
|
|
|
|
use PHPMailer\PHPMailer\PHPMailer;
|
|
|
|
|
use Utopia\App;
|
|
|
|
|
use Utopia\Audit\Audit;
|
|
|
|
@@ -358,9 +357,18 @@ App::get('/v1/projects')
|
|
|
|
|
throw new Exception(Exception::GENERAL_CURSOR_NOT_FOUND, "Project '{$projectId}' for the 'cursor' value not found.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($cursorDocument->getAttribute('_deletedAt')) && $cursorDocument->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::GENERAL_CURSOR_NOT_FOUND, "Project '{$projectId}' for the 'cursor' value not found.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$cursor->setValue($cursorDocument);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$queries[] = query::or([
|
|
|
|
|
query::isNull('_deletedAt'),
|
|
|
|
|
query::lessThan('_deletedAt', DateTime::now())
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$filterQueries = Query::groupByType($queries)['filters'];
|
|
|
|
|
try {
|
|
|
|
|
$projects = $dbForPlatform->find('projects', $queries);
|
|
|
|
@@ -402,6 +410,10 @@ App::get('/v1/projects/:projectId')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$response->dynamic($project, Response::MODEL_PROJECT);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@@ -435,10 +447,9 @@ App::patch('/v1/projects/:projectId')
|
|
|
|
|
->param('legalCity', '', new Text(256), 'Project legal city. Max length: 256 chars.', true)
|
|
|
|
|
->param('legalAddress', '', new Text(256), 'Project legal address. Max length: 256 chars.', true)
|
|
|
|
|
->param('legalTaxId', '', new Text(256), 'Project legal tax ID. Max length: 256 chars.', true)
|
|
|
|
|
->param('restore', null, new Boolean(), 'Restore project from being marked for deletion', true)
|
|
|
|
|
->inject('response')
|
|
|
|
|
->inject('dbForPlatform')
|
|
|
|
|
->action(function (string $projectId, string $name, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, bool $restore, Response $response, Database $dbForPlatform) {
|
|
|
|
|
->action(function (string $projectId, string $name, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Response $response, Database $dbForPlatform) {
|
|
|
|
|
|
|
|
|
|
$project = $dbForPlatform->getDocument('projects', $projectId);
|
|
|
|
|
|
|
|
|
@@ -446,7 +457,12 @@ App::patch('/v1/projects/:projectId')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$project
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$project = $dbForPlatform->updateDocument('projects', $project->getId(), $project
|
|
|
|
|
->setAttribute('name', $name)
|
|
|
|
|
->setAttribute('description', $description)
|
|
|
|
|
->setAttribute('logo', $logo)
|
|
|
|
@@ -457,14 +473,42 @@ App::patch('/v1/projects/:projectId')
|
|
|
|
|
->setAttribute('legalCity', $legalCity)
|
|
|
|
|
->setAttribute('legalAddress', $legalAddress)
|
|
|
|
|
->setAttribute('legalTaxId', $legalTaxId)
|
|
|
|
|
->setAttribute('search', implode(' ', [$projectId, $name]))
|
|
|
|
|
;
|
|
|
|
|
->setAttribute('search', implode(' ', [$projectId, $name])));
|
|
|
|
|
|
|
|
|
|
if (!empty($restore)) {
|
|
|
|
|
$project->setAttribute('_deletedAt', null);
|
|
|
|
|
$response->dynamic($project, Response::MODEL_PROJECT);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
App::patch('/v1/projects/:projectId/restore')
|
|
|
|
|
->desc('Restore project from being a candidate for deletion')
|
|
|
|
|
->groups(['api', 'projects'])
|
|
|
|
|
->label('scope', 'projects.write')
|
|
|
|
|
->label('sdk', new Method(
|
|
|
|
|
namespace: 'projects',
|
|
|
|
|
group: 'projects',
|
|
|
|
|
name: 'restore',
|
|
|
|
|
description: '/docs/references/projects/restore.md',
|
|
|
|
|
auth: [AuthType::ADMIN],
|
|
|
|
|
responses: [
|
|
|
|
|
new SDKResponse(
|
|
|
|
|
code: Response::STATUS_CODE_OK,
|
|
|
|
|
model: Response::MODEL_PROJECT,
|
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
))
|
|
|
|
|
->param('projectId', '', new UID(), 'Project unique ID.')
|
|
|
|
|
->inject('response')
|
|
|
|
|
->inject('dbForPlatform')
|
|
|
|
|
->action(function (string $projectId, Response $response, Database $dbForPlatform) {
|
|
|
|
|
|
|
|
|
|
$project = $dbForPlatform->getDocument('projects', $projectId);
|
|
|
|
|
|
|
|
|
|
if ($project->isEmpty()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$project = $dbForPlatform->updateDocument('projects', $project->getId(), $project);
|
|
|
|
|
$project = $dbForPlatform->updateDocument('projects', $project->getId(),
|
|
|
|
|
$project->setAttribute('_deletedAt', null)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$response->dynamic($project, Response::MODEL_PROJECT);
|
|
|
|
|
});
|
|
|
|
@@ -499,6 +543,10 @@ App::patch('/v1/projects/:projectId/team')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($team->isEmpty()) {
|
|
|
|
|
throw new Exception(Exception::TEAM_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
@@ -574,6 +622,10 @@ App::patch('/v1/projects/:projectId/service')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$services = $project->getAttribute('services', []);
|
|
|
|
|
$services[$service] = $status;
|
|
|
|
|
|
|
|
|
@@ -611,6 +663,10 @@ App::patch('/v1/projects/:projectId/service/all')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$allServices = array_keys(array_filter(Config::getParam('services'), fn ($element) => $element['optional']));
|
|
|
|
|
|
|
|
|
|
$services = [];
|
|
|
|
@@ -653,6 +709,10 @@ App::patch('/v1/projects/:projectId/api')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$apis = $project->getAttribute('apis', []);
|
|
|
|
|
$apis[$api] = $status;
|
|
|
|
|
|
|
|
|
@@ -690,6 +750,10 @@ App::patch('/v1/projects/:projectId/api/all')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$allApis = array_keys(Config::getParam('apis'));
|
|
|
|
|
|
|
|
|
|
$apis = [];
|
|
|
|
@@ -734,6 +798,10 @@ App::patch('/v1/projects/:projectId/oauth2')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$providers = $project->getAttribute('oAuthProviders', []);
|
|
|
|
|
|
|
|
|
|
if ($appId !== null) {
|
|
|
|
@@ -782,6 +850,10 @@ App::patch('/v1/projects/:projectId/auth/session-alerts')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$auths = $project->getAttribute('auths', []);
|
|
|
|
|
$auths['sessionAlerts'] = $alerts;
|
|
|
|
|
|
|
|
|
@@ -821,6 +893,10 @@ App::patch('/v1/projects/:projectId/auth/memberships-privacy')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$auths = $project->getAttribute('auths', []);
|
|
|
|
|
|
|
|
|
|
$auths['membershipsUserName'] = $userName;
|
|
|
|
@@ -862,6 +938,10 @@ App::patch('/v1/projects/:projectId/auth/limit')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$auths = $project->getAttribute('auths', []);
|
|
|
|
|
$auths['limit'] = $limit;
|
|
|
|
|
|
|
|
|
@@ -900,6 +980,10 @@ App::patch('/v1/projects/:projectId/auth/duration')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$auths = $project->getAttribute('auths', []);
|
|
|
|
|
$auths['duration'] = $duration;
|
|
|
|
|
|
|
|
|
@@ -942,6 +1026,10 @@ App::patch('/v1/projects/:projectId/auth/:method')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$auths = $project->getAttribute('auths', []);
|
|
|
|
|
$auths[$authKey] = $status;
|
|
|
|
|
|
|
|
|
@@ -979,6 +1067,10 @@ App::patch('/v1/projects/:projectId/auth/password-history')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$auths = $project->getAttribute('auths', []);
|
|
|
|
|
$auths['passwordHistory'] = $limit;
|
|
|
|
|
|
|
|
|
@@ -1017,6 +1109,10 @@ App::patch('/v1/projects/:projectId/auth/password-dictionary')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$auths = $project->getAttribute('auths', []);
|
|
|
|
|
$auths['passwordDictionary'] = $enabled;
|
|
|
|
|
|
|
|
|
@@ -1055,6 +1151,10 @@ App::patch('/v1/projects/:projectId/auth/personal-data')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$auths = $project->getAttribute('auths', []);
|
|
|
|
|
$auths['personalDataCheck'] = $enabled;
|
|
|
|
|
|
|
|
|
@@ -1093,6 +1193,10 @@ App::patch('/v1/projects/:projectId/auth/max-sessions')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$auths = $project->getAttribute('auths', []);
|
|
|
|
|
$auths['maxSessions'] = $limit;
|
|
|
|
|
|
|
|
|
@@ -1139,6 +1243,10 @@ App::patch('/v1/projects/:projectId/auth/mock-numbers')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$auths = $project->getAttribute('auths', []);
|
|
|
|
|
|
|
|
|
|
$auths['mockNumbers'] = $numbers;
|
|
|
|
@@ -1170,16 +1278,19 @@ App::delete('/v1/projects/:projectId')
|
|
|
|
|
))
|
|
|
|
|
->param('projectId', '', new UID(), 'Project unique ID.')
|
|
|
|
|
->inject('response')
|
|
|
|
|
->inject('user')
|
|
|
|
|
->inject('dbForPlatform')
|
|
|
|
|
->inject('queueForDeletes')
|
|
|
|
|
->action(function (string $projectId, Response $response, Document $user, Database $dbForPlatform, Delete $queueForDeletes) {
|
|
|
|
|
->action(function (string $projectId, Response $response, Database $dbForPlatform) {
|
|
|
|
|
$project = $dbForPlatform->getDocument('projects', $projectId);
|
|
|
|
|
|
|
|
|
|
if ($project->isEmpty()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$expiration = System::getEnv('_APP_PROJECTS_DELETE_EXPIRATION','3600');
|
|
|
|
|
$deletedAt = DateTime::formatTz(DateTime::addSeconds(new \DateTime(), (int)$expiration));
|
|
|
|
|
$dbForPlatform->updateDocument('projects', $project->getId(),
|
|
|
|
@@ -1226,6 +1337,10 @@ App::post('/v1/projects/:projectId/webhooks')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$security = (bool) filter_var($security, FILTER_VALIDATE_BOOLEAN);
|
|
|
|
|
|
|
|
|
|
$webhook = new Document([
|
|
|
|
@@ -1284,6 +1399,10 @@ App::get('/v1/projects/:projectId/webhooks')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$webhooks = $dbForPlatform->find('webhooks', [
|
|
|
|
|
Query::equal('projectInternalId', [$project->getInternalId()]),
|
|
|
|
|
Query::limit(5000),
|
|
|
|
@@ -1324,6 +1443,10 @@ App::get('/v1/projects/:projectId/webhooks/:webhookId')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$webhook = $dbForPlatform->findOne('webhooks', [
|
|
|
|
|
Query::equal('$id', [$webhookId]),
|
|
|
|
|
Query::equal('projectInternalId', [$project->getInternalId()]),
|
|
|
|
@@ -1372,6 +1495,10 @@ App::put('/v1/projects/:projectId/webhooks/:webhookId')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$security = ($security === '1' || $security === 'true' || $security === 1 || $security === true);
|
|
|
|
|
|
|
|
|
|
$webhook = $dbForPlatform->findOne('webhooks', [
|
|
|
|
@@ -1431,6 +1558,10 @@ App::patch('/v1/projects/:projectId/webhooks/:webhookId/signature')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$webhook = $dbForPlatform->findOne('webhooks', [
|
|
|
|
|
Query::equal('$id', [$webhookId]),
|
|
|
|
|
Query::equal('projectInternalId', [$project->getInternalId()]),
|
|
|
|
@@ -1478,6 +1609,10 @@ App::delete('/v1/projects/:projectId/webhooks/:webhookId')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$webhook = $dbForPlatform->findOne('webhooks', [
|
|
|
|
|
Query::equal('$id', [$webhookId]),
|
|
|
|
|
Query::equal('projectInternalId', [$project->getInternalId()]),
|
|
|
|
@@ -1527,6 +1662,10 @@ App::post('/v1/projects/:projectId/keys')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$key = new Document([
|
|
|
|
|
'$id' => ID::unique(),
|
|
|
|
|
'$permissions' => [
|
|
|
|
@@ -1581,6 +1720,10 @@ App::get('/v1/projects/:projectId/keys')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$keys = $dbForPlatform->find('keys', [
|
|
|
|
|
Query::equal('projectInternalId', [$project->getInternalId()]),
|
|
|
|
|
Query::limit(5000),
|
|
|
|
@@ -1621,6 +1764,10 @@ App::get('/v1/projects/:projectId/keys/:keyId')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$key = $dbForPlatform->findOne('keys', [
|
|
|
|
|
Query::equal('$id', [$keyId]),
|
|
|
|
|
Query::equal('projectInternalId', [$project->getInternalId()]),
|
|
|
|
@@ -1665,6 +1812,10 @@ App::put('/v1/projects/:projectId/keys/:keyId')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$key = $dbForPlatform->findOne('keys', [
|
|
|
|
|
Query::equal('$id', [$keyId]),
|
|
|
|
|
Query::equal('projectInternalId', [$project->getInternalId()]),
|
|
|
|
@@ -1716,6 +1867,10 @@ App::delete('/v1/projects/:projectId/keys/:keyId')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$key = $dbForPlatform->findOne('keys', [
|
|
|
|
|
Query::equal('$id', [$keyId]),
|
|
|
|
|
Query::equal('projectInternalId', [$project->getInternalId()]),
|
|
|
|
@@ -1764,6 +1919,10 @@ App::post('/v1/projects/:projectId/jwts')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$jwt = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', $duration, 0);
|
|
|
|
|
|
|
|
|
|
$response
|
|
|
|
@@ -1810,6 +1969,10 @@ App::post('/v1/projects/:projectId/platforms')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$platform = new Document([
|
|
|
|
|
'$id' => ID::unique(),
|
|
|
|
|
'$permissions' => [
|
|
|
|
@@ -1903,6 +2066,10 @@ App::get('/v1/projects/:projectId/platforms/:platformId')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$platform = $dbForPlatform->findOne('platforms', [
|
|
|
|
|
Query::equal('$id', [$platformId]),
|
|
|
|
|
Query::equal('projectInternalId', [$project->getInternalId()]),
|
|
|
|
@@ -1947,6 +2114,10 @@ App::put('/v1/projects/:projectId/platforms/:platformId')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$platform = $dbForPlatform->findOne('platforms', [
|
|
|
|
|
Query::equal('$id', [$platformId]),
|
|
|
|
|
Query::equal('projectInternalId', [$project->getInternalId()]),
|
|
|
|
@@ -2001,6 +2172,10 @@ App::delete('/v1/projects/:projectId/platforms/:platformId')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$platform = $dbForPlatform->findOne('platforms', [
|
|
|
|
|
Query::equal('$id', [$platformId]),
|
|
|
|
|
Query::equal('projectInternalId', [$project->getInternalId()]),
|
|
|
|
@@ -2056,6 +2231,10 @@ App::patch('/v1/projects/:projectId/smtp')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ensure required params for when enabling SMTP
|
|
|
|
|
if ($enabled) {
|
|
|
|
|
if (empty($senderName)) {
|
|
|
|
@@ -2154,6 +2333,10 @@ App::post('/v1/projects/:projectId/smtp/tests')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$replyToEmail = !empty($replyTo) ? $replyTo : $senderEmail;
|
|
|
|
|
|
|
|
|
|
$subject = 'Custom SMTP email sample';
|
|
|
|
@@ -2223,6 +2406,10 @@ App::get('/v1/projects/:projectId/templates/sms/:type/:locale')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$templates = $project->getAttribute('templates', []);
|
|
|
|
|
$template = $templates['sms.' . $type . '-' . $locale] ?? null;
|
|
|
|
|
|
|
|
|
@@ -2269,6 +2456,10 @@ App::get('/v1/projects/:projectId/templates/email/:type/:locale')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$templates = $project->getAttribute('templates', []);
|
|
|
|
|
$template = $templates['email.' . $type . '-' . $locale] ?? null;
|
|
|
|
|
|
|
|
|
@@ -2331,6 +2522,10 @@ App::patch('/v1/projects/:projectId/templates/sms/:type/:locale')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$templates = $project->getAttribute('templates', []);
|
|
|
|
|
$templates['sms.' . $type . '-' . $locale] = [
|
|
|
|
|
'message' => $message
|
|
|
|
@@ -2380,6 +2575,10 @@ App::patch('/v1/projects/:projectId/templates/email/:type/:locale')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$templates = $project->getAttribute('templates', []);
|
|
|
|
|
$templates['email.' . $type . '-' . $locale] = [
|
|
|
|
|
'senderName' => $senderName,
|
|
|
|
@@ -2435,6 +2634,10 @@ App::delete('/v1/projects/:projectId/templates/sms/:type/:locale')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$templates = $project->getAttribute('templates', []);
|
|
|
|
|
$template = $templates['sms.' . $type . '-' . $locale] ?? null;
|
|
|
|
|
|
|
|
|
@@ -2484,6 +2687,10 @@ App::delete('/v1/projects/:projectId/templates/email/:type/:locale')
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($project->getAttribute('_deletedAt')) && $project->getAttribute('_deletedAt') < DateTime::now()) {
|
|
|
|
|
throw new Exception(Exception::PROJECT_NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$templates = $project->getAttribute('templates', []);
|
|
|
|
|
$template = $templates['email.' . $type . '-' . $locale] ?? null;
|
|
|
|
|
|
|
|
|
|