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.
- package/library.js +39 -30
- 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
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
.
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
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
|
|