Commit 5a69849a authored by Volker Krause's avatar Volker Krause
Browse files

Extract QR code ticket tokens from eki-net mails as well

Easily doable now that we have proper multipart/related handling.
parent 81b7c2aa
Pipeline #83581 passed with stage
in 15 minutes and 36 seconds
......@@ -3,15 +3,23 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function parseReservation(text)
function parseReservation(html, node)
{
var reservations = new Array();
const text = html.root.recursiveContent;
const resNum = text.match(/予約番号\n(.*)\n/);
const date = text.match(/乗車日.*?(\d.*)\n/);
const trainInfo = text.match(/列車情報==([\s\S]*?)==/)[1];
const legs = trainInfo.split(/\(\d列車目\)\n/);
var qrCode = undefined;
for (qrCodeNode of node.findChildNodes({ mimeType: "text/plain", scope: "Descendants" })) {
if (qrCodeNode.location == "qrcode") {
qrCode = qrCodeNode.content;
break;
}
}
var reservations = new Array();
for (leg of legs) {
console.log(leg);
const fromTo = leg.match(/区 間:(.*?)\((.*?)\)(.*?)\((.*?)\)\n/);
if (!fromTo) {
continue;
......@@ -34,6 +42,9 @@ function parseReservation(text)
}
res.reservationNumber = resNum[1];
if (qrCode) {
res.reservedTicket.ticketToken = "qrCode:" + qrCode;
}
reservations.push(res);
}
return reservations;
......
......@@ -8,6 +8,6 @@
}
],
"function": "parseReservation",
"mimeType": "text/plain",
"mimeType": "text/html",
"script": "eki-net.js"
}
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