nodebb-plugin-niki-loyalty 1.3.5 → 1.3.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 +39 -30
  2. package/package.json +1 -1
package/library.js CHANGED
@@ -510,36 +510,45 @@ Plugin.addNavigation = async function (nav) {
510
510
  // 🔌 SOCKET IO FONKSİYONLARI
511
511
  // =========================
512
512
  Plugin.adminGetUsers = async function (socket, data) {
513
- // Yetki Kontrolü
514
- const uid = socket.uid;
515
- if (!uid) throw new Error('Giriş yapmalısınız.');
516
-
517
- const isAdmin = await user.isAdministrator(uid);
518
- const isMod = await user.isGlobalModerator(uid);
519
-
520
- if (!isAdmin && !isMod) throw new Error('Yetkisiz Erişim');
521
-
522
- // Tüm kullanıcıları al (limit 500)
523
- const uids = await db.getSortedSetRange('users:joindate', 0, 499);
524
- if (!uids || uids.length === 0) return [];
525
-
526
- // Kullanıcı bilgilerini al
527
- const usersData = await user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'niki_points', 'icon:bgColor']);
528
-
529
- // Puanları olan kullanıcıları filtrele ve sırala
530
- const result = usersData
531
- .map(u => ({
532
- uid: u.uid,
533
- username: u.username,
534
- userslug: u.userslug,
535
- picture: u.picture || '',
536
- iconBg: u['icon:bgColor'] || '#4b5563',
537
- points: parseFloat(u.niki_points || 0)
538
- }))
539
- // .filter(u => u.points > 0) // KALDIRILDI - Tüm kullanıcıları göster
540
- .sort((a, b) => b.points - a.points); // Yüksekten düşüğe sırala
541
-
542
- return result;
513
+ try {
514
+ // Yetki Kontrolü
515
+ const uid = socket.uid;
516
+ if (!uid) throw new Error('Giriş yapmalısınız.');
517
+
518
+ const isAdmin = await user.isAdministrator(uid);
519
+ const isMod = await user.isGlobalModerator(uid);
520
+
521
+ if (!isAdmin && !isMod) throw new Error('Yetkisiz Erişim');
522
+
523
+ // TÜM kullanıcıları al (limit yok: -1)
524
+ const uids = await db.getSortedSetRevRange('users:joindate', 0, -1);
525
+ console.log('[Niki-Admin] Çekilen UID sayısı:', uids ? uids.length : 0);
526
+
527
+ if (!uids || uids.length === 0) return [];
528
+
529
+ // Kullanıcı bilgilerini al
530
+ const usersData = await user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'niki_points', 'icon:bgColor']);
531
+ console.log('[Niki-Admin] Kullanıcı verisi alındı:', usersData ? usersData.length : 0);
532
+
533
+ // Puanları işle ve sırala (puanı yüksek olan önce)
534
+ const result = usersData
535
+ .filter(u => u && u.uid) // Geçersiz kayıtları filtrele
536
+ .map(u => ({
537
+ uid: u.uid,
538
+ username: u.username || 'Bilinmeyen',
539
+ userslug: u.userslug || '',
540
+ picture: u.picture || '',
541
+ iconBg: u['icon:bgColor'] || '#4b5563',
542
+ points: parseFloat(u.niki_points || 0)
543
+ }))
544
+ .sort((a, b) => b.points - a.points); // Yüksekten düşüğe sırala
545
+
546
+ console.log('[Niki-Admin] Döndürülen kullanıcı sayısı:', result.length);
547
+ return result;
548
+ } catch (err) {
549
+ console.error('[Niki-Admin] adminGetUsers HATA:', err.message);
550
+ throw err;
551
+ }
543
552
  };
544
553
 
545
554
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-niki-loyalty",
3
- "version": "1.3.5",
3
+ "version": "1.3.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": {