Maintenance mode activates after current draw completes

- When admin enables maintenance, it's set to 'pending' state
- Maintenance activates automatically after the current draw completes
- Admin can use immediate=true to force immediate activation
- Frontend shows 'Maintenance Scheduled' banner when pending
- Telegram bot warns users but still allows purchases when pending
- Both mode and pending status tracked in system_settings table
This commit is contained in:
Michilis
2025-12-09 00:46:55 +00:00
parent 0eb8a6c580
commit 404fdf2610
12 changed files with 474 additions and 4 deletions

View File

@@ -3,7 +3,9 @@ import {
listCycles,
runDrawManually,
retryPayout,
listPayouts
listPayouts,
getMaintenanceStatus,
setMaintenanceMode
} from '../controllers/admin';
import { verifyAdmin } from '../middleware/auth';
@@ -126,5 +128,78 @@ router.get('/payouts', listPayouts);
*/
router.post('/payouts/:id/retry', retryPayout);
/**
* @swagger
* /admin/maintenance:
* get:
* summary: Get maintenance mode status
* tags: [Admin]
* security:
* - adminKey: []
* responses:
* 200:
* description: Maintenance status
* content:
* application/json:
* schema:
* type: object
* properties:
* maintenance_mode:
* type: boolean
* message:
* type: string
* 403:
* description: Invalid admin key
*/
router.get('/maintenance', getMaintenanceStatus);
/**
* @swagger
* /admin/maintenance:
* post:
* summary: Enable or disable maintenance mode
* description: When enabling, maintenance is set to "pending" and activates after current draw completes. Use immediate=true to activate immediately.
* tags: [Admin]
* security:
* - adminKey: []
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - enabled
* properties:
* enabled:
* type: boolean
* description: Whether to enable maintenance mode
* message:
* type: string
* description: Custom maintenance message
* immediate:
* type: boolean
* description: If true, activate immediately instead of waiting for draw to complete
* responses:
* 200:
* description: Maintenance mode updated
* content:
* application/json:
* schema:
* type: object
* properties:
* maintenance_mode:
* type: boolean
* maintenance_pending:
* type: boolean
* message:
* type: string
* 400:
* description: Invalid input
* 403:
* description: Invalid admin key
*/
router.post('/maintenance', setMaintenanceMode);
export default router;