mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 17:08:45 +00:00
Merge pull request #9115 from appwrite/chore-optimise-webhooks-payload
chore: optimise webhooks payload
This commit is contained in:
commit
610121d02c
2 changed files with 15 additions and 1 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Appwrite\Event;
|
||||
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Queue\Connection;
|
||||
|
||||
class Webhook extends Event
|
||||
|
|
@ -14,4 +15,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 = new Document([
|
||||
'$id' => $this->project->getId(),
|
||||
'$internalId' => $this->project->getAttribute('internalId'),
|
||||
]);
|
||||
|
||||
return parent::trigger();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue