Restore platform fallback and null-template round-trip in BuildMessage

- toArray() falls back to Config::getParam('platform') when the
  in-memory platform is empty, matching the old Build event behavior so
  workers always receive a populated platform array.
- toArray() emits null for an absent template instead of an empty
  array, and fromArray() treats empty/null/missing template as null so
  the round-trip preserves the no-template case.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
loks0n
2026-05-07 13:56:46 +01:00
co-authored by Claude Opus 4.7
parent 7d0843cc7f
commit f947fde701
+6 -3
View File
@@ -2,6 +2,7 @@
namespace Appwrite\Event\Message;
use Utopia\Config\Config;
use Utopia\Database\Document;
final class Build extends Base
@@ -18,13 +19,15 @@ final class Build extends Base
public function toArray(): array
{
$platform = !empty($this->platform) ? $this->platform : Config::getParam('platform', []);
return [
'project' => $this->project->getArrayCopy(),
'resource' => $this->resource->getArrayCopy(),
'deployment' => $this->deployment->getArrayCopy(),
'type' => $this->type,
'template' => $this->template?->getArrayCopy() ?? [],
'platform' => $this->platform,
'template' => $this->template?->getArrayCopy(),
'platform' => $platform,
];
}
@@ -35,7 +38,7 @@ final class Build extends Base
resource: new Document($data['resource'] ?? []),
deployment: new Document($data['deployment'] ?? []),
type: $data['type'] ?? '',
template: isset($data['template']) ? new Document($data['template']) : null,
template: !empty($data['template']) ? new Document($data['template']) : null,
platform: $data['platform'] ?? [],
);
}