nodebb-plugin-onekite-calendar 1.0.20 → 1.0.21
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/CHANGELOG.md +2 -0
- package/lib/api.js +37 -4
- package/package.json +1 -1
- package/plugin.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
- Suppression du texte d’archivage dans le toast de purge (plus de « 0 archivés »)
|
|
5
5
|
- Renommage du plugin : nodebb-plugin-onekite-calendar
|
|
6
6
|
- Discord : notification « ❌ Réservation annulée » (annulation manuelle + annulation automatique) + option ACP
|
|
7
|
+
- Groupes ACP : les champs CSV acceptent aussi ; et retours à la ligne
|
|
8
|
+
- Notifications email (groupes) : résolution robuste nom/slug et normalisation des membres (uids)
|
|
7
9
|
|
|
8
10
|
## 1.0.2
|
|
9
11
|
- Purge calendrier : suppression réelle des réservations (aucune logique d’archivage)
|
package/lib/api.js
CHANGED
|
@@ -20,6 +20,27 @@ async function getMembersByGroupIdentifier(groupIdentifier) {
|
|
|
20
20
|
const id = String(groupIdentifier || '').trim();
|
|
21
21
|
if (!id) return [];
|
|
22
22
|
|
|
23
|
+
const toUids = (arr) => {
|
|
24
|
+
if (!Array.isArray(arr)) return [];
|
|
25
|
+
// NodeBB may return an array of uids (numbers/strings), or an array of user objects (with uid).
|
|
26
|
+
const uids = arr.map((v) => {
|
|
27
|
+
if (v == null) return null;
|
|
28
|
+
if (typeof v === 'number') return v;
|
|
29
|
+
if (typeof v === 'string') {
|
|
30
|
+
const n = parseInt(v, 10);
|
|
31
|
+
return Number.isFinite(n) ? n : null;
|
|
32
|
+
}
|
|
33
|
+
if (typeof v === 'object') {
|
|
34
|
+
const maybe = v.uid ?? v.userId ?? v.id;
|
|
35
|
+
const n = parseInt(String(maybe), 10);
|
|
36
|
+
return Number.isFinite(n) ? n : null;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}).filter((n) => Number.isFinite(n));
|
|
40
|
+
// de-dupe
|
|
41
|
+
return [...new Set(uids)];
|
|
42
|
+
};
|
|
43
|
+
|
|
23
44
|
// First try direct.
|
|
24
45
|
let members = [];
|
|
25
46
|
try {
|
|
@@ -27,7 +48,17 @@ async function getMembersByGroupIdentifier(groupIdentifier) {
|
|
|
27
48
|
} catch (e) {
|
|
28
49
|
members = [];
|
|
29
50
|
}
|
|
30
|
-
|
|
51
|
+
const directUids = toUids(members);
|
|
52
|
+
if (directUids.length) return directUids;
|
|
53
|
+
|
|
54
|
+
// Some NodeBB builds expose getMembersByGroupSlug (slug -> uids)
|
|
55
|
+
if (typeof groups.getMembersByGroupSlug === 'function') {
|
|
56
|
+
try {
|
|
57
|
+
const bySlug = await groups.getMembersByGroupSlug(id, 0, -1);
|
|
58
|
+
const bySlugUids = toUids(bySlug);
|
|
59
|
+
if (bySlugUids.length) return bySlugUids;
|
|
60
|
+
} catch (e) {}
|
|
61
|
+
}
|
|
31
62
|
|
|
32
63
|
// Then try slug -> groupName mapping when available.
|
|
33
64
|
if (typeof groups.getGroupNameByGroupSlug === 'function') {
|
|
@@ -50,11 +81,12 @@ async function getMembersByGroupIdentifier(groupIdentifier) {
|
|
|
50
81
|
} catch (e) {
|
|
51
82
|
members = [];
|
|
52
83
|
}
|
|
53
|
-
|
|
84
|
+
const byNameUids = toUids(members);
|
|
85
|
+
if (byNameUids.length) return byNameUids;
|
|
54
86
|
}
|
|
55
87
|
}
|
|
56
88
|
|
|
57
|
-
return
|
|
89
|
+
return [];
|
|
58
90
|
}
|
|
59
91
|
|
|
60
92
|
// Fast membership check without N calls to groups.isMember.
|
|
@@ -88,7 +120,8 @@ function normalizeAllowedGroups(raw) {
|
|
|
88
120
|
if (Array.isArray(parsed)) return parsed.map(v => String(v).trim()).filter(Boolean);
|
|
89
121
|
} catch (e) {}
|
|
90
122
|
}
|
|
91
|
-
|
|
123
|
+
// Accept commas, semicolons, or new lines as separators
|
|
124
|
+
return s.split(/[,;\n]+/).map(v => String(v).trim().replace(/^"+|"+$/g, '')).filter(Boolean);
|
|
92
125
|
}
|
|
93
126
|
|
|
94
127
|
// NOTE: Avoid per-group async checks (groups.isMember) when possible.
|
package/package.json
CHANGED
package/plugin.json
CHANGED