Skip to content

Commit 8e3ee5d

Browse files
committed
fix(tg-bot): validate license status before PATCH
1 parent 33f3dfc commit 8e3ee5d

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/commands/update.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
const Validator = require('../utils/Validator');
66
const PermissionManager = require('../utils/PermissionManager');
77

8+
const VALID_LICENSE_STATUS_MAP = {
9+
active: 'ACTIVE',
10+
revoked: 'REVOKED',
11+
suspended: 'SUSPENDED',
12+
expired: 'EXPIRED',
13+
};
14+
815
module.exports = {
916
name: 'update',
1017
description: 'Update a license or ticket status (Admin only)',
@@ -36,6 +43,7 @@ module.exports = {
3643
' `/update TKT-1234567890-ABC123 pending`\n' +
3744
' `/update TKT-1234567890-ABC123 closed`\n\n' +
3845
'License Fields: status, plan, expiresAt, issuedTo, issuedEmail\n' +
46+
'License Statuses: ACTIVE, REVOKED, SUSPENDED, EXPIRED\n' +
3947
'Ticket Statuses: open, pending, closed',
4048
{ parse_mode: 'Markdown' }
4149
);
@@ -114,7 +122,13 @@ module.exports = {
114122

115123
// Map field names
116124
if (field === 'status') {
117-
updateData.status = value.toUpperCase();
125+
const normalizedStatus = VALID_LICENSE_STATUS_MAP[String(value).trim().toLowerCase()];
126+
if (!normalizedStatus) {
127+
throw new Error(
128+
'Invalid license status. Use one of: ACTIVE, REVOKED, SUSPENDED, EXPIRED.'
129+
);
130+
}
131+
updateData.status = normalizedStatus;
118132
} else if (field === 'plan') {
119133
updateData.plan = value.toUpperCase();
120134
} else if (field === 'expiresat') {

0 commit comments

Comments
 (0)