|  |  | @ -2,6 +2,7 @@ import type { Database } from 'bun:sqlite'; | 
			
		
	
		
		
			
				
					
					|  |  |  | import { db } from '../db'; |  |  |  | import { db } from '../db'; | 
			
		
	
		
		
			
				
					
					|  |  |  | import { AllowedGroups } from './allowed-groups'; |  |  |  | import { AllowedGroups } from './allowed-groups'; | 
			
		
	
		
		
			
				
					
					|  |  |  | import { normalizeWhatsAppId, isGroupId } from '../utils/whatsapp'; |  |  |  | import { normalizeWhatsAppId, isGroupId } from '../utils/whatsapp'; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import { Metrics } from './metrics'; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | type AdminContext = { |  |  |  | type AdminContext = { | 
			
		
	
		
		
			
				
					
					|  |  |  |   sender: string;      // normalized user id (digits only)
 |  |  |  |   sender: string;      // normalized user id (digits only)
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -82,7 +83,8 @@ export class AdminService { | 
			
		
	
		
		
			
				
					
					|  |  |  |       if (!isGroupId(ctx.groupId)) { |  |  |  |       if (!isGroupId(ctx.groupId)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return [{ recipient: sender, message: 'ℹ️ Este comando se debe usar dentro de un grupo.' }]; |  |  |  |         return [{ recipient: sender, message: 'ℹ️ Este comando se debe usar dentro de un grupo.' }]; | 
			
		
	
		
		
			
				
					
					|  |  |  |       } |  |  |  |       } | 
			
		
	
		
		
			
				
					
					|  |  |  |       AllowedGroups.setStatus(ctx.groupId, 'allowed'); |  |  |  |       const changed = AllowedGroups.setStatus(ctx.groupId, 'allowed'); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       try { if (changed) Metrics.inc('admin_actions_total_allow'); } catch {} | 
			
		
	
		
		
			
				
					
					|  |  |  |       return [{ recipient: sender, message: `✅ Grupo habilitado: ${ctx.groupId}` }]; |  |  |  |       return [{ recipient: sender, message: `✅ Grupo habilitado: ${ctx.groupId}` }]; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -91,7 +93,8 @@ export class AdminService { | 
			
		
	
		
		
			
				
					
					|  |  |  |       if (!isGroupId(ctx.groupId)) { |  |  |  |       if (!isGroupId(ctx.groupId)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return [{ recipient: sender, message: 'ℹ️ Este comando se debe usar dentro de un grupo.' }]; |  |  |  |         return [{ recipient: sender, message: 'ℹ️ Este comando se debe usar dentro de un grupo.' }]; | 
			
		
	
		
		
			
				
					
					|  |  |  |       } |  |  |  |       } | 
			
		
	
		
		
			
				
					
					|  |  |  |       AllowedGroups.setStatus(ctx.groupId, 'blocked'); |  |  |  |       const changed = AllowedGroups.setStatus(ctx.groupId, 'blocked'); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       try { if (changed) Metrics.inc('admin_actions_total_block'); } catch {} | 
			
		
	
		
		
			
				
					
					|  |  |  |       return [{ recipient: sender, message: `✅ Grupo deshabilitado: ${ctx.groupId}` }]; |  |  |  |       return [{ recipient: sender, message: `✅ Grupo deshabilitado: ${ctx.groupId}` }]; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -101,7 +104,8 @@ export class AdminService { | 
			
		
	
		
		
			
				
					
					|  |  |  |       if (!isGroupId(arg)) { |  |  |  |       if (!isGroupId(arg)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return [{ recipient: sender, message: '⚠️ Debes indicar un group_id válido terminado en @g.us' }]; |  |  |  |         return [{ recipient: sender, message: '⚠️ Debes indicar un group_id válido terminado en @g.us' }]; | 
			
		
	
		
		
			
				
					
					|  |  |  |       } |  |  |  |       } | 
			
		
	
		
		
			
				
					
					|  |  |  |       AllowedGroups.setStatus(arg, 'allowed'); |  |  |  |       const changed = AllowedGroups.setStatus(arg, 'allowed'); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       try { if (changed) Metrics.inc('admin_actions_total_allow'); } catch {} | 
			
		
	
		
		
			
				
					
					|  |  |  |       return [{ recipient: sender, message: `✅ Grupo habilitado: ${arg}` }]; |  |  |  |       return [{ recipient: sender, message: `✅ Grupo habilitado: ${arg}` }]; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -111,7 +115,8 @@ export class AdminService { | 
			
		
	
		
		
			
				
					
					|  |  |  |       if (!isGroupId(arg)) { |  |  |  |       if (!isGroupId(arg)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return [{ recipient: sender, message: '⚠️ Debes indicar un group_id válido terminado en @g.us' }]; |  |  |  |         return [{ recipient: sender, message: '⚠️ Debes indicar un group_id válido terminado en @g.us' }]; | 
			
		
	
		
		
			
				
					
					|  |  |  |       } |  |  |  |       } | 
			
		
	
		
		
			
				
					
					|  |  |  |       AllowedGroups.setStatus(arg, 'blocked'); |  |  |  |       const changed = AllowedGroups.setStatus(arg, 'blocked'); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       try { if (changed) Metrics.inc('admin_actions_total_block'); } catch {} | 
			
		
	
		
		
			
				
					
					|  |  |  |       return [{ recipient: sender, message: `✅ Grupo bloqueado: ${arg}` }]; |  |  |  |       return [{ recipient: sender, message: `✅ Grupo bloqueado: ${arg}` }]; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |