nodebb-plugin-onekite-calendar 2.0.77 → 2.0.78

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/lib/api.js CHANGED
@@ -1404,7 +1404,6 @@ api.createReservation = async function (req, res) {
1404
1404
  try {
1405
1405
  const notifyGroups = normalizeAllowedGroups(settings.notifyGroups);
1406
1406
  if (notifyGroups.length) {
1407
- const requester = await user.getUserFields(uid, ['username', 'email']);
1408
1407
  const itemsLabel = (resv.itemNames || []).join(', ');
1409
1408
  for (const g of notifyGroups) {
1410
1409
  const members = await getMembersByGroupIdentifier(g);
@@ -1436,15 +1435,14 @@ api.createReservation = async function (req, res) {
1436
1435
  await sendEmail('calendar-onekite_pending', u, 'Location matériel - Demande de réservation', {
1437
1436
  uid: u,
1438
1437
  username: md && md.username ? md.username : '',
1439
- requester: requester.username,
1438
+ requester: targetUsername,
1439
+ createdBy: isForSelf ? '' : (creatorUsername || ''),
1440
1440
  itemName: itemsLabel,
1441
1441
  itemNames: resv.itemNames || [],
1442
1442
  dateRange: `Du ${formatFR(start)} au ${formatFR(end)}`,
1443
1443
  start: formatFR(start),
1444
1444
  end: formatFR(end),
1445
1445
  total: resv.total || 0,
1446
- // Link to the plugin ACP page so managers can process the request quickly.
1447
- // Kept as `adminUrl` to match the email template placeholder.
1448
1446
  adminUrl: `${forumBaseUrl()}/admin/plugins/calendar-onekite`,
1449
1447
  });
1450
1448
  }
@@ -1455,6 +1453,23 @@ api.createReservation = async function (req, res) {
1455
1453
  console.warn('[calendar-onekite] Failed to send pending email', e && e.message ? e.message : e);
1456
1454
  }
1457
1455
 
1456
+ // Notify target user when a validator created the reservation on their behalf
1457
+ if (!isForSelf) {
1458
+ try {
1459
+ await sendEmail('calendar-onekite_pending_for_you', targetUid, 'Location matériel - Demande créée en votre nom', {
1460
+ uid: targetUid,
1461
+ username: targetUsername,
1462
+ createdBy: creatorUsername,
1463
+ itemName: (resv.itemNames || []).join(', '),
1464
+ itemNames: resv.itemNames || [],
1465
+ dateRange: `Du ${formatFR(start)} au ${formatFR(end)}`,
1466
+ total: resv.total || 0,
1467
+ });
1468
+ } catch (e) {
1469
+ console.warn('[calendar-onekite] Failed to send pending_for_you email', e && e.message ? e.message : e);
1470
+ }
1471
+ }
1472
+
1458
1473
  // Discord webhook (optional)
1459
1474
  try {
1460
1475
  await discord.notifyReservationRequested(settings, {
@@ -1471,6 +1486,24 @@ api.createReservation = async function (req, res) {
1471
1486
 
1472
1487
  }
1473
1488
 
1489
+ // When a validator explicitly regularizes a reservation for another user (directly paid,
1490
+ // no HelloAsso), the main notification block is skipped. Still notify the target user.
1491
+ if (isRegularization && !isForSelf) {
1492
+ try {
1493
+ await sendEmail('calendar-onekite_paid', targetUid, 'Location matériel - Réservation confirmée', {
1494
+ uid: targetUid,
1495
+ username: targetUsername,
1496
+ itemName: (resv.itemNames || []).join(', '),
1497
+ itemNames: resv.itemNames || [],
1498
+ dateRange: `Du ${formatFR(start)} au ${formatFR(end)}`,
1499
+ icsUrl: '',
1500
+ googleCalUrl: '',
1501
+ });
1502
+ } catch (e) {
1503
+ console.warn('[calendar-onekite] Failed to send regularization paid email', e && e.message ? e.message : e);
1504
+ }
1505
+ }
1506
+
1474
1507
  res.json({ ok: true, rid, status: resv.status, autoPaid: isAutoPaid });
1475
1508
  };
1476
1509
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-onekite-calendar",
3
- "version": "2.0.77",
3
+ "version": "2.0.78",
4
4
  "description": "FullCalendar-based equipment reservation workflow with admin approval & HelloAsso payment for NodeBB",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
@@ -3,6 +3,10 @@
3
3
 
4
4
  <p><strong>Demandeur :</strong> {requester}</p>
5
5
 
6
+ <!-- IF createdBy -->
7
+ <p><strong>Créée par :</strong> {createdBy}</p>
8
+ <!-- ENDIF createdBy -->
9
+
6
10
  <p><strong>Matériel</strong></p>
7
11
  <ul>
8
12
  <!-- BEGIN itemNames -->
@@ -0,0 +1,15 @@
1
+ <p>Bonjour {username},</p>
2
+ <p>Une demande de réservation de matériel a été créée en votre nom par {createdBy}.</p>
3
+
4
+ <p><strong>Matériel</strong></p>
5
+ <ul>
6
+ <!-- BEGIN itemNames -->
7
+ <li>{itemNames}</li>
8
+ <!-- END itemNames -->
9
+ </ul>
10
+
11
+ <p>{dateRange}</p>
12
+
13
+ <p><strong>Total estimé :</strong> {total} €</p>
14
+
15
+ <p>Vous recevrez un email avec les instructions de paiement une fois la demande validée par un responsable.</p>