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.
- package/library.js +3 -16
- package/package.json +1 -1
- 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
|
-
|
|
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
|
|
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,
|