chore: optimise webhooks payload

This commit is contained in:
Christy Jacob
2024-12-19 16:43:05 +05:30
parent 153431246d
commit 53d8e2b0c3
2 changed files with 14 additions and 1 deletions
+12
View File
@@ -14,4 +14,16 @@ class Webhook extends Event
->setQueue(Event::WEBHOOK_QUEUE_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();
}
}
+2 -1
View File
@@ -56,9 +56,10 @@ class Webhooks extends Action
$events = $payload['events'];
$webhookPayload = json_encode($payload['payload']);
$project = new Document($payload['project']);
$user = new Document($payload['user'] ?? []);
$project = new Document($payload['project']);
$project = $dbForPlatform->getDocument('projects', $project->getId());
$log->addTag('projectId', $project->getId());
foreach ($project->getAttribute('webhooks', []) as $webhook) {