Commit ad076973 authored by Volker Krause's avatar Volker Krause
Browse files

Handle RegioJet iCal attachments

parent 546b95dd
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Michael Angstadt//biweekly 0.6.0//EN
METHOD:REQUEST
BEGIN:VEVENT
DTSTAMP:20190101T123456Z
DTSTART;TZID=Europe/Vienna:20190102T143900
DTEND;TZID=Europe/Prague:20190102T160500
CREATED:20190101T123456Z
ATTENDEE;CN=Dr Konqui:mailto:null@kde.org
SUMMARY:#9876543210: From Vienna\, Hbf\, to Brno\, dolní nádraží\, seat: 1/
42
DESCRIPTION:Arrival/Departure|Station/Transfer|Platf.|Connection|Coach/Seat
s\nDep:14:39|Vienna\, Hbf|Vienna → Prague (RJ\, RJ 1234)|1/42\nArr:16:05|B
rno\, dolní nádraží\n
LOCATION:48.18522644042969\, 16.376480102539062
UID:-1234567890@regiojet.cz
SEQUENCE:1
END:VEVENT
END:VCALENDAR
[
{
"@context": "http://schema.org",
"@type": "TrainReservation",
"reservationFor": {
"@type": "TrainTrip",
"arrivalStation": {
"@type": "TrainStation",
"name": "Brno, dolní nádraží"
},
"arrivalTime": {
"@type": "QDateTime",
"@value": "2019-01-02T16:05:00+01:00",
"timezone": "Europe/Prague"
},
"departureDay": "2019-01-02",
"departureStation": {
"@type": "TrainStation",
"geo": {
"@type": "GeoCoordinates",
"latitude": 48.18522644042969,
"longitude": 16.376480102539062
},
"name": "Vienna, Hbf"
},
"departureTime": {
"@type": "QDateTime",
"@value": "2019-01-02T14:39:00+01:00",
"timezone": "Europe/Vienna"
},
"trainNumber": "RJ, RJ 1234"
},
"reservationNumber": "9876543210",
"reservedTicket": {
"@type": "Ticket",
"ticketedSeat": {
"@type": "Seat",
"seatNumber": "1/42"
}
},
"underName": {
"@type": "Person",
"name": "Dr Konqui"
}
}
]
......@@ -215,3 +215,25 @@ function main(text) {
return reservations;
}
function parseEvent(event)
{
var res = JsonLd.newTrainReservation();
res.reservationFor.departureTime = JsonLd.readQDateTime(event, "dtStart");
res.reservationFor.arrivalTime = JsonLd.readQDateTime(event, "dtEnd");
res.underName.name = event.attendees[0].name;
var summary = event.summary.match(/#(.+?): From (.+?), to (.+?), seat: (.+)/);
res.reservationNumber = summary[1];
res.reservationFor.departureStation.name = summary[2];
res.reservationFor.arrivalStation.name = summary[3];
res.reservedTicket.ticketedSeat.seatNumber =summary[4];
var desc = event.description.match(/\((.+?)\)/);
res.reservationFor.trainNumber = desc[1];
var loc = event.location.match(/(.+?), (.+)/);
res.reservationFor.departureStation.geo.latitude = 1.0 * loc[1];
res.reservationFor.departureStation.geo.longitude = 1.0 * loc[2];
return res;
}
{
"filter": [
{ "header": "From", "match": "express@studentagency.cz" },
{ "header": "From", "match": "info@regiojet.cz" }
],
"script": "regiojet.js"
}
[
{
"type": "text",
"filter": [
{ "header": "From", "match": "express@studentagency.cz" },
{ "header": "From", "match": "info@regiojet.cz" }
],
"script": "regiojet.js",
"function": "main"
},
{
"type": "ical",
"filter": [ { "property": "uid", "match": "@regiojet.cz", "type": "ICal" } ],
"script": "regiojet.js",
"function": "parseEvent"
}
]
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