Commit 0f8a2a4a authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

Turn acceptsReservation into a ReserveAction

According to [1] it can be the URL to a reservation page.
Turn it into a ReserveAction to have a single code path for this on the consumer side.

[1] https://schema.org/acceptsReservations

Differential Revision: https://phabricator.kde.org/D27599
parent 81989879
......@@ -162,6 +162,22 @@ static void filterBusTrip(QJsonObject &trip)
renameProperty(trip, "busCompany", "provider");
}
static void filterFoodEstablishment(QJsonObject &restaurant)
{
// This can be a bool, "Yes"/"No", or a URL.
auto reservationsValue = restaurant.value(QLatin1String("acceptsReservations"));
if (reservationsValue.isString()) {
const QString reservations = reservationsValue.toString();
if (reservations == QLatin1String("Yes")) {
restaurant.insert(QLatin1String("acceptsReservations"), true);
} else if (reservations == QLatin1String("No")) {
restaurant.insert(QLatin1String("acceptsReservations"), false);
} else {
migrateToAction(restaurant, "acceptsReservations", "ReserveAction", true);
}
}
}
static void filterActionTarget(QJsonObject &action)
{
QJsonArray targets;
......@@ -242,6 +258,7 @@ static const struct {
} type_filters[] = {
{ "BusTrip", filterBusTrip },
{ "Flight", filterFlight },
{ "FoodEstablishment", filterFoodEstablishment },
{ "LodgingReservation", filterLodgingReservation },
{ "TrainTrip", filterTrainTrip },
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment