feat: trips-only chatbot MCP endpoint without editorial website text

This commit is contained in:
fromme committed 2026-10-12 14:43:46 +02:00
1 parent 9f805aaec7
commit 26d4140c18
7 files changed
+110 -11

No files matched your search

+8 -6
View File
@@ -126,9 +126,12 @@ class TripCatalog
* booking documents (SSLMP061226 is product SSLMP on 06.12.26); it narrows the trip to
* that date, shown even when it has already started.
*
* Without $editorial the product and hotel page texts are left out, and only what is
* structured remains: names, links, hotel facts and everything from the booking system.
*
* @return array<string, mixed>|null
*/
public function get(string $code, ?string $hotelCode = null): ?array
public function get(string $code, ?string $hotelCode = null, bool $editorial = true): ?array
{
$catalog = $this->load();
$code = (new DateCodeUtility())->sanitize(trim($code));
@@ -175,8 +178,8 @@ class TripCatalog
static fn (ContentDocument $other): array => ['site' => $other->getSite(), 'url' => $other->getUrl()],
array_filter(array_slice($products, 1), static fn (ContentDocument $other): bool => null !== $other->getUrl()),
)),
'description' => $this->truncate($product->getBodyMd(), self::BODY_LIMIT),
'hotels' => $this->hotelDetails($catalog, $hotelCodes, $product),
] + ($editorial ? ['description' => $this->truncate($product->getBodyMd(), self::BODY_LIMIT)] : []) + [
'hotels' => $this->hotelDetails($catalog, $hotelCodes, $product, $editorial),
'dates' => $this->dates($catalog, $rows),
'dataAsOf' => $this->dataAsOf($catalog['export']),
];
@@ -495,7 +498,7 @@ class TripCatalog
*
* @return list<array<string, mixed>>
*/
private function hotelDetails(array $catalog, array $hotelCodes, ContentDocument $product): array
private function hotelDetails(array $catalog, array $hotelCodes, ContentDocument $product, bool $editorial): array
{
$hotels = [];
@@ -521,8 +524,7 @@ class TripCatalog
'name' => $hotel->getTitle(),
'url' => $hotel->getUrl(),
'facts' => is_array($hotel->getData()['facts'] ?? null) ? array_filter($hotel->getData()['facts'], static fn (mixed $value): bool => null !== $value && '' !== $value) : [],
'description' => $this->truncate($hotel->getBodyMd(), self::HOTEL_BODY_LIMIT),
], $hotels));
] + ($editorial ? ['description' => $this->truncate($hotel->getBodyMd(), self::HOTEL_BODY_LIMIT)] : []), $hotels));
}
/**