nodebb-plugin-calendar-onekite 12.0.14 → 12.0.16

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.
Files changed (2) hide show
  1. package/lib/api.js +28 -8
  2. package/package.json +1 -1
package/lib/api.js CHANGED
@@ -137,9 +137,19 @@ function toTs(v) {
137
137
  if (typeof v === 'number') return v;
138
138
  const s = String(v).trim();
139
139
  if (/^[0-9]+$/.test(s)) return parseInt(s, 10);
140
+
141
+ // IMPORTANT: Date-only strings like "2026-01-09" are interpreted as UTC by JS Date(),
142
+ // which can create 1h overlaps in Europe/Paris (and other TZs) between consecutive days.
143
+ // We treat date-only inputs as local-midnight by appending a time component.
144
+ if (/^\d{4}-\d{2}-\d{2}$/.test(s)) {
145
+ const dLocal = new Date(s + 'T00:00:00');
146
+ return dLocal.getTime();
147
+ }
148
+
140
149
  const d = new Date(s);
141
150
  return d.getTime();
142
151
  }
152
+ }
143
153
 
144
154
  function yearFromTs(ts) {
145
155
  const d = new Date(Number(ts));
@@ -205,11 +215,11 @@ function autoFormSlugForYear(year) {
205
215
  }
206
216
 
207
217
  async function canRequest(uid, settings, startTs) {
208
- if (!uid) return { ok: false, allowed: [], candidates: [], startTs };
218
+ if (!uid) return false;
209
219
 
210
220
  // Always allow administrators to create.
211
221
  try {
212
- if (await groups.isMember(uid, 'administrators')) return { ok: true, allowed: [], candidates: [], startTs };
222
+ if (await groups.isMember(uid, 'administrators')) return true;
213
223
  } catch (e) {}
214
224
 
215
225
  const year = yearFromTs(startTs);
@@ -219,13 +229,23 @@ async function canRequest(uid, settings, startTs) {
219
229
  const raw = settings.creatorGroups ?? settings.allowedGroups ?? [];
220
230
  const extraGroups = normalizeAllowedGroups(raw);
221
231
 
222
- const allowed = [defaultGroup, ...extraGroups].filter(Boolean);
232
+ const allowedSlugs = [...new Set([defaultGroup, ...extraGroups].filter(Boolean))];
223
233
 
224
- const chk = await checkAnyMembership(uid, allowed, 'canRequest');
225
- if (chk.ok) return { ok: true, allowed, candidates: chk.candidates, startTs };
226
-
227
- logger.warn('[calendar-onekite] not-allowed in canRequest', { uid, startTs, allowed, candidates: chk.candidates, raw });
228
- return { ok: false, allowed, candidates: chk.candidates, startTs };
234
+ // Use getUserGroups (returns group objects) and compare slugs.
235
+ try {
236
+ const ug = await groups.getUserGroups([uid]);
237
+ const list = (ug && ug[0]) ? ug[0] : [];
238
+ const userSlugs = list.map(g => (g && g.slug) ? String(g.slug) : '').filter(Boolean);
239
+ return allowedSlugs.some(s => userSlugs.includes(s));
240
+ } catch (e) {
241
+ // Fallback: try isMember on each allowed slug (some installs accept slug)
242
+ for (const g of allowedSlugs) {
243
+ try {
244
+ if (await groups.isMember(uid, g)) return true;
245
+ } catch (err) {}
246
+ }
247
+ return false;
248
+ }
229
249
  }
230
250
 
231
251
  async function canValidate(uid, settings) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-calendar-onekite",
3
- "version": "12.0.14",
3
+ "version": "12.0.16",
4
4
  "description": "FullCalendar-based equipment reservation workflow with admin approval & HelloAsso payment for NodeBB",
5
5
  "main": "library.js",
6
6
  "license": "MIT",