nodebb-plugin-calendar-onekite 12.0.10 → 12.0.11

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 (3) hide show
  1. package/lib/api.js +27 -1
  2. package/library.js +2 -0
  3. package/package.json +1 -1
package/lib/api.js CHANGED
@@ -866,4 +866,30 @@ api.cancelReservation = async function (req, res) {
866
866
  return res.json({ ok: true, status: 'cancelled' });
867
867
  };
868
868
 
869
- module.exports = api;
869
+ module.exports = api;
870
+
871
+ api.debugGroupCheck = async function (req, res) {
872
+ try {
873
+ const targetUid = parseInt(String(req.params.uid || ''), 10);
874
+ const group = String(req.params.group || '').trim();
875
+ if (!targetUid || !group) return res.status(400).json({ error: 'missing-params' });
876
+
877
+ const isAdmin = await groups.isMember(req.uid, 'administrators');
878
+ if (!isAdmin) return res.status(403).json({ error: 'not-allowed' });
879
+
880
+ const member = await groups.isMember(targetUid, group);
881
+ const ug = await groups.getUserGroups([targetUid]);
882
+ const userGroups = ug && ug[0] ? ug[0] : [];
883
+ return res.json({
884
+ ok: true,
885
+ callerUid: req.uid,
886
+ targetUid,
887
+ group,
888
+ isMember: member,
889
+ userGroups,
890
+ });
891
+ } catch (e) {
892
+ console.error('[calendar-onekite] debugGroupCheck error', e);
893
+ return res.status(500).json({ error: 'internal-error' });
894
+ }
895
+ };
package/library.js CHANGED
@@ -76,6 +76,8 @@ Plugin.init = async function (params) {
76
76
  router.delete('/api/v3/plugins/calendar-onekite/special-events/:eid', ...publicExpose, api.deleteSpecialEvent);
77
77
 
78
78
  // Admin API (JSON)
79
+ router.get('/api/v3/admin/plugins/calendar-onekite/debug/groups/:uid/:group', ...adminMws, api.debugGroupCheck);
80
+
79
81
  const adminBases = ['/api/v3/admin/plugins/calendar-onekite'];
80
82
 
81
83
  adminBases.forEach((base) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-calendar-onekite",
3
- "version": "12.0.10",
3
+ "version": "12.0.11",
4
4
  "description": "FullCalendar-based equipment reservation workflow with admin approval & HelloAsso payment for NodeBB",
5
5
  "main": "library.js",
6
6
  "license": "MIT",