nodebb-plugin-niki-loyalty 1.5.5 → 1.5.7

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/library.js +40 -25
  2. package/package.json +1 -1
package/library.js CHANGED
@@ -32,7 +32,7 @@ const ACTIONS = {
32
32
  // Grup Katılım Bonusları
33
33
  const GROUP_BONUSES = {
34
34
  'Premium': 30,
35
- 'VIP': 50,
35
+ 'VIP': 60,
36
36
  };
37
37
 
38
38
  // Ödüller
@@ -221,33 +221,48 @@ Plugin.onUpvote = async function (data) {
221
221
  // 5. GRUP KATILIM BONUSU (Premium / VIP)
222
222
  Plugin.onGroupJoin = async function (data) {
223
223
  try {
224
- const groupName = data.groupName;
225
- const uid = data.uid;
226
- if (!groupName || !uid) return;
227
-
228
- const bonus = GROUP_BONUSES[groupName];
229
- if (!bonus) return; // Bu grup için bonus tanımlı değil
230
-
231
- // Aynı gruba tekrar katılırsa çift puan vermesin
232
- const flagKey = `niki:group_bonus:${uid}:${groupName}`;
233
- const alreadyClaimed = await db.get(flagKey);
234
- if (alreadyClaimed) {
235
- return;
236
- }
224
+ if (!data) return;
225
+
226
+ // NodeBB sürümüne göre groupName string veya array gelebilir
227
+ const groupNames = Array.isArray(data.groupName) ? data.groupName
228
+ : data.groupNames ? (Array.isArray(data.groupNames) ? data.groupNames : [data.groupNames])
229
+ : data.groupName ? [data.groupName]
230
+ : [];
231
+
232
+ // uid tek veya array olabilir (ACP toplu ekleme)
233
+ const uids = Array.isArray(data.uid) ? data.uid : data.uid ? [data.uid] : [];
234
+
235
+ for (const rawGroupName of groupNames) {
236
+ if (!rawGroupName) continue;
237
+
238
+ // Grup adını GROUP_BONUSES'da bul (case-insensitive)
239
+ let matchedGroup = null;
240
+ let bonus = 0;
241
+ for (const key of Object.keys(GROUP_BONUSES)) {
242
+ if (key.toLowerCase() === String(rawGroupName).toLowerCase()) {
243
+ matchedGroup = key;
244
+ bonus = GROUP_BONUSES[key];
245
+ break;
246
+ }
247
+ }
248
+ if (!matchedGroup || !bonus) continue;
237
249
 
238
- await user.incrementUserFieldBy(uid, 'niki_points', bonus);
239
- await db.set(flagKey, '1');
240
- await addUserLog(uid, 'earn', bonus, `${groupName} Grubu Katılım Bonusu 🎉`);
250
+ for (const uid of uids) {
251
+ if (!uid) continue;
241
252
 
242
- // Socket bildirimi
243
- try {
244
- if (socketHelpers && socketHelpers.server && socketHelpers.server.sockets) {
245
- socketHelpers.server.sockets.in('uid_' + uid).emit('event:niki_award', {
246
- title: 'Grup Bonusu! 🎉',
247
- message: `${groupName} grubuna katıldığın için <strong style="color:#ffd700">+${bonus} Puan</strong> kazandın!`,
248
- });
253
+ await user.incrementUserFieldBy(uid, 'niki_points', bonus);
254
+ await addUserLog(uid, 'earn', bonus, `${matchedGroup} Grubu Katılım Bonusu 🎉`);
255
+
256
+ try {
257
+ if (socketHelpers && socketHelpers.server && socketHelpers.server.sockets) {
258
+ socketHelpers.server.sockets.in('uid_' + uid).emit('event:niki_award', {
259
+ title: 'Grup Bonusu! 🎉',
260
+ message: `${matchedGroup} grubuna katıldığın için <strong style="color:#ffd700">+${bonus} Puan</strong> kazandın!`,
261
+ });
262
+ }
263
+ } catch (socketErr) {
264
+ }
249
265
  }
250
- } catch (socketErr) {
251
266
  }
252
267
  } catch (err) {
253
268
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-niki-loyalty",
3
- "version": "1.5.5",
3
+ "version": "1.5.7",
4
4
  "description": "Niki The Cat Coffee Loyalty System - Earn points while studying on IEU Forum.",
5
5
  "main": "library.js",
6
6
  "nbbpm": {