nodebb-plugin-ezoic-infinite 1.5.13 → 1.5.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 (3) hide show
  1. package/library.js +3 -16
  2. package/package.json +1 -1
  3. package/public/client.js +747 -530
package/library.js CHANGED
@@ -66,21 +66,9 @@ async function getSettings() {
66
66
  }
67
67
 
68
68
  async function isUserExcluded(uid, excludedGroups) {
69
- // Note: uid can be 0 for guests; treat 0 as a valid user id here.
70
- if (uid === undefined || uid === null || !excludedGroups.length) return false;
71
-
72
- const excludedSet = new Set(excludedGroups.map(g => String(g).toLowerCase()));
73
- // Guests: NodeBB often represents them as uid=0 and they may not have groups in the database.
74
- if (uid === 0) {
75
- return excludedSet.has('guests') || excludedSet.has('guest');
76
- }
77
-
78
-
69
+ if (!uid || !excludedGroups.length) return false;
79
70
  const userGroups = await groups.getUserGroups([uid]);
80
- return (userGroups[0] || []).some(g => {
81
- const name = (g && g.name) ? g.name : g;
82
- return excludedSet.has(String(name).toLowerCase());
83
- });
71
+ return (userGroups[0] || []).some(g => excludedGroups.includes(g.name));
84
72
  }
85
73
 
86
74
 
@@ -120,8 +108,7 @@ plugin.init = async ({ router, middleware }) => {
120
108
 
121
109
  router.get('/api/plugins/ezoic-infinite/config', async (req, res) => {
122
110
  const settings = await getSettings();
123
- const uid = (typeof req.uid === 'number' ? req.uid : (req.user && typeof req.user.uid === 'number' ? req.user.uid : (res.locals && typeof res.locals.uid === 'number' ? res.locals.uid : 0)));
124
- const excluded = await isUserExcluded(uid, settings.excludedGroups);
111
+ const excluded = await isUserExcluded(req.uid, settings.excludedGroups);
125
112
 
126
113
  res.json({
127
114
  excluded,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.5.13",
3
+ "version": "1.5.16",
4
4
  "description": "Production-ready Ezoic infinite ads integration for NodeBB 4.x",
5
5
  "main": "library.js",
6
6
  "license": "MIT",