@curless/hotel-storefront 0.73.1 → 0.74.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/index.d.ts +16 -6
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +184 -33
- package/dist/account/index.js.map +1 -1
- package/dist/account/pages.d.ts +5 -1
- package/dist/account/pages.d.ts.map +1 -1
- package/dist/account/pages.js +11 -7
- package/dist/account/pages.js.map +1 -1
- package/dist/account/store.d.ts +4 -2
- package/dist/account/store.d.ts.map +1 -1
- package/dist/account/store.js.map +1 -1
- package/dist/card.generated.d.ts +1 -1
- package/dist/card.generated.js +2 -2
- package/dist/card.generated.js.map +1 -1
- package/dist/otaless/booking.d.ts +20 -1
- package/dist/otaless/booking.d.ts.map +1 -1
- package/dist/otaless/booking.js +273 -124
- package/dist/otaless/booking.js.map +1 -1
- package/dist/otaless/client.d.ts +53 -24
- package/dist/otaless/client.d.ts.map +1 -1
- package/dist/otaless/client.js +10 -7
- package/dist/otaless/client.js.map +1 -1
- package/dist/otaless/fake.d.ts +32 -1
- package/dist/otaless/fake.d.ts.map +1 -1
- package/dist/otaless/fake.js +84 -22
- package/dist/otaless/fake.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +7 -2
- package/dist/server.js.map +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +13 -7
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
package/dist/otaless/booking.js
CHANGED
|
@@ -18,9 +18,11 @@ import { CHANNEL_SESSION_EXPIRED, NOT_SIGNED_IN, OtalessBusy, OtalessError, REPE
|
|
|
18
18
|
// is ordered, and 8 is called only once the guest agreed on the card's own
|
|
19
19
|
// button or the one-time page (`acceptTerms`), never on the model's word.
|
|
20
20
|
// A group whose `/site` row says `termsRequired` (the 11-16 document, 0.72.1)
|
|
21
|
-
// is asked for its own terms by 8 itself -
|
|
22
|
-
//
|
|
23
|
-
// only then
|
|
21
|
+
// is asked for its own terms by 8 itself - its step 1, which answers them
|
|
22
|
+
// with a `confirmToken` and orders nothing - and those are what the guest
|
|
23
|
+
// agrees to; only then are its steps 2 (`termsAccepted`) and 3
|
|
24
|
+
// (`checkoutPayment`) sent with that token, to order it (the 11-17
|
|
25
|
+
// document, 0.74.0 - `place`).
|
|
24
26
|
// Terms the group answers the order with that are not the ones agreed hold
|
|
25
27
|
// the order's payment page back until the guest agrees to them too; not
|
|
26
28
|
// agreed, or not in `TERMS_MS`, the order is cancelled (9).
|
|
@@ -178,6 +180,13 @@ const REASON_MAX = 200;
|
|
|
178
180
|
const SESSIONS_MAX = 20_000;
|
|
179
181
|
const PENDING_MAX = 2_000;
|
|
180
182
|
const PENDING_PER_ACCOUNT = 5;
|
|
183
|
+
/**
|
|
184
|
+
* 8's `confirmToken` (step 1 of the 11-17 document - a UUID in its example): printable, no
|
|
185
|
+
* spaces, and not long - one that is not goes nowhere.
|
|
186
|
+
*/
|
|
187
|
+
export const STEP_TOKEN = /^[\x21-\x7e]{1,512}$/;
|
|
188
|
+
/** ⚠️ A `confirmToken` ON THE LOG: its first six characters, never more (总线程 11-17). */
|
|
189
|
+
export const tokenForLog = (token) => `${token.slice(0, 6)}…`;
|
|
181
190
|
/** The orders checked on one look at the bookings - newest first; the rest wait for the next look. */
|
|
182
191
|
const CHECKED_PER_LOOK = 5;
|
|
183
192
|
/**
|
|
@@ -622,6 +631,21 @@ export const cancelOutcome = (out) => {
|
|
|
622
631
|
return 'unknown';
|
|
623
632
|
return CANCELLED_STATUSES.has(s) ? 'done' : 'refused';
|
|
624
633
|
};
|
|
634
|
+
/**
|
|
635
|
+
* The backend refusing because the guest's membership of that group is not linked - or its
|
|
636
|
+
* channel not signed in - in its own words (0.74.0, robin 11-17: 「未绑定 / 未登录渠道」). Its
|
|
637
|
+
* codes for it are questions #94; ⚠️ NOT ITS 4012 (`CHANNEL_SESSION_EXPIRED`, answered with a
|
|
638
|
+
* new handshake first) NOR 401 (the account's own sign-in). Words we cannot read are not it.
|
|
639
|
+
*/
|
|
640
|
+
export const unlinkedSaid = (err) => {
|
|
641
|
+
if (!(err instanceof OtalessError) || err instanceof OtalessBusy)
|
|
642
|
+
return false;
|
|
643
|
+
if (err.backendCode === CHANNEL_SESSION_EXPIRED || err.backendCode === NOT_SIGNED_IN)
|
|
644
|
+
return false;
|
|
645
|
+
const msg = String(err.answer?.msg ?? '');
|
|
646
|
+
return (/(未|没有?)(绑定|关联)(该|此|这个)?(渠道|集团|会员)|(渠道|集团)(会员)?(未|没有?)(绑定|关联|登录)|未登录(该|此|这个)?渠道|请先(绑定|关联|登录)(该|此|这个)?(渠道|集团)|渠道凭据(不存在|为空|缺失)/.test(msg) ||
|
|
647
|
+
/\b(channel|membership|provider)\b[^.]{0,40}\b(not (linked|bound|signed in)|unlinked|unbound)\b|\bnot (linked|bound) to\b/i.test(msg));
|
|
648
|
+
};
|
|
625
649
|
const isCode = (err, code) => err instanceof OtalessError && !(err instanceof OtalessBusy) && err.backendCode === code;
|
|
626
650
|
/**
|
|
627
651
|
* Sent, and no answer it could be read by: whether it was done is not known -
|
|
@@ -689,7 +713,27 @@ export const createOtalessBookings = (deps) => {
|
|
|
689
713
|
return undefined;
|
|
690
714
|
}
|
|
691
715
|
};
|
|
692
|
-
|
|
716
|
+
/**
|
|
717
|
+
* ⚠️ NOT SIGNED IN TO THE ACCOUNT ITSELF (0.74.0, robin 11-17: 「登陆平台就好,酒店预订不需要每次
|
|
718
|
+
* 登陆」): the only thing checked before a booking. A group linked or not is the backend's to
|
|
719
|
+
* say (`linkFirst`) - no group is asked to be linked before it is booked. No groups: no link.
|
|
720
|
+
*/
|
|
721
|
+
const signInFirst = (_groups) => signInRefusal('sign-in', `Nothing was booked: booking needs the guest signed in to their ${deps.brand} account - ask them to sign in first.`, []);
|
|
722
|
+
/**
|
|
723
|
+
* The backend said this group needs the guest's membership linked before it books (0.74.0,
|
|
724
|
+
* robin 11-17): its 4012 after a new handshake, or its own words for a channel not linked
|
|
725
|
+
* (`unlinkedSaid`). ⚠️ NOTHING WAS ORDERED - both are answered before the group is asked
|
|
726
|
+
* (the document's `requireMemberAndMcpSession`) - so the guest links it, comes back and
|
|
727
|
+
* presses Book again: one order. The account marks the group to be linked again (its
|
|
728
|
+
* `expired` - the remembered link stays, 总线程 11-17).
|
|
729
|
+
*/
|
|
730
|
+
const linkFirst = (acct, why) => {
|
|
731
|
+
sessions.delete(sessionKey(acct));
|
|
732
|
+
deps.auth?.expired?.(acct.key, acct.group);
|
|
733
|
+
const name = deps.groupOf(acct.group).name;
|
|
734
|
+
log(`[otaless] a booking at ${acct.group} needs its membership linked: ${why} - nothing was ordered`);
|
|
735
|
+
return signInRefusal('sign-in', `${name} needs the guest's ${name} membership linked to their ${deps.brand} account before this booking can be made, so nothing was booked or charged. Once it is linked, the guest presses Book again.`, [acct.group]);
|
|
736
|
+
};
|
|
693
737
|
/**
|
|
694
738
|
* One of this guest's orders, by its id or the code the guest quotes, with
|
|
695
739
|
* their sign-in at its group - never an order of anyone else, and never one
|
|
@@ -749,6 +793,12 @@ export const createOtalessBookings = (deps) => {
|
|
|
749
793
|
counts.initRefused += 1;
|
|
750
794
|
log(`[otaless] initialize for ${group} with the member's token was refused (code ${err.backendCode}) - questions, 11-10 evening`);
|
|
751
795
|
}
|
|
796
|
+
// 0.74.1 (总线程's review of 0.74.0, P3): the account's sign-in over is said as that -
|
|
797
|
+
// and the group not linked as that - never as the group not taking the booking.
|
|
798
|
+
if (isCode(err, NOT_SIGNED_IN))
|
|
799
|
+
throw signedOut(acct);
|
|
800
|
+
if (unlinkedSaid(err))
|
|
801
|
+
throw linkFirst(acct, 'initialize said so in its own words');
|
|
752
802
|
throw err;
|
|
753
803
|
}
|
|
754
804
|
const id = text(sent.data?.mcpSessionId) ?? sent.session;
|
|
@@ -810,17 +860,22 @@ export const createOtalessBookings = (deps) => {
|
|
|
810
860
|
throw signedOut(acct);
|
|
811
861
|
if (!isCode(err, CHANNEL_SESSION_EXPIRED))
|
|
812
862
|
throw err;
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
throw signInRefusal('session-expired', `${name} says the guest's sign-in there is over, so nothing was done - ask them to sign in to ${name} through their ${deps.brand} account again.`, [acct.group]);
|
|
863
|
+
// ⚠️ 4012 AGAIN, AFTER A NEW HANDSHAKE (0.74.0): the backend has no session of the
|
|
864
|
+
// group's for this account - its membership is to be linked (again). Nothing ordered.
|
|
865
|
+
throw linkFirst(acct, '4012 again after a new handshake');
|
|
817
866
|
}
|
|
818
867
|
};
|
|
868
|
+
/**
|
|
869
|
+
* 401: the guest's sign-in to the ACCOUNT is over (0.74.0 - every booking goes with the
|
|
870
|
+
* account's own token, Sa-Token's `NotLoginException`). No link mends that: they sign in to
|
|
871
|
+
* the account again. The group's link is left as it is.
|
|
872
|
+
*/
|
|
819
873
|
const signedOut = (acct) => {
|
|
820
874
|
sessions.delete(sessionKey(acct));
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
875
|
+
// ⚠️ ENDED HERE TOO (0.74.1, 总线程's review of 0.74.0, P2-2): kept signed in with a token
|
|
876
|
+
// the backend refuses, the guest told to sign in again was answered "already signed in".
|
|
877
|
+
deps.auth?.signedOut?.(acct.key);
|
|
878
|
+
return signInRefusal('signed-out', `The guest's sign-in to their ${deps.brand} account is over, so nothing was done - ask them to sign in again.`, []);
|
|
824
879
|
};
|
|
825
880
|
// ── an order, as a booking ────────────────────────────────────────────────
|
|
826
881
|
/** One of the amounts the order asked: 13's, the quote's, or the quote's USD. */
|
|
@@ -1054,88 +1109,55 @@ export const createOtalessBookings = (deps) => {
|
|
|
1054
1109
|
? 'other nights'
|
|
1055
1110
|
: undefined;
|
|
1056
1111
|
/**
|
|
1057
|
-
* 8
|
|
1058
|
-
* `confirm_required`, #68)
|
|
1059
|
-
*
|
|
1060
|
-
*
|
|
1061
|
-
*
|
|
1062
|
-
*
|
|
1063
|
-
* guest did it - nothing is booked, and the log says which it was.
|
|
1112
|
+
* 8 refused for a second step, with no order (`terms_required`, questions #66;
|
|
1113
|
+
* `confirm_required`, #68) - what the backend answered before its three steps (11-11).
|
|
1114
|
+
* ⚠️ NOT BOOKED, NOTHING SHOWN (0.74.0): what it sends to agree to or confirm, and its token
|
|
1115
|
+
* (the names guessed in #66 / #68), have no way back - the 11-17 document's steps 2 and 3
|
|
1116
|
+
* take a `confirmToken` of step 1 alone, and one of these sent there would be read as that.
|
|
1117
|
+
* Never agreed or confirmed for the guest (#52); the log says which it was.
|
|
1064
1118
|
*/
|
|
1065
|
-
const groupAsked = (a, step, data
|
|
1119
|
+
const groupAsked = (a, step, data) => {
|
|
1066
1120
|
const g = deps.groupOf(a.group);
|
|
1067
1121
|
const what = `${step}_required`;
|
|
1068
1122
|
const code = (step === 'terms' ? 'group-terms' : 'group-confirm');
|
|
1069
1123
|
const asked = groupStepOf(step, data);
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
const amountOff = off === 'another amount';
|
|
1073
|
-
if (off) {
|
|
1074
|
-
log(`[otaless] booking at ${a.group} answered ${what} for ${amountOff ? 'another amount' : 'other nights'} than the guest was shown - not shown, not booked`);
|
|
1075
|
-
return {
|
|
1076
|
-
failed: failedStay(a, `${g.name} asked for ${step === 'terms' ? 'its terms to be agreed to' : 'the booking to be confirmed'} at ${amountOff ? 'another amount' : 'other nights'} than the guest was shown, so nothing was booked or charged.`, code),
|
|
1077
|
-
};
|
|
1078
|
-
}
|
|
1079
|
-
log(`[otaless] booking at ${a.group} answered ${what} with what to ${step === 'terms' ? 'agree to' : 'confirm'} - shown to the guest, nothing ordered`);
|
|
1080
|
-
return {
|
|
1081
|
-
terms: remember({
|
|
1082
|
-
ref: randomBytes(18).toString('base64url'),
|
|
1083
|
-
group: a.group,
|
|
1084
|
-
...groupWords(a.group),
|
|
1085
|
-
hotelId: a.hotel.id,
|
|
1086
|
-
hotelName: a.hotel.name,
|
|
1087
|
-
...(a.hotel.names?.name ? { hotelNames: a.hotel.names.name } : {}),
|
|
1088
|
-
roomName: a.roomName,
|
|
1089
|
-
stay: a.stay,
|
|
1090
|
-
rooms: a.rooms,
|
|
1091
|
-
total: a.total,
|
|
1092
|
-
text: asked.text,
|
|
1093
|
-
source: 'booking',
|
|
1094
|
-
more: true,
|
|
1095
|
-
askedByGroup: step,
|
|
1096
|
-
until: iso(now() + TERMS_MS),
|
|
1097
|
-
owner: a.acct.owner,
|
|
1098
|
-
key: a.acct.key,
|
|
1099
|
-
ask: {
|
|
1100
|
-
roomId: a.roomId,
|
|
1101
|
-
guest: a.guest,
|
|
1102
|
-
roomTerms: a.agreed,
|
|
1103
|
-
token: asked.token,
|
|
1104
|
-
step,
|
|
1105
|
-
},
|
|
1106
|
-
}),
|
|
1107
|
-
};
|
|
1108
|
-
}
|
|
1109
|
-
// After the guest agreed to the group's own terms - 8's (0.72.1) or a step's.
|
|
1110
|
-
const agreedAlready = !!a.groupStep || a.groupTerms === 'agreed';
|
|
1124
|
+
// After the guest agreed to the group's own terms (8's steps).
|
|
1125
|
+
const agreedAlready = a.groupTerms === 'agreed';
|
|
1111
1126
|
log(agreedAlready
|
|
1112
1127
|
? `[otaless] booking at ${a.group} answered ${what} again, after the guest ${step === 'terms' ? 'agreed to its terms' : 'confirmed it'} - not booked`
|
|
1113
|
-
:
|
|
1128
|
+
: asked
|
|
1129
|
+
? `[otaless] booking at ${a.group} answered ${what} with what to ${step === 'terms' ? 'agree to' : 'confirm'} and a token of its own, which 8 has no way to take back (its steps take step 1's confirmToken alone) - not shown, not booked (questions #${step === 'terms' ? 66 : 68})`
|
|
1130
|
+
: `[otaless] booking at ${a.group} answered ${what} with no ${step === 'terms' ? 'terms' : 'details'} and token to show the guest - not booked (questions #${step === 'terms' ? 66 : 68})`);
|
|
1114
1131
|
const again = step === 'terms'
|
|
1115
1132
|
? `${g.name} asked for its terms to be agreed to again after the guest agreed to them, so nothing was booked or charged.`
|
|
1116
1133
|
: `${g.name} asked for the booking to be confirmed again after the guest confirmed it, so nothing was booked or charged.`;
|
|
1117
|
-
const none =
|
|
1118
|
-
?
|
|
1119
|
-
|
|
1134
|
+
const none = asked
|
|
1135
|
+
? step === 'terms'
|
|
1136
|
+
? `${g.name} asked for terms of its own to be agreed to in a way that cannot be answered from here, so nothing was booked or charged.`
|
|
1137
|
+
: `${g.name} asked for the booking to be confirmed in a way that cannot be answered from here, so nothing was booked or charged.`
|
|
1138
|
+
: step === 'terms'
|
|
1139
|
+
? `${g.name} asked for terms of its own to be agreed to, which it did not send to be shown here, so nothing was booked or charged.`
|
|
1140
|
+
: `${g.name} asked for the booking to be confirmed in a second step, and did not send what to confirm to be shown here, so nothing was booked or charged.`;
|
|
1120
1141
|
// New codes for the card (酒店平台's next version): until then, these words.
|
|
1121
1142
|
return { failed: failedStay(a, agreedAlready ? again : none, code) };
|
|
1122
1143
|
};
|
|
1123
1144
|
/**
|
|
1124
|
-
* 8 answered the group's own terms, and no order (`WireBookingTerms` - the 11-
|
|
1125
|
-
*
|
|
1126
|
-
*
|
|
1127
|
-
*
|
|
1128
|
-
*
|
|
1129
|
-
*
|
|
1130
|
-
* ⚠️
|
|
1131
|
-
*
|
|
1132
|
-
*
|
|
1145
|
+
* 8's step 1 answered the group's own terms, and no order (`WireBookingTerms` - the 11-17
|
|
1146
|
+
* document: a group whose `/site` says it asks for them; robin 11-16, questions #66, #79).
|
|
1147
|
+
* ⚠️ NEVER AGREED FOR THE GUEST (#52): its `termsPoints` and `cancellation`, word for word,
|
|
1148
|
+
* are the guest's to read and agree to themselves - the card's button or the one-time page;
|
|
1149
|
+
* agreed, the room is priced again and steps 2 and 3 sent with its `confirmToken`, which
|
|
1150
|
+
* order it (`place`). Not agreed: nothing more is sent.
|
|
1151
|
+
* ⚠️ THE TOKEN IS KEPT WITH THE TERMS, IN MEMORY ALONE (`Pending`); with none, they cannot
|
|
1152
|
+
* be agreed to - not shown, not booked. ⚠️ NOT HANDED ON: `next` (words for a model - "ask
|
|
1153
|
+
* about add-ons before the yes"), the `summary` (to the log alone, questions #75),
|
|
1154
|
+
* `acceptArgs` (the backend keeps its own). For another hotel or room than the one asked,
|
|
1133
1155
|
* with nothing to show, too long to show whole, or answered again after the guest agreed:
|
|
1134
1156
|
* nothing is shown and nothing booked.
|
|
1135
1157
|
*/
|
|
1136
1158
|
const termsFrom8 = (a, w) => {
|
|
1137
1159
|
const g = deps.groupOf(a.group);
|
|
1138
|
-
const guest = [a.guest.name, a.guest.email, a.guest.phone];
|
|
1160
|
+
const guest = [a.guest.name, a.guest.email, a.guest.phone, a.confirmToken];
|
|
1139
1161
|
const note = text(w.summary ?? undefined);
|
|
1140
1162
|
if (note)
|
|
1141
1163
|
log(`[otaless] booking at ${a.group}: the summary of its terms, kept to this log: "${summaryForLog(note, guest)}"`);
|
|
@@ -1169,11 +1191,12 @@ export const createOtalessBookings = (deps) => {
|
|
|
1169
1191
|
return notBooked('with nothing to show', `${g.name} asked for its own terms to be agreed to and sent none to show here, so nothing was booked or charged.`, 'group-terms');
|
|
1170
1192
|
if (shown.length > TERMS_MAX)
|
|
1171
1193
|
return notBooked('too long to show whole', `${g.name}'s terms for this room are too long to show in full here, so nothing was booked or charged.`);
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1194
|
+
// ⚠️ THE TOKEN STEPS 2 AND 3 GO WITH (the 11-17 document): with none - or one that is not
|
|
1195
|
+
// a token - the terms cannot be agreed to, so they are not shown.
|
|
1196
|
+
const token = typeof w.confirmToken === 'string' ? w.confirmToken.trim() : '';
|
|
1197
|
+
if (!STEP_TOKEN.test(token))
|
|
1198
|
+
return notBooked('with no confirmToken to agree to them with (steps 2 and 3 take one - the 11-17 document)', `${g.name} sent its own terms with no way to agree to them from here, so nothing was booked or charged.`, 'group-terms');
|
|
1199
|
+
log(`[otaless] booking at ${a.group} answered its terms (${[points.length ? `termsPoints${points.length > 1 || Array.isArray(w.termsPoints) ? ` - ${points.length} points` : ''}` : '', text(w.cancellation ?? undefined) ? 'cancellation' : ''].filter(Boolean).join(', ')}) - shown to the guest, nothing ordered; its confirmToken ${tokenForLog(token)} kept in memory for the guest's yes${w.acceptArgs !== undefined && w.acceptArgs !== null ? '; acceptArgs not sent back (the backend keeps its own)' : ''}${a.groupTerms ? '' : ` - 8 was sent with no termsRequired: /site said ${a.group} asks for none (out of date - read again within ten minutes)`}`);
|
|
1177
1200
|
return {
|
|
1178
1201
|
terms: remember({
|
|
1179
1202
|
ref: randomBytes(18).toString('base64url'),
|
|
@@ -1200,6 +1223,7 @@ export const createOtalessBookings = (deps) => {
|
|
|
1200
1223
|
guest: a.guest,
|
|
1201
1224
|
groupTerms: 'answered',
|
|
1202
1225
|
parts: points.length > 1 ? [...parts, ...points] : parts,
|
|
1226
|
+
confirmToken: token,
|
|
1203
1227
|
},
|
|
1204
1228
|
}),
|
|
1205
1229
|
};
|
|
@@ -1405,7 +1429,7 @@ export const createOtalessBookings = (deps) => {
|
|
|
1405
1429
|
r.stay.checkIn === a.stay.checkIn &&
|
|
1406
1430
|
r.stay.checkOut === a.stay.checkOut));
|
|
1407
1431
|
const untouched = (a, id, how) => {
|
|
1408
|
-
const guest = [a.guest.name, a.guest.email, a.guest.phone];
|
|
1432
|
+
const guest = [a.guest.name, a.guest.email, a.guest.phone, a.confirmToken];
|
|
1409
1433
|
log(`[otaless] booking at ${a.group}: 8 ${how} naming order ${forTheLog(id, guest)}, one already kept here - not touched (not cancelled, overwritten or claimed); said as a refusal`);
|
|
1410
1434
|
return {
|
|
1411
1435
|
failed: failedStay(a, `${deps.groupOf(a.group).name} did not take the booking, so nothing was booked or charged.`),
|
|
@@ -1427,6 +1451,8 @@ export const createOtalessBookings = (deps) => {
|
|
|
1427
1451
|
a.guest.name,
|
|
1428
1452
|
a.guest.email,
|
|
1429
1453
|
a.guest.phone,
|
|
1454
|
+
// ⚠️ AND STEP 3's TOKEN (0.74.1): this line goes to the log as it is.
|
|
1455
|
+
a.confirmToken,
|
|
1430
1456
|
]),
|
|
1431
1457
|
};
|
|
1432
1458
|
};
|
|
@@ -1448,7 +1474,7 @@ export const createOtalessBookings = (deps) => {
|
|
|
1448
1474
|
const r = recordOf(a, pairs, `pending:${randomBytes(8).toString('hex')}`, '', 'unconfirmed');
|
|
1449
1475
|
r.refusedOrder = ref;
|
|
1450
1476
|
put(r);
|
|
1451
|
-
const guest = [a.guest.name, a.guest.email, a.guest.phone];
|
|
1477
|
+
const guest = [a.guest.name, a.guest.email, a.guest.phone, a.confirmToken];
|
|
1452
1478
|
const said = `booking at ${a.group} refused "${ref.said}" with order ${forTheLog(ref.id, guest)} in its answer`;
|
|
1453
1479
|
let rows;
|
|
1454
1480
|
try {
|
|
@@ -1502,18 +1528,23 @@ export const createOtalessBookings = (deps) => {
|
|
|
1502
1528
|
const k = termsKey(said);
|
|
1503
1529
|
if (k === termsKey(a.agreed))
|
|
1504
1530
|
return true;
|
|
1505
|
-
if (a.groupStep?.step === 'terms' && k === termsKey(a.groupStep.text))
|
|
1506
|
-
return true;
|
|
1507
1531
|
return a.groupTerms === 'agreed' && (a.agreedParts ?? []).some((p) => termsKey(p) === k);
|
|
1508
1532
|
};
|
|
1509
1533
|
/** What 8 answered, settled: an order to hand on, one held for new terms, or none. */
|
|
1510
1534
|
const settle = async (a, w, pairs) => {
|
|
1511
|
-
// ⚠️ THE GROUP'S TERMS, NOT AN ORDER (0.72.1): 8
|
|
1512
|
-
//
|
|
1513
|
-
// ⚠️
|
|
1514
|
-
//
|
|
1515
|
-
//
|
|
1516
|
-
|
|
1535
|
+
// ⚠️ THE GROUP'S TERMS, NOT AN ORDER (0.72.1): 8's step 1 answers them with no order id -
|
|
1536
|
+
// never an order "being looked into" (核对中) below.
|
|
1537
|
+
// ⚠️ AN 8 SENT WITH `termsRequired` - OR ONE ANSWERED WITH STEP 1'S TOKEN (0.74.0, 总线程
|
|
1538
|
+
// 11-17): the backend goes by its own `/site` (the 11-17 document), so a group whose
|
|
1539
|
+
// `/site` we read as asking for none ten minutes ago may answer step 1 all the same - its
|
|
1540
|
+
// terms and a `confirmToken`, nothing ordered; kept as one being looked into, that stay was
|
|
1541
|
+
// held back for hours with no order anywhere. Its terms are shown and agreed to as any.
|
|
1542
|
+
// ⚠️ NEVER ON ITS OWN MARKS ALONE (总线程's review of 0.72.1, P3-1): at a group that asks
|
|
1543
|
+
// for no terms (Atour, JI - `/site` false) an answer with no id and no such token is an
|
|
1544
|
+
// order's, being looked into - never "not booked", booked again.
|
|
1545
|
+
if ((a.groupTerms ||
|
|
1546
|
+
STEP_TOKEN.test(String(w?.confirmToken ?? '').trim())) &&
|
|
1547
|
+
isBookingTerms(w))
|
|
1517
1548
|
return termsFrom8(a, w);
|
|
1518
1549
|
return settleOrder(a, w, pairs);
|
|
1519
1550
|
};
|
|
@@ -1526,7 +1557,7 @@ export const createOtalessBookings = (deps) => {
|
|
|
1526
1557
|
// number. Never shown to the guest, never in what the model reads (questions #75).
|
|
1527
1558
|
const note = text(w?.summary ?? undefined);
|
|
1528
1559
|
if (note)
|
|
1529
|
-
log(`[otaless] booking at ${a.group}: 8's summary, kept to this log: "${summaryForLog(note, [a.guest.name, a.guest.email, a.guest.phone])}"`);
|
|
1560
|
+
log(`[otaless] booking at ${a.group}: 8's summary, kept to this log: "${summaryForLog(note, [a.guest.name, a.guest.email, a.guest.phone, a.confirmToken])}"`);
|
|
1530
1561
|
const status = String(w?.status ?? '')
|
|
1531
1562
|
.trim()
|
|
1532
1563
|
.toUpperCase();
|
|
@@ -1535,7 +1566,7 @@ export const createOtalessBookings = (deps) => {
|
|
|
1535
1566
|
const err = text(w?.errorMessage ?? undefined);
|
|
1536
1567
|
if (!w || w.success === false || status === 'FAILED' || err) {
|
|
1537
1568
|
if (err)
|
|
1538
|
-
log(`[otaless] booking at ${a.group} refused: "${forTheLog(err, [a.guest.name, a.guest.email, a.guest.phone])}"`);
|
|
1569
|
+
log(`[otaless] booking at ${a.group} refused: "${forTheLog(err, [a.guest.name, a.guest.email, a.guest.phone, a.confirmToken])}"`);
|
|
1539
1570
|
const ref = w ? refusalOf(a, w, err ?? status) : undefined;
|
|
1540
1571
|
if (ref)
|
|
1541
1572
|
return refusedWithOrder(a, ref, pairs);
|
|
@@ -1547,7 +1578,7 @@ export const createOtalessBookings = (deps) => {
|
|
|
1547
1578
|
// Terms of its own to agree to, and no order (questions #66).
|
|
1548
1579
|
const step = /TERMS/.test(status) ? 'terms' : stepAsked(status);
|
|
1549
1580
|
if (step)
|
|
1550
|
-
return groupAsked(a, step, w
|
|
1581
|
+
return groupAsked(a, step, w);
|
|
1551
1582
|
// Something may be held, under a number we were not told: kept to look for (12).
|
|
1552
1583
|
const r = recordOf(a, pairs, `pending:${randomBytes(8).toString('hex')}`, '', 'unconfirmed');
|
|
1553
1584
|
put(r);
|
|
@@ -1709,6 +1740,22 @@ export const createOtalessBookings = (deps) => {
|
|
|
1709
1740
|
* only `PRICED_IN_MS`, by the sign-in's token - in memory alone.
|
|
1710
1741
|
*/
|
|
1711
1742
|
const pricedIn = new Map();
|
|
1743
|
+
/**
|
|
1744
|
+
* 8's step-3 tokens whose order is not known (核对中 - 0.74.0), by that order's id: kept as
|
|
1745
|
+
* 总线程 11-17 asked, for the day the backend can look an order up by one (questions #88).
|
|
1746
|
+
* ⚠️ IN MEMORY ONLY, NEVER SENT AGAIN, never on disk, the card, to the model or on the log
|
|
1747
|
+
* whole; gone with a restart, or past `PENDING_MAX`.
|
|
1748
|
+
*/
|
|
1749
|
+
const checkoutTokens = new Map();
|
|
1750
|
+
const keepCheckoutToken = (id, token) => {
|
|
1751
|
+
checkoutTokens.set(id, token);
|
|
1752
|
+
while (checkoutTokens.size > PENDING_MAX) {
|
|
1753
|
+
const first = checkoutTokens.keys().next().value;
|
|
1754
|
+
if (first === undefined)
|
|
1755
|
+
break;
|
|
1756
|
+
checkoutTokens.delete(first);
|
|
1757
|
+
}
|
|
1758
|
+
};
|
|
1712
1759
|
const pricedKey = (a, token) => `${hash(token)}|${a.hotel.id}|${a.roomId}|${a.stay.checkIn}|${a.stay.checkOut}|${a.stay.guests}|${a.rooms}`;
|
|
1713
1760
|
const pricedJustNow = (a, token, data) => {
|
|
1714
1761
|
const k = pricedKey(a, token);
|
|
@@ -1742,11 +1789,27 @@ export const createOtalessBookings = (deps) => {
|
|
|
1742
1789
|
* session, held to the price they were shown - and only then 8, in that same
|
|
1743
1790
|
* session (总线程 11-11, C). A 4012 on either is one new handshake and one more
|
|
1744
1791
|
* try of both.
|
|
1792
|
+
*
|
|
1793
|
+
* ⚠️ AT A GROUP THAT ASKS FOR ITS OWN TERMS, ONCE THE GUEST AGREED TO THEM (0.74.0, the
|
|
1794
|
+
* 11-17 document - 总线程 11-17): 7, then 8's step 2 (`termsAccepted`), then its step 3
|
|
1795
|
+
* (`checkoutPayment`), all here, with step 1's token alone. A price that moved stops it
|
|
1796
|
+
* before step 2. Step 2 not answered, refused as a repeat (10014) or for its state is no
|
|
1797
|
+
* failure: step 3 follows all the same - the backend orders it only once step 2 took, so
|
|
1798
|
+
* one that did not is refused there and nothing is ordered. ONLY STEP 3 MAY ORDER
|
|
1799
|
+
* (`fromBook`): not answered, or 10014, it is an order not known (核对中) and never sent
|
|
1800
|
+
* again; a 4012 is answered before the group is asked - a new handshake, and all once more.
|
|
1745
1801
|
*/
|
|
1746
1802
|
const place = async (a) => {
|
|
1747
1803
|
const g = deps.groupOf(a.group);
|
|
1804
|
+
// The guest's yes to the group's own terms, with no token to send it with: nothing to send.
|
|
1805
|
+
if (a.groupTerms === 'agreed' && !a.confirmToken) {
|
|
1806
|
+
log(`[otaless] booking at ${a.group}: the guest agreed to its terms with no confirmToken kept - not booked`);
|
|
1807
|
+
return {
|
|
1808
|
+
failed: failedStay(a, `${g.name}'s terms can no longer be agreed to from here, so nothing was booked or charged - ask to book again.`, 'group-terms'),
|
|
1809
|
+
};
|
|
1810
|
+
}
|
|
1748
1811
|
let pairs;
|
|
1749
|
-
/** What 8 itself threw, if it did: only that may have made an order. */
|
|
1812
|
+
/** What 8 itself threw, if it did - its step 3, at a group with three: only that may have made an order. */
|
|
1750
1813
|
let fromBook;
|
|
1751
1814
|
/** A refusal for a step naming an order we keep already (`knownNamed`) - see `madeIn`. */
|
|
1752
1815
|
let namedKnown;
|
|
@@ -1756,7 +1819,7 @@ export const createOtalessBookings = (deps) => {
|
|
|
1756
1819
|
fromBook = undefined;
|
|
1757
1820
|
let priced;
|
|
1758
1821
|
const ask = (mode) => deps.quoteIn(a.hotel, a.roomId, a.stay, a.rooms, cred, a.who, mode);
|
|
1759
|
-
const notPriced = (err) => isCode(err, NOT_SIGNED_IN) || isCode(err, CHANNEL_SESSION_EXPIRED)
|
|
1822
|
+
const notPriced = (err) => isCode(err, NOT_SIGNED_IN) || isCode(err, CHANNEL_SESSION_EXPIRED) || unlinkedSaid(err)
|
|
1760
1823
|
? err
|
|
1761
1824
|
: new NotPriced(err instanceof OtalessBusy, isCode(err, REPEAT_SUBMIT));
|
|
1762
1825
|
// ⚠️ THE 7 IN THE GUEST'S SESSION FIRST, AS EVER (总线程's review of 0.71.2, P2): it
|
|
@@ -1815,20 +1878,14 @@ export const createOtalessBookings = (deps) => {
|
|
|
1815
1878
|
checkIn: a.stay.checkIn,
|
|
1816
1879
|
checkOut: a.stay.checkOut,
|
|
1817
1880
|
roomCount: a.rooms,
|
|
1818
|
-
// 8's
|
|
1819
|
-
//
|
|
1820
|
-
...(a.groupTerms ? { termsRequired:
|
|
1821
|
-
// Only after the guest agreed to the terms 8 asked for (questions #66).
|
|
1822
|
-
...(a.groupStep?.step === 'terms'
|
|
1823
|
-
? { termsToken: a.groupStep.token, termsAccepted: true }
|
|
1824
|
-
: {}),
|
|
1825
|
-
...(a.groupStep?.step === 'confirm'
|
|
1826
|
-
? { confirmToken: a.groupStep.token, confirmed: true }
|
|
1827
|
-
: {}),
|
|
1881
|
+
// 8's step 1 (0.72.1): the group's terms asked for. Not sent at a group that asks
|
|
1882
|
+
// for no terms - nor after the guest agreed to them: steps 2 and 3 carry the token.
|
|
1883
|
+
...(a.groupTerms === 'ask' ? { termsRequired: true } : {}),
|
|
1828
1884
|
};
|
|
1885
|
+
const cred8 = { token: cred.token, ...(session ? { session } : {}) };
|
|
1829
1886
|
const send = async (b) => {
|
|
1830
1887
|
try {
|
|
1831
|
-
return await client.book(b,
|
|
1888
|
+
return await client.book(b, cred8, deps.callerOf(a.who));
|
|
1832
1889
|
}
|
|
1833
1890
|
catch (err) {
|
|
1834
1891
|
// ⚠️ A REFUSAL THAT CARRIES ITS ORDER IS THAT ORDER (总线程's review of
|
|
@@ -1865,18 +1922,52 @@ export const createOtalessBookings = (deps) => {
|
|
|
1865
1922
|
.trim()
|
|
1866
1923
|
.toUpperCase();
|
|
1867
1924
|
// The guest's own details never on the log (总线程's re-review of 0.68.1, 2).
|
|
1868
|
-
const guest = [a.guest.name, a.guest.email, a.guest.phone];
|
|
1925
|
+
const guest = [a.guest.name, a.guest.email, a.guest.phone, a.confirmToken];
|
|
1869
1926
|
log(`[otaless] booking at ${a.group}: 8 refused "${forTheLog(String(msg), guest)}" with order ${forTheLog(id, guest)} in its answer - kept as that order, not sent again`);
|
|
1870
1927
|
return {
|
|
1871
1928
|
...order,
|
|
1872
1929
|
status: /TERMS/.test(status) || stepAsked(status) ? order.status : String(msg),
|
|
1873
1930
|
};
|
|
1874
1931
|
};
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1932
|
+
/**
|
|
1933
|
+
* 8's step 2 (the 11-17 document): the guest's own yes to the group's terms, with
|
|
1934
|
+
* step 1's token alone - orders nothing. ⚠️ NOT `send`: never `fromBook`. An answer
|
|
1935
|
+
* that is not its taking is said on the log and step 3 goes all the same (it orders
|
|
1936
|
+
* only once step 2 took - questions #89, #94); only the sign-in (401), the session
|
|
1937
|
+
* (4012 - `withSession`) or a limit of ours (not sent) stops it here. An order in its
|
|
1938
|
+
* answer - not in the document - is that order: step 3 is never sent after one.
|
|
1939
|
+
*/
|
|
1940
|
+
const agree = async (token) => {
|
|
1941
|
+
let said;
|
|
1942
|
+
try {
|
|
1943
|
+
said = await client.book({ confirmToken: token, termsAccepted: true }, cred8, deps.callerOf(a.who));
|
|
1944
|
+
}
|
|
1945
|
+
catch (err) {
|
|
1946
|
+
if (err instanceof OtalessBusy ||
|
|
1947
|
+
isCode(err, NOT_SIGNED_IN) ||
|
|
1948
|
+
isCode(err, CHANNEL_SESSION_EXPIRED))
|
|
1949
|
+
throw err;
|
|
1950
|
+
const how = unanswered(err)
|
|
1951
|
+
? 'not answered'
|
|
1952
|
+
: isCode(err, REPEAT_SUBMIT)
|
|
1953
|
+
? 'answered 10014'
|
|
1954
|
+
: `refused${err instanceof OtalessError && err.backendCode !== undefined ? ` (code ${err.backendCode})` : ''}`;
|
|
1955
|
+
log(`[otaless] booking at ${a.group}: step 2 (the guest's yes, ${tokenForLog(token)}) ${how} - step 3 sent all the same: it orders only once step 2 took (questions #89, #94)`);
|
|
1956
|
+
return undefined;
|
|
1957
|
+
}
|
|
1958
|
+
const d = (said.data ?? {});
|
|
1959
|
+
if (text(d.unifiedOrderId) || text(d.originalOrderId) || text(d.checkoutUrl)) {
|
|
1960
|
+
log(`[otaless] booking at ${a.group}: step 2 answered with an order (not in the document) - taken as that order, step 3 not sent`);
|
|
1961
|
+
return said;
|
|
1962
|
+
}
|
|
1963
|
+
log(`[otaless] booking at ${a.group}: step 2 took the guest's yes (${forTheLog(String(d.status ?? '?'))}) - step 3 next`);
|
|
1964
|
+
return undefined;
|
|
1965
|
+
};
|
|
1966
|
+
const confirmToken = a.groupTerms === 'agreed' ? a.confirmToken : undefined;
|
|
1967
|
+
const stepTwo = confirmToken ? await agree(confirmToken) : undefined;
|
|
1968
|
+
// ⚠️ STEP 3 ONCE, AND ONLY STEP 3 MAY ORDER (`send` - `fromBook`): never sent again for
|
|
1969
|
+
// this token here, whatever comes back. The first 8 of any other booking: the same.
|
|
1970
|
+
const booked = stepTwo ?? (await send(confirmToken ? { confirmToken, checkoutPayment: true } : body));
|
|
1880
1971
|
const back = booked.session ?? priced.session;
|
|
1881
1972
|
return { data: booked.data, ...(back ? { session: back } : {}) };
|
|
1882
1973
|
});
|
|
@@ -1896,7 +1987,14 @@ export const createOtalessBookings = (deps) => {
|
|
|
1896
1987
|
: failedStay(a, `${g.name} did not price it again just now, so nothing was booked.`, 'unreachable'),
|
|
1897
1988
|
};
|
|
1898
1989
|
if (err instanceof OtalessBusy)
|
|
1899
|
-
return {
|
|
1990
|
+
return {
|
|
1991
|
+
failed:
|
|
1992
|
+
// ⚠️ AFTER THE GUEST'S YES, ITS TERMS ARE GONE (0.74.1, 总线程's review of 0.74.0,
|
|
1993
|
+
// P3): agreed once, they cannot be agreed again - Book again asks for new ones.
|
|
1994
|
+
a.groupTerms === 'agreed'
|
|
1995
|
+
? failedStay(a, `Not sent to ${g.name}: too many requests just now, so nothing was booked - the guest presses Book again in a minute.`, 'limited')
|
|
1996
|
+
: limited(a, g.name),
|
|
1997
|
+
};
|
|
1900
1998
|
// ⚠️ THE GROUP'S TERMS ASKED FOR, NOTHING AGREED - A 10014 IS NO ORDER (总线程's review
|
|
1901
1999
|
// of 0.72.1, P2-1): 8 sent with `termsRequired: true` answers the terms and orders
|
|
1902
2000
|
// nothing, so its repeat refused (10014) - Book pressed twice at Ascott, or asked again
|
|
@@ -1917,6 +2015,13 @@ export const createOtalessBookings = (deps) => {
|
|
|
1917
2015
|
if (err === fromBook && (unanswered(err) || isCode(err, REPEAT_SUBMIT))) {
|
|
1918
2016
|
const r = recordOf(a, pairs ?? { orig: a.total }, `pending:${randomBytes(8).toString('hex')}`, '', 'unconfirmed');
|
|
1919
2017
|
put(r);
|
|
2018
|
+
// ⚠️ 8's STEP 3 (0.74.0): its token stays - in memory alone, with the order not known -
|
|
2019
|
+
// and is never sent again; the order is looked for in the group's order list (12)
|
|
2020
|
+
// as any other (questions #88: whether the backend can look one up by its token).
|
|
2021
|
+
if (a.groupTerms === 'agreed' && a.confirmToken) {
|
|
2022
|
+
keepCheckoutToken(r.id, a.confirmToken);
|
|
2023
|
+
log(`[otaless] booking at ${a.group}: step 3 (checkout, ${tokenForLog(a.confirmToken)}) ${unanswered(err) ? 'not answered' : 'answered 10014'} - kept as not known (核对中), never sent again; looked for in its order list (12) (questions #88)`);
|
|
2024
|
+
}
|
|
1920
2025
|
return { booked: toBooking(r) };
|
|
1921
2026
|
}
|
|
1922
2027
|
if (namedKnown && err === namedKnown.err)
|
|
@@ -1924,12 +2029,19 @@ export const createOtalessBookings = (deps) => {
|
|
|
1924
2029
|
// ⚠️ 8 REFUSED FOR TERMS (robin 11-11 18:30, Ascott: code 500 "terms_required").
|
|
1925
2030
|
const step = err === fromBook && err instanceof OtalessError ? stepAsked(err.answer?.msg) : undefined;
|
|
1926
2031
|
if (step)
|
|
1927
|
-
return groupAsked(a, step, err instanceof OtalessError ? err.answer?.data : undefined
|
|
2032
|
+
return groupAsked(a, step, err instanceof OtalessError ? err.answer?.data : undefined);
|
|
1928
2033
|
const ref = err === fromBook && err instanceof OtalessError
|
|
1929
2034
|
? refusalOf(a, err.answer?.data, err.answer?.msg)
|
|
1930
2035
|
: undefined;
|
|
1931
2036
|
if (ref)
|
|
1932
2037
|
return refusedWithOrder(a, ref, pairs ?? { orig: a.total });
|
|
2038
|
+
// ⚠️ THE BACKEND'S OWN WORDS FOR A GROUP NOT LINKED (0.74.0, robin 11-17): refused, so
|
|
2039
|
+
// nothing was ordered - the guest links it and presses Book again. ⚠️ ONLY ONCE NO ORDER
|
|
2040
|
+
// IS NAMED IN THE REFUSAL (0.74.1, 总线程's review of 0.74.0, P2-1): one that names its
|
|
2041
|
+
// order was checked as that order just above - said as "not booked", it was booked twice.
|
|
2042
|
+
// Any other refusal is "not booked" below, with the backend's words on the log.
|
|
2043
|
+
if (unlinkedSaid(err))
|
|
2044
|
+
throw linkFirst(a.acct, 'its own words for a group not linked');
|
|
1933
2045
|
if (err instanceof OtalessError)
|
|
1934
2046
|
return {
|
|
1935
2047
|
failed: failedStay(a, `${g.name} did not take the booking, so nothing was booked or charged.`),
|
|
@@ -2144,6 +2256,34 @@ export const createOtalessBookings = (deps) => {
|
|
|
2144
2256
|
const booked = [];
|
|
2145
2257
|
const terms = [];
|
|
2146
2258
|
const reused = [];
|
|
2259
|
+
/**
|
|
2260
|
+
* ⚠️ ONE STAY REFUSED FOR A SIGN-IN OR A LINK IS THAT STAY'S ALONE (0.74.1, 总线程's review
|
|
2261
|
+
* of 0.74.0, P1): thrown, it took the stays booked before it out of the answer - the
|
|
2262
|
+
* guest read "nothing was booked", and Book again ordered them twice (an order CONFIRMED
|
|
2263
|
+
* with no payment page is not one `stayGuard` hands back). Kept as that stay's failure,
|
|
2264
|
+
* with its groups, beside what was booked; nothing booked at all, the refusal itself is
|
|
2265
|
+
* the answer, as before.
|
|
2266
|
+
*/
|
|
2267
|
+
const stayRefusals = [];
|
|
2268
|
+
const placeStay = async (label, ask) => {
|
|
2269
|
+
try {
|
|
2270
|
+
return await place(ask);
|
|
2271
|
+
}
|
|
2272
|
+
catch (err) {
|
|
2273
|
+
const e = err;
|
|
2274
|
+
if (!(err instanceof Error) ||
|
|
2275
|
+
(e?.code !== 'sign-in' && e?.code !== 'signed-out' && e?.code !== 'session-expired') ||
|
|
2276
|
+
!Array.isArray(e.groups))
|
|
2277
|
+
throw err;
|
|
2278
|
+
stayRefusals.push(err);
|
|
2279
|
+
return {
|
|
2280
|
+
failed: {
|
|
2281
|
+
...failedStay(label, err.message),
|
|
2282
|
+
...(e.groups.length ? { groups: [...e.groups] } : {}),
|
|
2283
|
+
},
|
|
2284
|
+
};
|
|
2285
|
+
}
|
|
2286
|
+
};
|
|
2147
2287
|
for (const line of q.lines) {
|
|
2148
2288
|
if (line.kind !== 'room' || !line.stay || !line.roomRef)
|
|
2149
2289
|
continue;
|
|
@@ -2162,7 +2302,7 @@ export const createOtalessBookings = (deps) => {
|
|
|
2162
2302
|
const group = hotel.supplier;
|
|
2163
2303
|
const acct = accountFor(who, group);
|
|
2164
2304
|
if (!acct) {
|
|
2165
|
-
failed.push(
|
|
2305
|
+
failed.push(failedStay(label, signInFirst([group]).message));
|
|
2166
2306
|
continue;
|
|
2167
2307
|
}
|
|
2168
2308
|
const lockKey = `${acct.owner}|${hotel.id}|${line.roomRef}|${stay.checkIn}|${stay.checkOut}|${rooms}`;
|
|
@@ -2208,7 +2348,12 @@ export const createOtalessBookings = (deps) => {
|
|
|
2208
2348
|
if (needsTerms) {
|
|
2209
2349
|
inFlight.add(lockKey);
|
|
2210
2350
|
try {
|
|
2211
|
-
const out = await
|
|
2351
|
+
const out = await placeStay(label, {
|
|
2352
|
+
...ask,
|
|
2353
|
+
agreed: '',
|
|
2354
|
+
roomTerms: agreed,
|
|
2355
|
+
groupTerms: 'ask',
|
|
2356
|
+
});
|
|
2212
2357
|
if (out.booked)
|
|
2213
2358
|
booked.push(out.booked);
|
|
2214
2359
|
if (out.failed)
|
|
@@ -2227,7 +2372,7 @@ export const createOtalessBookings = (deps) => {
|
|
|
2227
2372
|
if (!agreed && deps.proceedWithoutGroupConfirm) {
|
|
2228
2373
|
inFlight.add(lockKey);
|
|
2229
2374
|
try {
|
|
2230
|
-
const out = await
|
|
2375
|
+
const out = await placeStay(label, {
|
|
2231
2376
|
...ask,
|
|
2232
2377
|
noTerms: true,
|
|
2233
2378
|
...(unsaid ? { groupTerms: 'ask' } : {}),
|
|
@@ -2247,6 +2392,9 @@ export const createOtalessBookings = (deps) => {
|
|
|
2247
2392
|
// ⚠️ NOTHING IS ORDERED YET (§15.1): the terms first, for the guest to agree to.
|
|
2248
2393
|
terms.push(termsBefore(ask, unsaid));
|
|
2249
2394
|
}
|
|
2395
|
+
// Nothing booked, nothing waiting: the sign-in or link the backend asked for is the answer.
|
|
2396
|
+
if (stayRefusals[0] && !booked.length && !terms.length)
|
|
2397
|
+
throw stayRefusals[0];
|
|
2250
2398
|
return {
|
|
2251
2399
|
booked,
|
|
2252
2400
|
failed,
|
|
@@ -2326,15 +2474,16 @@ export const createOtalessBookings = (deps) => {
|
|
|
2326
2474
|
roomName: p.roomName,
|
|
2327
2475
|
stay: p.stay,
|
|
2328
2476
|
rooms: p.rooms,
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
: {}),
|
|
2334
|
-
// 8's own two steps (0.72.1): the group's terms as 8 answered them, agreed - the
|
|
2335
|
-
// order now; or the room's, at a group whose `/site` did not say - 8 asks for them.
|
|
2477
|
+
agreed: p.text,
|
|
2478
|
+
// 8's own steps: the group's terms as its step 1 answered them, agreed - steps 2 and
|
|
2479
|
+
// 3 with its token, the order now (0.74.0); or the room's, at a group whose `/site`
|
|
2480
|
+
// did not say - 8 asks for them (0.72.1).
|
|
2336
2481
|
...(ask.groupTerms === 'answered'
|
|
2337
|
-
? {
|
|
2482
|
+
? {
|
|
2483
|
+
groupTerms: 'agreed',
|
|
2484
|
+
...(ask.parts ? { agreedParts: ask.parts } : {}),
|
|
2485
|
+
...(ask.confirmToken ? { confirmToken: ask.confirmToken } : {}),
|
|
2486
|
+
}
|
|
2338
2487
|
: ask.groupTerms === 'ask'
|
|
2339
2488
|
? { groupTerms: 'ask' }
|
|
2340
2489
|
: {}),
|