mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-12-02 11:54:04 +01:00
feat: add smirk toggle and more admin capabilities
This commit is contained in:
+14
-1
@@ -354,7 +354,20 @@ HIGH_PENDING_THRESHOLD=10
|
||||
ALERT_COOLDOWN_MS=3600000
|
||||
|
||||
# =============================================================================
|
||||
# SECTION 14: DEVELOPMENT/DEBUG OPTIONS
|
||||
# SECTION 14: SMIRK WALLET INTEGRATION
|
||||
# =============================================================================
|
||||
# Smirk is a browser extension wallet for Wownero/Monero.
|
||||
# https://smirk.network
|
||||
#
|
||||
# Enable this for Wownero mainnet. Disable for Monero stagenet
|
||||
# (Smirk doesn't support stagenet addresses).
|
||||
|
||||
# Enable Smirk wallet connection button (default: true)
|
||||
# Set to false for Monero stagenet deployments
|
||||
SMIRK_ENABLED=true
|
||||
|
||||
# =============================================================================
|
||||
# SECTION 15: DEVELOPMENT/DEBUG OPTIONS
|
||||
# =============================================================================
|
||||
# These are for testing only. Don't use in production with real money!
|
||||
|
||||
|
||||
@@ -1194,7 +1194,9 @@ class GameModeManager {
|
||||
enabled: paymentConfig.earlyEntry?.enabled ?? false,
|
||||
allowInFreeMode: paymentConfig.earlyEntry?.allowInFreeMode ?? false,
|
||||
allowInCreditsMode: paymentConfig.earlyEntry?.allowInCreditsMode ?? false
|
||||
}
|
||||
},
|
||||
// Smirk wallet integration (disabled for Monero stagenet)
|
||||
smirkEnabled: process.env.SMIRK_ENABLED !== 'false'
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -444,7 +444,11 @@ app.get('/api/user/:socketId/payouts', asyncHandler(async (req, res) => {
|
||||
// =============================================================================
|
||||
// Smirk Wallet Authentication Endpoints
|
||||
// =============================================================================
|
||||
// Smirk is a browser extension wallet for Wownero/Monero.
|
||||
// Disable for Monero stagenet deployments (Smirk doesn't support stagenet).
|
||||
const smirkEnabled = process.env.SMIRK_ENABLED !== 'false';
|
||||
|
||||
if (smirkEnabled) {
|
||||
/**
|
||||
* POST /api/auth/smirk/challenge
|
||||
* Generate a challenge for Smirk wallet signature verification
|
||||
@@ -604,6 +608,8 @@ app.get('/api/auth/smirk/status', asyncHandler(async (req, res) => {
|
||||
});
|
||||
}));
|
||||
|
||||
} // End of smirkEnabled block
|
||||
|
||||
// =============================================================================
|
||||
// Admin API Endpoints (requires ADMIN_API_KEY)
|
||||
// =============================================================================
|
||||
@@ -911,6 +917,85 @@ app.post('/api/admin/alerts/test-email', adminAuth, asyncHandler(async (req, res
|
||||
});
|
||||
}));
|
||||
|
||||
// =============================================================================
|
||||
// Admin Queue Management
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* GET /api/admin/queue
|
||||
* Get current queue details for admin dashboard
|
||||
* Returns full queue entries (not anonymized)
|
||||
*/
|
||||
app.get('/api/admin/queue', adminAuth, asyncHandler(async (req, res) => {
|
||||
if (!socketHandlers?.queueManager) {
|
||||
return res.status(503).json({
|
||||
success: false,
|
||||
message: 'Queue manager not available'
|
||||
});
|
||||
}
|
||||
|
||||
const queueDetails = socketHandlers.queueManager.getQueueDetailsForAdmin();
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
queue: queueDetails,
|
||||
count: queueDetails.length
|
||||
});
|
||||
}));
|
||||
|
||||
/**
|
||||
* POST /api/admin/queue/remove
|
||||
* Remove a stuck queue entry by serverId
|
||||
* Body: { serverId: string, reason?: string }
|
||||
*/
|
||||
app.post('/api/admin/queue/remove', adminAuth, asyncHandler(async (req, res) => {
|
||||
const { serverId, reason } = req.body || {};
|
||||
|
||||
if (!serverId || typeof serverId !== 'string') {
|
||||
throw new ValidationError('Missing serverId', {
|
||||
safeMessage: 'serverId is required to remove a queue entry.'
|
||||
});
|
||||
}
|
||||
|
||||
if (!socketHandlers?.queueManager) {
|
||||
return res.status(503).json({
|
||||
success: false,
|
||||
message: 'Queue manager not available'
|
||||
});
|
||||
}
|
||||
|
||||
// Check if entry exists first
|
||||
const isQueued = socketHandlers.queueManager.isPlayerQueued(serverId);
|
||||
if (!isQueued) {
|
||||
return res.status(404).json({
|
||||
success: false,
|
||||
message: `No queue entry found for serverId: ${serverId}`
|
||||
});
|
||||
}
|
||||
|
||||
// Remove the entry
|
||||
const removed = socketHandlers.queueManager.removePlayer(serverId);
|
||||
|
||||
// Log admin action
|
||||
console.log(`[Admin] Queue entry removed: serverId=${serverId}, reason="${reason || 'No reason provided'}", by admin at ${new Date().toISOString()}`);
|
||||
|
||||
// Optionally notify the user via socket (if still connected)
|
||||
try {
|
||||
io.to(serverId).emit('queue_cancelled', {
|
||||
reason: 'admin_removed',
|
||||
message: 'Your queue entry was removed by an administrator.'
|
||||
});
|
||||
} catch (notifyErr) {
|
||||
// Ignore errors - user may be disconnected
|
||||
}
|
||||
|
||||
res.json({
|
||||
success: removed,
|
||||
message: removed ? 'Queue entry removed successfully' : 'Failed to remove queue entry',
|
||||
serverId: serverId
|
||||
});
|
||||
}));
|
||||
|
||||
/**
|
||||
* GET /api/admin/users/search
|
||||
* Search for users by socket ID prefix or payout address
|
||||
|
||||
@@ -288,6 +288,26 @@ class QueueManager {
|
||||
waitingForConfirmation: entry.requiresConfirmation && !entry.confirmed
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full queue details for admin dashboard (not anonymized)
|
||||
* @returns {Array} Full queue entries with all details
|
||||
*/
|
||||
getQueueDetailsForAdmin() {
|
||||
const now = Date.now();
|
||||
return this._waitingPlayers.map((entry, index) => ({
|
||||
position: index + 1,
|
||||
serverId: entry.serverId,
|
||||
playerId: entry.serverId.substring(0, 6), // For display
|
||||
entryTime: entry.entryTime ? new Date(entry.entryTime).toISOString() : null,
|
||||
waitingSeconds: entry.entryTime ? Math.floor((now - entry.entryTime) / 1000) : 0,
|
||||
paymentId: entry.paymentId || null,
|
||||
userId: entry.userId || null,
|
||||
requiresConfirmation: !!entry.requiresConfirmation,
|
||||
confirmed: !!entry.confirmed,
|
||||
isValuable: this._isValuableEntry(entry)
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = QueueManager;
|
||||
|
||||
Reference in New Issue
Block a user