mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
chore: optimise webhooks payload
This commit is contained in:
parent
153431246d
commit
53d8e2b0c3
2 changed files with 14 additions and 1 deletions
|
|
@ -14,4 +14,16 @@ class Webhook extends Event
|
||||||
->setQueue(Event::WEBHOOK_QUEUE_NAME)
|
->setQueue(Event::WEBHOOK_QUEUE_NAME)
|
||||||
->setClass(Event::WEBHOOK_CLASS_NAME);
|
->setClass(Event::WEBHOOK_CLASS_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function trigger(): string|bool
|
||||||
|
{
|
||||||
|
/** Filter out context and trim project to keep the payload small */
|
||||||
|
$this->context = [];
|
||||||
|
$this->project = [
|
||||||
|
'$id' => $this->project->getId(),
|
||||||
|
'$internalId' => $this->project->getAttribute('internalId'),
|
||||||
|
];
|
||||||
|
|
||||||
|
return parent::trigger();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,9 +56,10 @@ class Webhooks extends Action
|
||||||
|
|
||||||
$events = $payload['events'];
|
$events = $payload['events'];
|
||||||
$webhookPayload = json_encode($payload['payload']);
|
$webhookPayload = json_encode($payload['payload']);
|
||||||
$project = new Document($payload['project']);
|
|
||||||
$user = new Document($payload['user'] ?? []);
|
$user = new Document($payload['user'] ?? []);
|
||||||
|
|
||||||
|
$project = new Document($payload['project']);
|
||||||
|
$project = $dbForPlatform->getDocument('projects', $project->getId());
|
||||||
$log->addTag('projectId', $project->getId());
|
$log->addTag('projectId', $project->getId());
|
||||||
|
|
||||||
foreach ($project->getAttribute('webhooks', []) as $webhook) {
|
foreach ($project->getAttribute('webhooks', []) as $webhook) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue