mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
get proper projectDB when passing to adapter in webhook
This commit is contained in:
@@ -143,13 +143,19 @@ class Create extends Base
|
||||
return new AppwriteException(ExtendException::RESOURCE_ALREADY_EXISTS);
|
||||
}
|
||||
|
||||
$payments = (array) $project->getAttribute('payments', []);
|
||||
$providerConfigs = (array) ($payments['providers'] ?? []);
|
||||
if (empty($providerConfigs)) {
|
||||
$response->setStatusCode(Response::STATUS_CODE_BAD_REQUEST);
|
||||
$response->json(['message' => 'At least one payment provider must be configured before creating plans']);
|
||||
return;
|
||||
}
|
||||
|
||||
$created = $dbForProject->createDocument('payments_plans', $document);
|
||||
|
||||
$queueForEvents->setParam('planId', $planId);
|
||||
|
||||
// Provision on configured providers
|
||||
$payments = (array) $project->getAttribute('payments', []);
|
||||
$providerConfigs = (array) ($payments['providers'] ?? []);
|
||||
$providersMeta = [];
|
||||
foreach ($providerConfigs as $providerId => $providerConfig) {
|
||||
$state = new ProviderState((string) $providerId, (array) $providerConfig, (array) ($providerConfig['state'] ?? []));
|
||||
|
||||
@@ -134,6 +134,17 @@ class Get extends Base
|
||||
}
|
||||
}
|
||||
|
||||
if ($actorId !== '') {
|
||||
$collection = $actorType === 'team' ? 'teams' : 'users';
|
||||
$actor = $dbForProject->getDocument($collection, $actorId);
|
||||
|
||||
if ($actor->isEmpty()) {
|
||||
$response->setStatusCode(Response::STATUS_CODE_NOT_FOUND);
|
||||
$response->json(['message' => 'Actor not found']);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$queries = [
|
||||
Query::equal('actorType', [$actorType]),
|
||||
Query::equal('actorId', [$actorId]),
|
||||
|
||||
@@ -9,6 +9,7 @@ use Appwrite\SDK\Method;
|
||||
use Appwrite\Utopia\Response;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\Platform\Scope\HTTP;
|
||||
use Utopia\Swoole\Request;
|
||||
@@ -48,14 +49,32 @@ class Create extends Base
|
||||
->inject('request')
|
||||
->inject('registryPayments')
|
||||
->inject('dbForPlatform')
|
||||
->inject('dbForProject')
|
||||
->inject('getProjectDB')
|
||||
->inject('queueForEvents')
|
||||
->callback($this->action(...));
|
||||
}
|
||||
|
||||
public function action(string $providerId, string $projectId, Response $response, Request $request, Registry $registryPayments, \Utopia\Database\Database $dbForPlatform, \Utopia\Database\Database $dbForProject, Event $queueForEvents)
|
||||
public function action(
|
||||
string $providerId,
|
||||
string $projectId,
|
||||
Response $response,
|
||||
Request $request,
|
||||
Registry $registryPayments,
|
||||
Database $dbForPlatform,
|
||||
callable $getProjectDB,
|
||||
Event $queueForEvents
|
||||
)
|
||||
{
|
||||
$project = Authorization::skip(fn () => $dbForPlatform->getDocument('projects', $projectId));
|
||||
|
||||
if ($project === null || $project->isEmpty()) {
|
||||
$response->setStatusCode(Response::STATUS_CODE_NOT_FOUND);
|
||||
$response->json(['message' => 'Project not found']);
|
||||
return;
|
||||
}
|
||||
|
||||
$dbForProject = $getProjectDB($project);
|
||||
|
||||
// Feature flag: ignore if disabled
|
||||
$paymentsCfg = (array) $project->getAttribute('payments', []);
|
||||
if (isset($paymentsCfg['enabled']) && $paymentsCfg['enabled'] === false) {
|
||||
|
||||
Reference in New Issue
Block a user