Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
feat(dashboard): add location/contact/sticker/poll/forward/bulk to Message Tester (#813)
Yudhi Armyndharisc2a6d0e64432
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ee2bf9450..7909ef7f6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -29,6 +29,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0trap with initial focus, background scroll lock, and `role="dialog"` semantics. The Sessions pagemodals are the first to use it, gaining those behaviors plus a pinned header/footer with ascrolling body on long content.+- The dashboard Message Tester now covers every outbound message type: in addition to+ text/image/video/audio/document it can send location, contact-card, sticker, and native poll+ messages, forward an existing message to another chat, and submit a bulk text batch (recipients+ one per line, optional inter-message delay) with live batch progress polling and a cancel control+ in the response panel.### Changeddiff --git a/dashboard/src/i18n/locales/ar.json b/dashboard/src/i18n/locales/ar.jsonindex cf93a7869..eb0e9d720 100644--- a/dashboard/src/i18n/locales/ar.json+++ b/dashboard/src/i18n/locales/ar.json@@ -518,7 +518,13 @@"image": "صورة","video": "فيديو","audio": "صوت",- "document": "مستند"+ "document": "مستند",+ "location": "موقع",+ "contact": "جهة اتصال",+ "sticker": "ملصق",+ "poll": "استطلاع",+ "forward": "إعادة توجيه",+ "bulk": "جماعي"},"messageContent": "محتوى الرسالة","messagePlaceholder": "أدخل رسالتك هنا...",@@ -532,6 +538,34 @@"filename": "اسم الملف","captionPlaceholder": "أدخل التعليق...","filenamePlaceholder": "document.pdf",+ "locationLatitude": "خط العرض",+ "locationLongitude": "خط الطول",+ "locationDescription": "الوصف",+ "locationAddress": "العنوان",+ "contactName": "اسم جهة الاتصال",+ "contactNamePlaceholder": "Jane Doe",+ "contactNumber": "رقم جهة الاتصال",+ "pollQuestion": "سؤال الاستطلاع",+ "pollQuestionPlaceholder": "أين نلتقي؟",+ "pollOptions": "خيارات الاستطلاع",+ "pollOptionPlaceholder": "الخيار {{index}}",+ "pollOptionsHint": "بين 2 و12 خيارًا",+ "addOption": "إضافة خيار",+ "removeOption": "إزالة الخيار",+ "allowMultipleAnswers": "السماح بإجابات متعددة",+ "forwardFromChatId": "معرّف الدردشة المصدر",+ "forwardFromPlaceholder": "[email protected]",+ "forwardFromHint": "اتركه فارغًا لإعادة التوجيه من المستلم الحالي",+ "forwardToChatId": "معرّف الدردشة الوجهة",+ "forwardToPlaceholder": "رقم الهاتف أو معرّف الدردشة",+ "forwardMessageId": "معرّف الرسالة",+ "forwardMessageIdHint": "معرّف الرسالة المراد إعادة توجيهها",+ "bulkRecipients": "المستلمون",+ "bulkRecipientsPlaceholder": "+62812345678",+ "bulkRecipientsHint": "رقم هاتف أو معرّف دردشة واحد في كل سطر (100 كحد أقصى)",+ "bulkRecipientsCount": "المستلمون: {{count}}",+ "bulkDelay": "التأخير بين الرسائل (مللي ثانية)",+ "bulkDelayHint": "1000–60000 مللي ثانية (الافتراضي 3000)","send": "إرسال الرسالة","sending": "جارٍ الإرسال...","viewOnly": "للعرض فقط",@@ -541,10 +575,23 @@"response": {"timestamp": "الوقت","messageId": "معرّف الرسالة",+ "batchId": "معرّف الدفعة","error": "خطأ"},"sendFailed": "فشل إرسال الرسالة",- "notOnWhatsApp": "هذا الرقم غير مسجَّل على واتساب"+ "notOnWhatsApp": "هذا الرقم غير مسجَّل على واتساب",+ "batch": {+ "status": {+ "pending": "قيد الانتظار",+ "processing": "قيد المعالجة",+ "completed": "مكتمل",+ "cancelled": "ملغى",+ "failed": "فشل"+ },+ "progress": "تم إرسال {{sent}} من {{total}} · {{failed}} فشلت · {{pending}} قيد الانتظار",+ "cancel": "إلغاء الدفعة",+ "cancelling": "جارٍ الإلغاء..."+ }},"infrastructure": {"title": "البنية التحتية",diff --git a/dashboard/src/i18n/locales/en.json b/dashboard/src/i18n/locales/en.jsonindex 9bbc9c7c2..afeceafb9 100644--- a/dashboard/src/i18n/locales/en.json+++ b/dashboard/src/i18n/locales/en.json@@ -514,7 +514,13 @@"image": "Image","video": "Video","audio": "Audio",- "document": "Document"+ "document": "Document",+ "location": "Location",+ "contact": "Contact",+ "sticker": "Sticker",+ "poll": "Poll",+ "forward": "Forward",+ "bulk": "Bulk"},"messageContent": "Message Content","messagePlaceholder": "Enter your message here...",@@ -528,6 +534,34 @@"filename": "Filename","captionPlaceholder": "Enter caption...","filenamePlaceholder": "document.pdf",+ "locationLatitude": "Latitude",+ "locationLongitude": "Longitude",+ "locationDescription": "Description",+ "locationAddress": "Address",+ "contactName": "Contact Name",+ "contactNamePlaceholder": "Jane Doe",+ "contactNumber": "Contact Number",+ "pollQuestion": "Poll Question",+ "pollQuestionPlaceholder": "Where should we meet?",+ "pollOptions": "Poll Options",+ "pollOptionPlaceholder": "Option {{index}}",+ "pollOptionsHint": "Between 2 and 12 options",+ "addOption": "Add Option",+ "removeOption": "Remove option",+ "allowMultipleAnswers": "Allow multiple answers",+ "forwardFromChatId": "From Chat ID",+ "forwardFromPlaceholder": "[email protected]",+ "forwardFromHint": "Leave empty to forward from the current recipient",+ "forwardToChatId": "To Chat ID",+ "forwardToPlaceholder": "Phone number or chat ID",+ "forwardMessageId": "Message ID",+ "forwardMessageIdHint": "ID of the message to forward",+ "bulkRecipients": "Recipients",+ "bulkRecipientsPlaceholder": "+62812345678",+ "bulkRecipientsHint": "One phone number or chat ID per line (max 100)",+ "bulkRecipientsCount": "Recipients: {{count}}",+ "bulkDelay": "Delay Between Messages (ms)",+ "bulkDelayHint": "1000–60000 ms (default 3000)","send": "Send Message","sending": "Sending...","viewOnly": "View Only",@@ -537,10 +571,23 @@"response": {"timestamp": "Timestamp","messageId": "Message ID",+ "batchId": "Batch ID","error": "Error"},"sendFailed": "Failed to send message",- "notOnWhatsApp": "This number is not registered on WhatsApp"+ "notOnWhatsApp": "This number is not registered on WhatsApp",+ "batch": {+ "status": {+ "pending": "Pending",+ "processing": "Processing",+ "completed": "Completed",+ "cancelled": "Cancelled",+ "failed": "Failed"+ },+ "progress": "Sent {{sent}} of {{total}} · {{failed}} failed · {{pending}} pending",+ "cancel": "Cancel Batch",+ "cancelling": "Cancelling..."+ }},"infrastructure": {"title": "Infrastructure",diff --git a/dashboard/src/i18n/locales/es.json b/dashboard/src/i18n/locales/es.jsonindex f32f45dfc..e02247a66 100644--- a/dashboard/src/i18n/locales/es.json+++ b/dashboard/src/i18n/locales/es.json@@ -469,7 +469,13 @@"image": "Imagen","video": "Vídeo","audio": "Audio",- "document": "Documento"+ "document": "Documento",+ "location": "Ubicación",+ "contact": "Contacto",+ "sticker": "Sticker",+ "poll": "Encuesta",+ "forward": "Reenviar",+ "bulk": "Masivo"},"messageContent": "Contenido del mensaje","messagePlaceholder": "Escribe tu mensaje aquí...",@@ -483,6 +489,34 @@"filename": "Nombre de archivo","captionPlaceholder": "Escribe un pie de foto...","filenamePlaceholder": "documento.pdf",+ "locationLatitude": "Latitud",+ "locationLongitude": "Longitud",+ "locationDescription": "Descripción",+ "locationAddress": "Dirección",+ "contactName": "Nombre del contacto",+ "contactNamePlaceholder": "Jane Doe",+ "contactNumber": "Número del contacto",+ "pollQuestion": "Pregunta de la encuesta",+ "pollQuestionPlaceholder": "¿Dónde nos reunimos?",+ "pollOptions": "Opciones de la encuesta",+ "pollOptionPlaceholder": "Opción {{index}}",+ "pollOptionsHint": "Entre 2 y 12 opciones",+ "addOption": "Añadir opción",+ "removeOption": "Quitar opción",+ "allowMultipleAnswers": "Permitir varias respuestas",+ "forwardFromChatId": "ID del chat de origen",+ "forwardFromPlaceholder": "[email protected]",+ "forwardFromHint": "Déjalo vacío para reenviar desde el destinatario actual",+ "forwardToChatId": "ID del chat de destino",+ "forwardToPlaceholder": "Número de teléfono o ID de chat",+ "forwardMessageId": "ID del mensaje",+ "forwardMessageIdHint": "ID del mensaje que se va a reenviar",+ "bulkRecipients": "Destinatarios",+ "bulkRecipientsPlaceholder": "+62812345678",+ "bulkRecipientsHint": "Un número de teléfono o ID de chat por línea (máx. 100)",+ "bulkRecipientsCount": "Destinatarios: {{count}}",+ "bulkDelay": "Retraso entre mensajes (ms)",+ "bulkDelayHint": "1000–60000 ms (predeterminado: 3000)","send": "Enviar mensaje","sending": "Enviando...","viewOnly": "Solo lectura",@@ -492,10 +526,23 @@"response": {"timestamp": "Fecha/Hora","messageId": "ID de mensaje",+ "batchId": "ID del lote","error": "Error"},"sendFailed": "Error al enviar el mensaje",- "notOnWhatsApp": "Este número no está registrado en WhatsApp"+ "notOnWhatsApp": "Este número no está registrado en WhatsApp",+ "batch": {+ "status": {+ "pending": "Pendiente",+ "processing": "Procesando",+ "completed": "Completado",+ "cancelled": "Cancelado",+ "failed": "Fallido"+ },+ "progress": "Enviados {{sent}} de {{total}} · {{failed}} fallidos · {{pending}} pendientes",+ "cancel": "Cancelar lote",+ "cancelling": "Cancelando..."+ }},"templates": {"title": "Plantillas",diff --git a/dashboard/src/i18n/locales/fr.json b/dashboard/src/i18n/locales/fr.jsonindex a36409865..4e2fee6ad 100644--- a/dashboard/src/i18n/locales/fr.json+++ b/dashboard/src/i18n/locales/fr.json@@ -514,7 +514,13 @@"image": "Image","video": "Vidéo","audio": "Audio",- "document": "Document"+ "document": "Document",+ "location": "Localisation",+ "contact": "Contact",+ "sticker": "Sticker",+ "poll": "Sondage",+ "forward": "Transférer",+ "bulk": "En masse"},"messageContent": "Contenu du message","messagePlaceholder": "Entrez votre message ici...",@@ -528,6 +534,34 @@"filename": "Nom du fichier","captionPlaceholder": "Entrez une légende...","filenamePlaceholder": "document.pdf",+ "locationLatitude": "Latitude",+ "locationLongitude": "Longitude",+ "locationDescription": "Description",+ "locationAddress": "Adresse",+ "contactName": "Nom du contact",+ "contactNamePlaceholder": "Jane Doe",+ "contactNumber": "Numéro du contact",+ "pollQuestion": "Question du sondage",+ "pollQuestionPlaceholder": "Où devrions-nous nous retrouver ?",+ "pollOptions": "Options du sondage",+ "pollOptionPlaceholder": "Option {{index}}",+ "pollOptionsHint": "Entre 2 et 12 options",+ "addOption": "Ajouter une option",+ "removeOption": "Supprimer l'option",+ "allowMultipleAnswers": "Autoriser les réponses multiples",+ "forwardFromChatId": "ID du chat source",+ "forwardFromPlaceholder": "[email protected]",+ "forwardFromHint": "Laisser vide pour transférer depuis le destinataire actuel",+ "forwardToChatId": "ID du chat de destination",+ "forwardToPlaceholder": "Numéro de téléphone ou ID de chat",+ "forwardMessageId": "ID du message",+ "forwardMessageIdHint": "ID du message à transférer",+ "bulkRecipients": "Destinataires",+ "bulkRecipientsPlaceholder": "+62812345678",+ "bulkRecipientsHint": "Un numéro de téléphone ou ID de chat par ligne (max 100)",+ "bulkRecipientsCount": "Destinataires : {{count}}",+ "bulkDelay": "Délai entre les messages (ms)",+ "bulkDelayHint": "1000–60000 ms (par défaut : 3000)","send": "Envoyer le message","sending": "Envoi...","viewOnly": "Lecture seule",@@ -537,10 +571,23 @@"response": {"timestamp": "Horodatage","messageId": "ID du message",+ "batchId": "ID du lot","error": "Erreur"},"sendFailed": "Échec de l'envoi du message",- "notOnWhatsApp": "Ce numéro n'est pas enregistré sur WhatsApp"+ "notOnWhatsApp": "Ce numéro n'est pas enregistré sur WhatsApp",+ "batch": {+ "status": {+ "pending": "En attente",+ "processing": "En cours",+ "completed": "Terminé",+ "cancelled": "Annulé",+ "failed": "Échoué"+ },+ "progress": "Envoyés {{sent}} sur {{total}} · {{failed}} échoués · {{pending}} en attente",+ "cancel": "Annuler le lot",+ "cancelling": "Annulation..."+ }},"infrastructure": {"title": "Infrastructure",diff --git a/dashboard/src/i18n/locales/he.json b/dashboard/src/i18n/locales/he.jsonindex 9cde1f361..22e9eae08 100644--- a/dashboard/src/i18n/locales/he.json+++ b/dashboard/src/i18n/locales/he.json@@ -515,7 +515,13 @@"image": "תמונה","video": "וידאו","audio": "אודיו",- "document": "מסמך"+ "document": "מסמך",+ "location": "מיקום",+ "contact": "איש קשר",+ "sticker": "מדבקה",+ "poll": "סקר",+ "forward": "העברה",+ "bulk": "מרובה"},"messageContent": "תוכן ההודעה","messagePlaceholder": "יש להזין כאן את ההודעה...",@@ -529,6 +535,34 @@"filename": "שם קובץ","captionPlaceholder": "יש להזין כיתוב...","filenamePlaceholder": "document.pdf",+ "locationLatitude": "קו רוחב",+ "locationLongitude": "קו אורך",+ "locationDescription": "תיאור",+ "locationAddress": "כתובת",+ "contactName": "שם איש הקשר",+ "contactNamePlaceholder": "ישראל ישראלי",+ "contactNumber": "מספר איש הקשר",+ "pollQuestion": "שאלת הסקר",+ "pollQuestionPlaceholder": "איפה ניפגש?",+ "pollOptions": "אפשרויות הסקר",+ "pollOptionPlaceholder": "אפשרות {{index}}",+ "pollOptionsHint": "בין 2 ל-12 אפשרויות",+ "addOption": "הוספת אפשרות",+ "removeOption": "הסרת אפשרות",+ "allowMultipleAnswers": "לאפשר מספר תשובות",+ "forwardFromChatId": "מזהה צ'אט מקור",+ "forwardFromPlaceholder": "[email protected]",+ "forwardFromHint": "השאר ריק כדי להעביר מהנמען הנוכחי",+ "forwardToChatId": "מזהה צ'אט יעד",+ "forwardToPlaceholder": "מספר טלפון או מזהה צ'אט",+ "forwardMessageId": "מזהה הודעה",+ "forwardMessageIdHint": "מזהה ההודעה להעברה",+ "bulkRecipients": "נמענים",+ "bulkRecipientsPlaceholder": "+62812345678",+ "bulkRecipientsHint": "מספר טלפון או מזהה צ'אט אחד בכל שורה (עד 100)",+ "bulkRecipientsCount": "נמענים: {{count}}",+ "bulkDelay": "השהיה בין הודעות (אלפיות שנייה)",+ "bulkDelayHint": "1000–60000 אלפיות שנייה (ברירת מחדל 3000)","send": "שליחת הודעה","sending": "שולח...","viewOnly": "צפייה בלבד",@@ -538,10 +572,23 @@"response": {"timestamp": "חותמת זמן","messageId": "מזהה הודעה",+ "batchId": "מזהה אצווה","error": "שגיאה"},"sendFailed": "שליחת ההודעה נכשלה",- "notOnWhatsApp": "מספר זה אינו רשום בוואטסאפ"+ "notOnWhatsApp": "מספר זה אינו רשום בוואטסאפ",+ "batch": {+ "status": {+ "pending": "ממתין",+ "processing": "מעבד",+ "completed": "הושלם",+ "cancelled": "בוטל",+ "failed": "נכשל"+ },+ "progress": "נשלחו {{sent}} מתוך {{total}} · {{failed}} נכשלו · {{pending}} ממתינים",+ "cancel": "ביטול אצווה",+ "cancelling": "מבטל..."+ }},"infrastructure": {"title": "תשתית",diff --git a/dashboard/src/i18n/locales/it.json b/dashboard/src/i18n/locales/it.jsonindex b967d658f..7158efb57 100644--- a/dashboard/src/i18n/locales/it.json+++ b/dashboard/src/i18n/locales/it.json@@ -514,7 +514,13 @@"image": "Immagine","video": "Video","audio": "Audio",- "document": "Documento"+ "document": "Documento",+ "location": "Posizione",+ "contact": "Contatto",+ "sticker": "Sticker",+ "poll": "Sondaggio",+ "forward": "Inoltra",+ "bulk": "Multiplo"},"messageContent": "Contenuto del Messaggio","messagePlaceholder": "Inserisci qui il tuo messaggio...",@@ -528,6 +534,34 @@"filename": "Nome File","captionPlaceholder": "Inserisci una didascalia...","filenamePlaceholder": "documento.pdf",+ "locationLatitude": "Latitudine",+ "locationLongitude": "Longitudine",+ "locationDescription": "Descrizione",+ "locationAddress": "Indirizzo",+ "contactName": "Nome del contatto",+ "contactNamePlaceholder": "Jane Doe",+ "contactNumber": "Numero del contatto",+ "pollQuestion": "Domanda del sondaggio",+ "pollQuestionPlaceholder": "Dove dovremmo incontrarci?",+ "pollOptions": "Opzioni del sondaggio",+ "pollOptionPlaceholder": "Opzione {{index}}",+ "pollOptionsHint": "Tra 2 e 12 opzioni",+ "addOption": "Aggiungi opzione",+ "removeOption": "Rimuovi opzione",+ "allowMultipleAnswers": "Consenti risposte multiple",+ "forwardFromChatId": "ID chat di origine",+ "forwardFromPlaceholder": "[email protected]",+ "forwardFromHint": "Lascia vuoto per inoltrare dal destinatario corrente",+ "forwardToChatId": "ID chat di destinazione",+ "forwardToPlaceholder": "Numero di telefono o ID chat",+ "forwardMessageId": "ID messaggio",+ "forwardMessageIdHint": "ID del messaggio da inoltrare",+ "bulkRecipients": "Destinatari",+ "bulkRecipientsPlaceholder": "+62812345678",+ "bulkRecipientsHint": "Un numero di telefono o ID chat per riga (max 100)",+ "bulkRecipientsCount": "Destinatari: {{count}}",+ "bulkDelay": "Ritardo tra i messaggi (ms)",+ "bulkDelayHint": "1000–60000 ms (predefinito: 3000)","send": "Invia Messaggio","sending": "Invio in corso...","viewOnly": "Sola Visualizzazione",@@ -537,10 +571,23 @@"response": {"timestamp": "Timestamp","messageId": "ID Messaggio",+ "batchId": "ID batch","error": "Errore"},"sendFailed": "Impossibile inviare il messaggio",- "notOnWhatsApp": "Questo numero non è registrato su WhatsApp"+ "notOnWhatsApp": "Questo numero non è registrato su WhatsApp",+ "batch": {+ "status": {+ "pending": "In attesa",+ "processing": "In elaborazione",+ "completed": "Completato",+ "cancelled": "Annullato",+ "failed": "Non riuscito"+ },+ "progress": "Inviati {{sent}} di {{total}} · {{failed}} non riusciti · {{pending}} in attesa",+ "cancel": "Annulla batch",+ "cancelling": "Annullamento..."+ }},"infrastructure": {"title": "Infrastruttura",diff --git a/dashboard/src/i18n/locales/ko.json b/dashboard/src/i18n/locales/ko.jsonindex e07eee5bf..09066bf17 100644--- a/dashboard/src/i18n/locales/ko.json+++ b/dashboard/src/i18n/locales/ko.json@@ -514,7 +514,13 @@"image": "이미지","video": "동영상","audio": "오디오",- "document": "문서"+ "document": "문서",+ "location": "위치",+ "contact": "연락처",+ "sticker": "스티커",+ "poll": "투표",+ "forward": "전달",+ "bulk": "대량"},"messageContent": "메시지 내용","messagePlaceholder": "메시지를 입력하세요...",@@ -528,6 +534,34 @@"filename": "파일 이름","captionPlaceholder": "설명을 입력하세요...","filenamePlaceholder": "document.pdf",+ "locationLatitude": "위도",+ "locationLongitude": "경도",+ "locationDescription": "설명",+ "locationAddress": "주소",+ "contactName": "연락처 이름",+ "contactNamePlaceholder": "홍길동",+ "contactNumber": "연락처 번호",+ "pollQuestion": "투표 질문",+ "pollQuestionPlaceholder": "어디서 만날까요?",+ "pollOptions": "투표 옵션",+ "pollOptionPlaceholder": "옵션 {{index}}",+ "pollOptionsHint": "2~12개의 옵션",+ "addOption": "옵션 추가",+ "removeOption": "옵션 삭제",+ "allowMultipleAnswers": "복수 응답 허용",+ "forwardFromChatId": "보내는 채팅 ID",+ "forwardFromPlaceholder": "[email protected]",+ "forwardFromHint": "비워 두면 현재 수신자에서 전달합니다",+ "forwardToChatId": "받는 채팅 ID",+ "forwardToPlaceholder": "전화번호 또는 채팅 ID",+ "forwardMessageId": "메시지 ID",+ "forwardMessageIdHint": "전달할 메시지의 ID",+ "bulkRecipients": "수신자",+ "bulkRecipientsPlaceholder": "+62812345678",+ "bulkRecipientsHint": "한 줄에 하나의 전화번호 또는 채팅 ID (최대 100개)",+ "bulkRecipientsCount": "수신자: {{count}}",+ "bulkDelay": "메시지 간 지연 (ms)",+ "bulkDelayHint": "1000–60000ms (기본값 3000)","send": "메시지 보내기","sending": "보내는 중...","viewOnly": "읽기 전용",@@ -537,10 +571,23 @@"response": {"timestamp": "타임스탬프","messageId": "메시지 ID",+ "batchId": "배치 ID","error": "오류"},"sendFailed": "메시지를 보내지 못했습니다",- "notOnWhatsApp": "이 번호는 WhatsApp에 등록되어 있지 않습니다"+ "notOnWhatsApp": "이 번호는 WhatsApp에 등록되어 있지 않습니다",+ "batch": {+ "status": {+ "pending": "대기 중",+ "processing": "처리 중",+ "completed": "완료됨",+ "cancelled": "취소됨",+ "failed": "실패"+ },+ "progress": "{{total}}개 중 {{sent}}개 전송됨 · {{failed}}개 실패 · {{pending}}개 대기 중",+ "cancel": "배치 취소",+ "cancelling": "취소 중..."+ }},"infrastructure": {"title": "인프라",diff --git a/dashboard/src/i18n/locales/pt-BR.json b/dashboard/src/i18n/locales/pt-BR.jsonindex 83dc73036..c1a45b1b8 100644--- a/dashboard/src/i18n/locales/pt-BR.json+++ b/dashboard/src/i18n/locales/pt-BR.json@@ -469,7 +469,13 @@"image": "Imagem","video": "Vídeo","audio": "Áudio",- "document": "Documento"+ "document": "Documento",+ "location": "Localização",+ "contact": "Contato",+ "sticker": "Figurinha",+ "poll": "Enquete",+ "forward": "Encaminhar",+ "bulk": "Em massa"},"messageContent": "Conteúdo da mensagem","messagePlaceholder": "Digite sua mensagem aqui...",@@ -483,6 +489,34 @@"filename": "Nome do arquivo","captionPlaceholder": "Digite uma legenda...","filenamePlaceholder": "documento.pdf",+ "locationLatitude": "Latitude",+ "locationLongitude": "Longitude",+ "locationDescription": "Descrição",+ "locationAddress": "Endereço",+ "contactName": "Nome do contato",+ "contactNamePlaceholder": "Jane Doe",+ "contactNumber": "Número do contato",+ "pollQuestion": "Pergunta da enquete",+ "pollQuestionPlaceholder": "Onde devemos nos encontrar?",+ "pollOptions": "Opções da enquete",+ "pollOptionPlaceholder": "Opção {{index}}",+ "pollOptionsHint": "Entre 2 e 12 opções",+ "addOption": "Adicionar opção",+ "removeOption": "Remover opção",+ "allowMultipleAnswers": "Permitir várias respostas",+ "forwardFromChatId": "ID do chat de origem",+ "forwardFromPlaceholder": "[email protected]",+ "forwardFromHint": "Deixe vazio para encaminhar a partir do destinatário atual",+ "forwardToChatId": "ID do chat de destino",+ "forwardToPlaceholder": "Número de telefone ou ID do chat",+ "forwardMessageId": "ID da mensagem",+ "forwardMessageIdHint": "ID da mensagem a ser encaminhada",+ "bulkRecipients": "Destinatários",+ "bulkRecipientsPlaceholder": "+62812345678",+ "bulkRecipientsHint": "Um número de telefone ou ID de chat por linha (máx. 100)",+ "bulkRecipientsCount": "Destinatários: {{count}}",+ "bulkDelay": "Intervalo entre mensagens (ms)",+ "bulkDelayHint": "1000–60000 ms (padrão: 3000)","send": "Enviar mensagem","sending": "Enviando...","viewOnly": "Somente leitura",@@ -492,10 +526,23 @@"response": {"timestamp": "Data/Hora","messageId": "ID da mensagem",+ "batchId": "ID do lote","error": "Erro"},"sendFailed": "Erro ao enviar a mensagem",- "notOnWhatsApp": "Este número não está registrado no WhatsApp"+ "notOnWhatsApp": "Este número não está registrado no WhatsApp",+ "batch": {+ "status": {+ "pending": "Pendente",+ "processing": "Processando",+ "completed": "Concluído",+ "cancelled": "Cancelado",+ "failed": "Falhou"+ },+ "progress": "Enviadas {{sent}} de {{total}} · {{failed}} falharam · {{pending}} pendentes",+ "cancel": "Cancelar lote",+ "cancelling": "Cancelando..."+ }},"templates": {"title": "Modelos",diff --git a/dashboard/src/i18n/locales/te.json b/dashboard/src/i18n/locales/te.jsonindex 9489dd6d8..c62a178d7 100644--- a/dashboard/src/i18n/locales/te.json+++ b/dashboard/src/i18n/locales/te.json@@ -514,7 +514,13 @@"image": "చిత్రం (Image)","video": "వీడియో","audio": "ఆడియో",- "document": "డాక్యుమెంట్"+ "document": "డాక్యుమెంట్",+ "location": "స్థానం",+ "contact": "పరిచయం",+ "sticker": "స్టిక్కర్",+ "poll": "పోల్",+ "forward": "ఫార్వార్డ్",+ "bulk": "బల్క్"},"messageContent": "సందేశం కంటెంట్","messagePlaceholder": "మీ సందేశాన్ని ఇక్కడ ఎంటర్ చేయండి...",@@ -528,6 +534,34 @@"filename": "ఫైల్ పేరు","captionPlaceholder": "క్యాప్షన్ ఎంటర్ చేయండి...","filenamePlaceholder": "document.pdf",+ "locationLatitude": "అక్షాంశం",+ "locationLongitude": "రేఖాంశం",+ "locationDescription": "వివరణ",+ "locationAddress": "చిరునామా",+ "contactName": "పరిచయ పేరు",+ "contactNamePlaceholder": "Jane Doe",+ "contactNumber": "పరిచయ నంబర్",+ "pollQuestion": "పోల్ ప్రశ్న",+ "pollQuestionPlaceholder": "మనం ఎక్కడ కలవాలి?",+ "pollOptions": "పోల్ ఎంపికలు",+ "pollOptionPlaceholder": "ఎంపిక {{index}}",+ "pollOptionsHint": "2 నుండి 12 ఎంపికలు",+ "addOption": "ఎంపికను జోడించండి",+ "removeOption": "ఎంపికను తొలగించండి",+ "allowMultipleAnswers": "బహుళ సమాధానాలను అనుమతించండి",+ "forwardFromChatId": "మూల చాట్ ID",+ "forwardFromPlaceholder": "[email protected]",+ "forwardFromHint": "ప్రస్తుత గ్రహీత నుండి ఫార్వార్డ్ చేయడానికి ఖాళీగా ఉంచండి",+ "forwardToChatId": "గమ్య చాట్ ID",+ "forwardToPlaceholder": "ఫోన్ నంబర్ లేదా చాట్ ID",+ "forwardMessageId": "సందేశ ID",+ "forwardMessageIdHint": "ఫార్వార్డ్ చేయాల్సిన సందేశం యొక్క ID",+ "bulkRecipients": "గ్రహీతలు",+ "bulkRecipientsPlaceholder": "+62812345678",+ "bulkRecipientsHint": "ఒక్కో లైన్లో ఒక ఫోన్ నంబర్ లేదా చాట్ ID (గరిష్టంగా 100)",+ "bulkRecipientsCount": "గ్రహీతలు: {{count}}",+ "bulkDelay": "సందేశాల మధ్య విరామం (ms)",+ "bulkDelayHint": "1000–60000 ms (డిఫాల్ట్ 3000)","send": "సందేశం పంపు","sending": "పంపుతోంది...","viewOnly": "చూడటానికి మాత్రమే",@@ -537,10 +571,23 @@"response": {"timestamp": "సమయము","messageId": "సందేశం ID",+ "batchId": "బ్యాచ్ ID","error": "లోపం"},"sendFailed": "సందేశాన్ని పంపడం విఫలమైంది",- "notOnWhatsApp": "ఈ నంబర్ WhatsAppలో నమోదు కాలేదు"+ "notOnWhatsApp": "ఈ నంబర్ WhatsAppలో నమోదు కాలేదు",+ "batch": {+ "status": {+ "pending": "పెండింగ్",+ "processing": "ప్రాసెస్ అవుతోంది",+ "completed": "పూర్తయింది",+ "cancelled": "రద్దు చేయబడింది",+ "failed": "విఫలమైంది"+ },+ "progress": "{{total}}లో {{sent}} పంపబడ్డాయి · {{failed}} విఫలమయ్యాయి · {{pending}} పెండింగ్లో ఉన్నాయి",+ "cancel": "బ్యాచ్ను రద్దు చేయండి",+ "cancelling": "రద్దు చేస్తోంది..."+ }},"infrastructure": {"title": "ఇన్ఫ్రాస్ట్రక్చర్",diff --git a/dashboard/src/i18n/locales/zh-CN.json b/dashboard/src/i18n/locales/zh-CN.jsonindex 845920d2b..064d3881a 100644--- a/dashboard/src/i18n/locales/zh-CN.json+++ b/dashboard/src/i18n/locales/zh-CN.json@@ -514,7 +514,13 @@"image": "图片","video": "视频","audio": "音频",- "document": "文档"+ "document": "文档",+ "location": "位置",+ "contact": "联系人",+ "sticker": "贴纸",+ "poll": "投票",+ "forward": "转发",+ "bulk": "批量"},"messageContent": "消息内容","messagePlaceholder": "在此输入你的消息...",@@ -528,6 +534,34 @@"filename": "文件名","captionPlaceholder": "输入说明文字...","filenamePlaceholder": "document.pdf",+ "locationLatitude": "纬度",+ "locationLongitude": "经度",+ "locationDescription": "描述",+ "locationAddress": "地址",+ "contactName": "联系人姓名",+ "contactNamePlaceholder": "张三",+ "contactNumber": "联系人号码",+ "pollQuestion": "投票问题",+ "pollQuestionPlaceholder": "我们在哪里见面?",+ "pollOptions": "投票选项",+ "pollOptionPlaceholder": "选项 {{index}}",+ "pollOptionsHint": "2 到 12 个选项",+ "addOption": "添加选项",+ "removeOption": "删除选项",+ "allowMultipleAnswers": "允许多选",+ "forwardFromChatId": "来源聊天 ID",+ "forwardFromPlaceholder": "[email protected]",+ "forwardFromHint": "留空则从当前接收者转发",+ "forwardToChatId": "目标聊天 ID",+ "forwardToPlaceholder": "电话号码或聊天 ID",+ "forwardMessageId": "消息 ID",+ "forwardMessageIdHint": "要转发的消息 ID",+ "bulkRecipients": "接收者",+ "bulkRecipientsPlaceholder": "+62812345678",+ "bulkRecipientsHint": "每行一个电话号码或聊天 ID(最多 100 个)",+ "bulkRecipientsCount": "接收者:{{count}}",+ "bulkDelay": "消息间隔延迟(毫秒)",+ "bulkDelayHint": "1000–60000 毫秒(默认 3000)","send": "发送消息","sending": "正在发送...","viewOnly": "仅查看",@@ -537,10 +571,23 @@"response": {"timestamp": "时间戳","messageId": "消息 ID",+ "batchId": "批次 ID","error": "错误"},"sendFailed": "发送消息失败",- "notOnWhatsApp": "该号码未在 WhatsApp 注册"+ "notOnWhatsApp": "该号码未在 WhatsApp 注册",+ "batch": {+ "status": {+ "pending": "等待中",+ "processing": "处理中",+ "completed": "已完成",+ "cancelled": "已取消",+ "failed": "失败"+ },+ "progress": "已发送 {{sent}}/{{total}} · {{failed}} 失败 · {{pending}} 待发送",+ "cancel": "取消批次",+ "cancelling": "取消中..."+ }},"infrastructure": {"title": "基础设施",diff --git a/dashboard/src/i18n/locales/zh-HK.json b/dashboard/src/i18n/locales/zh-HK.jsonindex e48d031bc..4f162fa76 100644--- a/dashboard/src/i18n/locales/zh-HK.json+++ b/dashboard/src/i18n/locales/zh-HK.json@@ -514,7 +514,13 @@"image": "圖片","video": "影片","audio": "音訊",- "document": "文件"+ "document": "文件",+ "location": "位置",+ "contact": "聯絡人",+ "sticker": "貼圖",+ "poll": "投票",+ "forward": "轉發",+ "bulk": "批量"},"messageContent": "訊息內容","messagePlaceholder": "在此輸入你的訊息...",@@ -528,6 +534,34 @@"filename": "檔案名稱","captionPlaceholder": "輸入說明文字...","filenamePlaceholder": "document.pdf",+ "locationLatitude": "緯度",+ "locationLongitude": "經度",+ "locationDescription": "描述",+ "locationAddress": "地址",+ "contactName": "聯絡人姓名",+ "contactNamePlaceholder": "陳大文",+ "contactNumber": "聯絡人號碼",+ "pollQuestion": "投票問題",+ "pollQuestionPlaceholder": "我們在哪裏見面?",+ "pollOptions": "投票選項",+ "pollOptionPlaceholder": "選項 {{index}}",+ "pollOptionsHint": "2 至 12 個選項",+ "addOption": "新增選項",+ "removeOption": "移除選項",+ "allowMultipleAnswers": "允許多選",+ "forwardFromChatId": "來源對話 ID",+ "forwardFromPlaceholder": "[email protected]",+ "forwardFromHint": "留空則從目前收件人轉發",+ "forwardToChatId": "目標對話 ID",+ "forwardToPlaceholder": "電話號碼或對話 ID",+ "forwardMessageId": "訊息 ID",+ "forwardMessageIdHint": "要轉發的訊息 ID",+ "bulkRecipients": "收件人",+ "bulkRecipientsPlaceholder": "+62812345678",+ "bulkRecipientsHint": "每行一個電話號碼或對話 ID(最多 100 個)",+ "bulkRecipientsCount": "收件人:{{count}}",+ "bulkDelay": "訊息之間的延遲(毫秒)",+ "bulkDelayHint": "1000–60000 毫秒(預設 3000)","send": "傳送訊息","sending": "正在傳送...","viewOnly": "僅檢視",@@ -537,10 +571,23 @@"response": {"timestamp": "時間戳記","messageId": "訊息 ID",+ "batchId": "批次 ID","error": "錯誤"},"sendFailed": "傳送訊息失敗",- "notOnWhatsApp": "此號碼未在 WhatsApp 註冊"+ "notOnWhatsApp": "此號碼未在 WhatsApp 註冊",+ "batch": {+ "status": {+ "pending": "等候中",+ "processing": "處理中",+ "completed": "已完成",+ "cancelled": "已取消",+ "failed": "失敗"+ },+ "progress": "已發送 {{sent}}/{{total}} · {{failed}} 失敗 · {{pending}} 待發送",+ "cancel": "取消批次",+ "cancelling": "取消中..."+ }},"infrastructure": {"title": "基礎架構",diff --git a/dashboard/src/pages/MessageTester.css b/dashboard/src/pages/MessageTester.cssindex 3246a929f..4e34ef36d 100644--- a/dashboard/src/pages/MessageTester.css+++ b/dashboard/src/pages/MessageTester.css@@ -273,6 +273,200 @@text-decoration: underline;}+/* The 11-entry message-type selector wraps as pills instead of squeezing into one row. */+.message-tester .toggle-group.toggle-group-wrap {+ flex-wrap: wrap;+ gap: 0.375rem;+ border: none;+ overflow: visible;+}++.message-tester .toggle-group.toggle-group-wrap button {+ flex: 1 1 30%;+ border: 1px solid var(--border);+ border-radius: 6px;+}++.message-tester .toggle-group.toggle-group-wrap button.active {+ border-color: var(--primary);+}++/* Side-by-side pair (location latitude/longitude). */+.message-tester .form-row {+ display: grid;+ grid-template-columns: 1fr 1fr;+ gap: 1rem;+}++.message-tester .poll-option-row {+ display: flex;+ align-items: center;+ gap: 0.5rem;+ margin-bottom: 0.5rem;+}++.message-tester .poll-option-row input {+ flex: 1;+}++.message-tester .remove-option-btn {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ flex-shrink: 0;+ width: 2rem;+ height: 2rem;+ color: var(--error);+ background: none;+ border: 1px solid var(--border);+ border-radius: var(--radius);+ cursor: pointer;+}++.message-tester .remove-option-btn:hover:not(:disabled) {+ border-color: var(--error);+}++.message-tester .remove-option-btn:disabled {+ opacity: 0.4;+ cursor: not-allowed;+}++.message-tester .add-option-btn {+ display: inline-flex;+ align-items: center;+ gap: 0.375rem;+ padding: 0.5rem 0.875rem;+ font-size: 0.8125rem;+ font-weight: 500;+ color: var(--text-secondary);+ background: var(--bg-white);+ border: 1px solid var(--border);+ border-radius: var(--radius);+ cursor: pointer;+ transition: all 0.2s;+}++.message-tester .add-option-btn:hover:not(:disabled) {+ border-color: var(--primary);+ color: var(--primary);+}++.message-tester .add-option-btn:disabled {+ opacity: 0.5;+ cursor: not-allowed;+}++/* Inline checkbox row (poll multiple answers) — undo the stacked uppercase label treatment. */+.message-tester .form-group label.checkbox-label {+ display: flex;+ align-items: center;+ gap: 0.5rem;+ font-size: 0.875rem;+ font-weight: 500;+ text-transform: none;+ letter-spacing: normal;+ color: var(--text-primary);+ margin-bottom: 0;+ cursor: pointer;+}++.message-tester .form-group label.checkbox-label input[type='checkbox'] {+ width: auto;+ margin: 0;+}++/* Bulk batch progress block in the response panel. */+.message-tester .batch-status {+ margin-bottom: 1rem;+ padding: 0.875rem 1rem;+ background: var(--bg-light);+ border: 1px solid var(--border);+ border-radius: var(--radius);+}++.message-tester .batch-status-row {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 0.75rem;+ margin-bottom: 0.625rem;+}++.message-tester .batch-badge {+ padding: 0.125rem 0.625rem;+ font-size: 0.75rem;+ font-weight: 600;+ border-radius: 999px;+ text-transform: capitalize;+}++.message-tester .batch-badge.pending,+.message-tester .batch-badge.processing {+ background: rgba(59, 130, 246, 0.12);+ color: #3b82f6;+}++.message-tester .batch-badge.completed {+ background: rgba(37, 211, 102, 0.12);+ color: var(--primary);+}++.message-tester .batch-badge.failed {+ background: rgba(239, 68, 68, 0.12);+ color: var(--error);+}++.message-tester .batch-badge.cancelled {+ background: rgba(100, 116, 139, 0.12);+ color: var(--text-secondary);+}++.message-tester .batch-progress-bar {+ height: 6px;+ background: var(--border);+ border-radius: 999px;+ overflow: hidden;+}++.message-tester .batch-progress-fill {+ height: 100%;+ background: var(--primary);+ transition: width 0.3s;+}++.message-tester .batch-progress-line {+ margin-top: 0.5rem;+ font-size: 0.8125rem;+ color: var(--text-secondary);+}++.message-tester .batch-cancel-btn {+ padding: 0.25rem 0.75rem;+ font-size: 0.75rem;+ font-weight: 600;+ color: var(--error);+ background: none;+ border: 1px solid var(--error);+ border-radius: var(--radius);+ cursor: pointer;+}++.message-tester .batch-cancel-btn:hover:not(:disabled) {+ background: rgba(239, 68, 68, 0.08);+}++.message-tester .batch-cancel-btn:disabled {+ opacity: 0.6;+ cursor: not-allowed;+}++.message-tester .batch-error {+ margin-top: 0.5rem;+ font-size: 0.8125rem;+ color: var(--error);+}+@media (max-width: 1000px) {.message-tester .tester-panels {grid-template-columns: 1fr;diff --git a/dashboard/src/pages/MessageTester.tsx b/dashboard/src/pages/MessageTester.tsxindex 917d298ad..6c05d78b6 100644--- a/dashboard/src/pages/MessageTester.tsx+++ b/dashboard/src/pages/MessageTester.tsx@@ -1,16 +1,26 @@import { useState, useEffect, useRef, type ChangeEvent } from 'react';import { useTranslation } from 'react-i18next';-import { Send, CheckCircle, XCircle, Loader2, Upload, X } from 'lucide-react';-import { messageApi, contactApi, type SendMediaPayload } from '../services/api';+import { Send, CheckCircle, XCircle, Loader2, Upload, X, Plus } from 'lucide-react';+import {+ messageApi,+ contactApi,+ type SendMediaPayload,+ type MessageResponse,+ type BatchStatus,+ type BatchStatusResponse,+} from '../services/api';import { useDocumentTitle } from '../hooks/useDocumentTitle';import { useRole } from '../hooks/useRole';import { useSessionsQuery, useSessionGroupsQuery } from '../hooks/queries';+import { parseBulkRecipients, BULK_MAX_RECIPIENTS } from '../utils/bulkRecipients';import { PageHeader } from '../components/PageHeader';import './MessageTester.css';interface ApiResponse {success: boolean;messageId?: string;+ /** Bulk sends return 202 + a batch instead of a messageId; the panel polls its progress. */+ batchId?: string;timestamp: string;error?: string;// The real HTTP status, carried on the Error by `request()` in services/api.ts. Absent when no@@ -19,7 +29,22 @@ interface ApiResponse {status?: number;}-const messageTypes = ['text', 'image', 'video', 'audio', 'document'] as const;+const messageTypes = [+ 'text',+ 'image',+ 'video',+ 'audio',+ 'document',+ 'location',+ 'contact',+ 'sticker',+ 'poll',+ 'forward',+ 'bulk',+] as const;++// The types that share the media upload/URL block (base64 XOR url + mimetype).+const mediaMessageTypes: readonly string[] = ['image', 'video', 'audio', 'document', 'sticker'];// Hint the native file picker at the right category (documents accept anything).const mediaAccept: Record<(typeof messageTypes)[number], string> = {@@ -28,6 +53,12 @@ const mediaAccept: Record<(typeof messageTypes)[number], string> = {video: 'video/*',audio: 'audio/*',document: '*/*',+ location: '*/*',+ contact: '*/*',+ sticker: 'image/*',+ poll: '*/*',+ forward: '*/*',+ bulk: '*/*',};// Fallback MIME for when the browser leaves File.type empty (some extensions). The backend requires a@@ -38,6 +69,12 @@ const fallbackMime: Record<(typeof messageTypes)[number], string> = {video: 'video/mp4',audio: 'audio/mpeg',document: 'application/octet-stream',+ location: 'application/octet-stream',+ contact: 'application/octet-stream',+ sticker: 'image/webp',+ poll: 'application/octet-stream',+ forward: 'application/octet-stream',+ bulk: 'application/octet-stream',};// Client pre-check before base64-encoding an upload. Aligned with the default request-body limit: base64@@ -46,6 +83,9 @@ const fallbackMime: Record<(typeof messageTypes)[number], string> = {// backend's MEDIA_DOWNLOAD_MAX_BYTES (default 50 MiB) stays authoritative for URL sends (fetched server-side).const MEDIA_UPLOAD_MAX_BYTES = 18 * 1024 * 1024;+// Batch statuses that stop the progress polling (mirrors the backend BatchStatus enum).+const TERMINAL_BATCH_STATUSES: readonly BatchStatus[] = ['completed', 'cancelled', 'failed'];+export function MessageTester() {const { t } = useTranslation();useDocumentTitle(t('messageTester.title'));@@ -56,20 +96,41 @@ export function MessageTester() {const [recipient, setRecipient] = useState('');const [recipientType, setRecipientType] = useState<'personal' | 'group'>('personal');const [selectedGroup, setSelectedGroup] = useState('');- const [messageType, setMessageType] = useState<typeof messageTypes[number]>('text');+ const [messageType, setMessageType] = useState<(typeof messageTypes)[number]>('text');const [content, setContent] = useState('');const [mediaUrl, setMediaUrl] = useState('');// A locally-picked media file, read as raw base64 (the engine contract — NOT a data: URI). Mutually// exclusive with mediaUrl: picking a file clears the URL field; typing a URL drops the file.const [mediaFile, setMediaFile] = useState<{ base64: string; mimetype: string; filename: string } | null>(null);const fileInputRef = useRef<HTMLInputElement>(null);+ // Per-type fields for the non-media types; text/media keep using `content`/`mediaUrl` above.+ const [latitude, setLatitude] = useState('');+ const [longitude, setLongitude] = useState('');+ const [locationDescription, setLocationDescription] = useState('');+ const [locationAddress, setLocationAddress] = useState('');+ const [contactName, setContactName] = useState('');+ const [contactNumber, setContactNumber] = useState('');+ const [pollQuestion, setPollQuestion] = useState('');+ // WhatsApp caps polls at 2..12 options; rows are trimmed and empty ones dropped at send time.+ const [pollOptions, setPollOptions] = useState<string[]>(['', '']);+ const [allowMultipleAnswers, setAllowMultipleAnswers] = useState(false);+ const [forwardFrom, setForwardFrom] = useState('');+ const [forwardTo, setForwardTo] = useState('');+ const [forwardMessageId, setForwardMessageId] = useState('');+ const [bulkRecipients, setBulkRecipients] = useState('');+ const [bulkDelay, setBulkDelay] = useState('');const [isLoading, setIsLoading] = useState(false);const [response, setResponse] = useState<ApiResponse | null>(null);+ // Live bulk-batch progress, polled every ~2s while the batch runs (see startBatchPolling).+ const [batchStatus, setBatchStatus] = useState<BatchStatusResponse | null>(null);+ const [batchCancelling, setBatchCancelling] = useState(false);+ const [batchError, setBatchError] = useState<string | null>(null);+ const batchPollRef = useRef<ReturnType<typeof setInterval> | null>(null);+ // The session a running batch belongs to: the user may switch the selector mid-batch, and+ // poll/cancel must keep addressing the session the batch was created on.+ const batchSessionRef = useRef('');- const { data: groups = [], isLoading: loadingGroups } = useSessionGroupsQuery(- session,- recipientType === 'group',- );+ const { data: groups = [], isLoading: loadingGroups } = useSessionGroupsQuery(session, recipientType === 'group');useEffect(() => {if (sessions.length > 0 && !session) {@@ -92,6 +153,44 @@ export function MessageTester() {}}, [groups, selectedGroup, recipientType]);+ const stopBatchPolling = () => {+ if (batchPollRef.current) {+ clearInterval(batchPollRef.current);+ batchPollRef.current = null;+ }+ };++ // Stop polling on unmount; the batch itself keeps running server-side regardless.+ useEffect(() => stopBatchPolling, []);++ const startBatchPolling = (batchSessionId: string, batchId: string) => {+ stopBatchPolling();+ batchPollRef.current = setInterval(async () => {+ try {+ const status = await messageApi.getBatchStatus(batchSessionId, batchId);+ setBatchStatus(status);+ if (TERMINAL_BATCH_STATUSES.includes(status.status)) stopBatchPolling();+ } catch {+ // A transient poll failure (network blip, backend restart) must not kill progress tracking.+ }+ }, 2000);+ };++ const handleCancelBatch = async () => {+ if (!batchStatus || !batchSessionRef.current) return;+ setBatchCancelling(true);+ setBatchError(null);+ try {+ const status = await messageApi.cancelBatch(batchSessionRef.current, batchStatus.batchId);+ setBatchStatus(prev => (prev ? { ...prev, ...status } : prev));+ stopBatchPolling();+ } catch (err) {+ setBatchError(err instanceof Error ? err.message : t('messageTester.sendFailed'));+ } finally {+ setBatchCancelling(false);+ }+ };+const handleFileChange = (e: ChangeEvent<HTMLInputElement>) => {const file = e.target.files?.[0];e.target.value = ''; // allow re-picking the same file after it's removed@@ -119,17 +218,57 @@ export function MessageTester() {reader.readAsDataURL(file);};+ const isMediaMessageType = mediaMessageTypes.includes(messageType);+ const bulkRecipientList = parseBulkRecipients(bulkRecipients);+ const pollOptionsFilled = pollOptions.map(o => o.trim()).filter(o => o.length > 0);+ const lat = parseFloat(latitude);+ const lng = parseFloat(longitude);+ const delayMs = bulkDelay.trim() === '' ? undefined : parseInt(bulkDelay, 10);++ // Per-type required-field validation for the newer types; text/media keep their original behavior+ // (the backend stays the authoritative validator either way).+ let formValid = true;+ if (messageType === 'location') {+ formValid = !Number.isNaN(lat) && !Number.isNaN(lng) && lat >= -90 && lat <= 90 && lng >= -180 && lng <= 180;+ } else if (messageType === 'contact') {+ formValid = contactName.trim().length > 0 && contactNumber.trim().length > 0;+ } else if (messageType === 'sticker') {+ formValid = !!mediaFile || mediaUrl.trim().length > 0;+ } else if (messageType === 'poll') {+ formValid = pollQuestion.trim().length > 0 && pollOptionsFilled.length >= 2;+ } else if (messageType === 'forward') {+ formValid = forwardTo.trim().length > 0 && forwardMessageId.trim().length > 0;+ } else if (messageType === 'bulk') {+ formValid =+ content.trim().length > 0 &&+ bulkRecipientList.length > 0 &&+ bulkRecipientList.length <= BULK_MAX_RECIPIENTS &&+ (delayMs === undefined || (!Number.isNaN(delayMs) && delayMs >= 1000 && delayMs <= 60000));+ }++ const isSendDisabled =+ !canWrite ||+ isLoading ||+ !session ||+ !formValid ||+ (messageType !== 'bulk' && (recipientType === 'group' ? !selectedGroup : !recipient));+const handleSend = async () => {const targetId = recipientType === 'group' ? selectedGroup : recipient;- if (!session || !targetId) return;+ if (!session || (messageType !== 'bulk' && !targetId)) return;setIsLoading(true);setResponse(null);+ // An earlier batch keeps running server-side, but its polling must not overwrite this response.+ stopBatchPolling();+ setBatchStatus(null);+ setBatchError(null);try {// For a personal recipient, let the engine resolve the number to its canonical chat id rather// than hand-building an engine-specific JID here (#265) — also surfaces unregistered numbers.+ // Bulk carries its own recipient list, so the shared selector's target is not resolved there.let chatId = targetId;- if (recipientType !== 'group') {+ if (messageType !== 'bulk' && recipientType !== 'group') {const resolved = await contactApi.checkNumber(session, targetId.replace(/[^0-9]/g, ''));if (!resolved.exists || !resolved.whatsappId) {setResponse({@@ -142,23 +281,103 @@ export function MessageTester() {chatId = resolved.whatsappId;}- let result;- if (messageType === 'text') {- result = await messageApi.sendText(session, chatId, content);- } else {- // sendMedia unifies URL and base64 (local file) sends; base64 wins when a file is picked. The- // backend accepts url XOR base64 and requires a mimetype for base64 (always provided here).- const payload: SendMediaPayload = mediaFile- ? { base64: mediaFile.base64, mimetype: mediaFile.mimetype }- : { url: mediaUrl };- if ((messageType === 'image' || messageType === 'video') && content) payload.caption = content;- if (messageType === 'document' && content) payload.filename = content;- result = await messageApi.sendMedia(- session,- chatId,- messageType as 'image' | 'video' | 'audio' | 'document',- payload,- );+ // Bulk is a batch, not a single send: 202 + batchId, then poll progress until terminal.+ if (messageType === 'bulk') {+ const batch = await messageApi.sendBulk(session, {+ messages: bulkRecipientList.map(recipientChatId => ({+ chatId: recipientChatId,+ type: 'text' as const,+ content: { text: content },+ })),+ ...(delayMs !== undefined ? { options: { delayBetweenMessages: delayMs } } : {}),+ });+ batchSessionRef.current = session;+ setResponse({ success: true, timestamp: new Date().toISOString(), batchId: batch.batchId });+ setBatchStatus({+ batchId: batch.batchId,+ status: 'pending',+ progress: { total: batch.totalMessages, sent: 0, failed: 0, pending: batch.totalMessages, cancelled: 0 },+ });+ startBatchPolling(session, batch.batchId);+ return;+ }++ let result: MessageResponse;+ switch (messageType) {+ case 'text':+ result = await messageApi.sendText(session, chatId, content);+ break;+ case 'image':+ case 'video':+ case 'audio':+ case 'document': {+ // sendMedia unifies URL and base64 (local file) sends; base64 wins when a file is picked. The+ // backend accepts url XOR base64 and requires a mimetype for base64 (always provided here).+ const payload: SendMediaPayload = mediaFile+ ? { base64: mediaFile.base64, mimetype: mediaFile.mimetype }+ : { url: mediaUrl };+ if ((messageType === 'image' || messageType === 'video') && content) payload.caption = content;+ if (messageType === 'document' && content) payload.filename = content;+ result = await messageApi.sendMedia(session, chatId, messageType, payload);+ break;+ }+ case 'sticker': {+ const payload: SendMediaPayload = mediaFile+ ? { base64: mediaFile.base64, mimetype: mediaFile.mimetype }+ : { url: mediaUrl };+ result = await messageApi.sendSticker(session, chatId, payload);+ break;+ }+ case 'location':+ result = await messageApi.sendLocation(session, {+ chatId,+ latitude: lat,+ longitude: lng,+ ...(locationDescription.trim() ? { description: locationDescription.trim() } : {}),+ ...(locationAddress.trim() ? { address: locationAddress.trim() } : {}),+ });+ break;+ case 'contact':+ result = await messageApi.sendContact(session, {+ chatId,+ contactName: contactName.trim(),+ contactNumber: contactNumber.trim(),+ });+ break;+ case 'poll':+ result = await messageApi.sendPoll(session, {+ chatId,+ name: pollQuestion.trim(),+ options: pollOptionsFilled,+ ...(allowMultipleAnswers ? { allowMultipleAnswers: true } : {}),+ });+ break;+ case 'forward': {+ // toChatId passes through as-is when it is a full chat ID; a bare number is resolved+ // through the same check-number flow as the main recipient.+ let toChatId = forwardTo.trim();+ if (!toChatId.includes('@')) {+ const resolvedTo = await contactApi.checkNumber(session, toChatId.replace(/[^0-9]/g, ''));+ if (!resolvedTo.exists || !resolvedTo.whatsappId) {+ setResponse({+ success: false,+ timestamp: new Date().toISOString(),+ error: t('messageTester.notOnWhatsApp'),+ });+ return;+ }+ toChatId = resolvedTo.whatsappId;+ }+ result = await messageApi.forward(session, {+ // An empty fromChatId defaults to the current (already resolved) recipient.+ fromChatId: forwardFrom.trim() || chatId,+ toChatId,+ messageId: forwardMessageId.trim(),+ });+ break;+ }+ default:+ throw new Error(`Unsupported message type: ${messageType}`);}setResponse({@@ -178,6 +397,15 @@ export function MessageTester() {}};+ const batchPercent =+ batchStatus && batchStatus.progress.total > 0+ ? Math.round(+ ((batchStatus.progress.sent + batchStatus.progress.failed + batchStatus.progress.cancelled) /+ batchStatus.progress.total) *+ 100,+ )+ : 0;+if (loadingSessions) {return (<div@@ -209,56 +437,68 @@ export function MessageTester() {</select></div>- <div className="form-group">- <label>{t('messageTester.recipientType')}</label>- <div className="toggle-group">- <button- className={recipientType === 'personal' ? 'active' : ''}- onClick={() => setRecipientType('personal')}- >- {t('messageTester.personal')}- </button>- <button className={recipientType === 'group' ? 'active' : ''} onClick={() => setRecipientType('group')}>- {t('messageTester.group')}- </button>- </div>- </div>+ {/* Bulk carries its own recipient list, so the single-recipient selector is hidden there. */}+ {messageType !== 'bulk' && (+ <>+ <div className="form-group">+ <label>{t('messageTester.recipientType')}</label>+ <div className="toggle-group">+ <button+ className={recipientType === 'personal' ? 'active' : ''}+ onClick={() => setRecipientType('personal')}+ >+ {t('messageTester.personal')}+ </button>+ <button+ className={recipientType === 'group' ? 'active' : ''}+ onClick={() => setRecipientType('group')}+ >+ {t('messageTester.group')}+ </button>+ </div>+ </div>- <div className="form-group">- <label>{recipientType === 'group' ? t('messageTester.selectGroup') : t('messageTester.recipientPhone')}</label>- {recipientType === 'group' ? (- <>- <select- value={selectedGroup}- onChange={e => setSelectedGroup(e.target.value)}- disabled={loadingGroups || groups.length === 0}- >- {loadingGroups && <option value="">{t('messageTester.loadingGroups')}</option>}- {!loadingGroups && groups.length === 0 && <option value="">{t('messageTester.noGroupsFound')}</option>}- {groups.map(g => (- <option key={g.id} value={g.id}>- {g.name}- </option>- ))}- </select>- <span className="hint">{t('messageTester.selectGroupHint')}</span>- </>- ) : (- <>- <input- type="text"- value={recipient}- onChange={e => setRecipient(e.target.value)}- placeholder="+62812345678"- />- <span className="hint">{t('messageTester.phoneHint')}</span>- </>- )}- </div>+ <div className="form-group">+ <label>+ {recipientType === 'group' ? t('messageTester.selectGroup') : t('messageTester.recipientPhone')}+ </label>+ {recipientType === 'group' ? (+ <>+ <select+ value={selectedGroup}+ onChange={e => setSelectedGroup(e.target.value)}+ disabled={loadingGroups || groups.length === 0}+ >+ {loadingGroups && <option value="">{t('messageTester.loadingGroups')}</option>}+ {!loadingGroups && groups.length === 0 && (+ <option value="">{t('messageTester.noGroupsFound')}</option>+ )}+ {groups.map(g => (+ <option key={g.id} value={g.id}>+ {g.name}+ </option>+ ))}+ </select>+ <span className="hint">{t('messageTester.selectGroupHint')}</span>+ </>+ ) : (+ <>+ <input+ type="text"+ value={recipient}+ onChange={e => setRecipient(e.target.value)}+ placeholder="+62812345678"+ />+ <span className="hint">{t('messageTester.phoneHint')}</span>+ </>+ )}+ </div>+ </>+ )}<div className="form-group"><label>{t('messageTester.messageType')}</label>- <div className="toggle-group">+ <div className="toggle-group toggle-group-wrap">{messageTypes.map(type => (<buttonkey={type}@@ -276,7 +516,7 @@ export function MessageTester() {</div></div>- {messageType === 'text' ? (+ {messageType === 'text' && (<div className="form-group"><label>{t('messageTester.messageContent')}</label><textarea@@ -286,7 +526,9 @@ export function MessageTester() {rows={5}/></div>- ) : (+ )}++ {isMediaMessageType && (<><div className="form-group"><label>{t('messageTester.mediaUrl')}</label>@@ -325,27 +567,224 @@ export function MessageTester() {onChange={handleFileChange}/></div>- {messageType !== 'audio' && (+ {messageType !== 'audio' && messageType !== 'sticker' && (<div className="form-group"><label>- {messageType === 'document' ? t('messageTester.filename') : t('messageTester.caption')} ({t('common.optional')})+ {messageType === 'document' ? t('messageTester.filename') : t('messageTester.caption')} (+ {t('common.optional')})</label><inputtype="text"value={content}onChange={e => setContent(e.target.value)}- placeholder={messageType === 'document' ? t('messageTester.filenamePlaceholder') : t('messageTester.captionPlaceholder')}+ placeholder={+ messageType === 'document'+ ? t('messageTester.filenamePlaceholder')+ : t('messageTester.captionPlaceholder')+ }/></div>)}</>)}- <button- className="send-btn"- onClick={handleSend}- disabled={!canWrite || isLoading || !session || (recipientType === 'group' ? !selectedGroup : !recipient)}- >+ {messageType === 'location' && (+ <>+ <div className="form-row">+ <div className="form-group">+ <label>{t('messageTester.locationLatitude')}</label>+ <input+ type="number"+ step="any"+ min={-90}+ max={90}+ value={latitude}+ onChange={e => setLatitude(e.target.value)}+ placeholder="-6.2088"+ />+ </div>+ <div className="form-group">+ <label>{t('messageTester.locationLongitude')}</label>+ <input+ type="number"+ step="any"+ min={-180}+ max={180}+ value={longitude}+ onChange={e => setLongitude(e.target.value)}+ placeholder="106.8456"+ />+ </div>+ </div>+ <div className="form-group">+ <label>+ {t('messageTester.locationDescription')} ({t('common.optional')})+ </label>+ <input type="text" value={locationDescription} onChange={e => setLocationDescription(e.target.value)} />+ </div>+ <div className="form-group">+ <label>+ {t('messageTester.locationAddress')} ({t('common.optional')})+ </label>+ <input type="text" value={locationAddress} onChange={e => setLocationAddress(e.target.value)} />+ </div>+ </>+ )}++ {messageType === 'contact' && (+ <>+ <div className="form-group">+ <label>{t('messageTester.contactName')}</label>+ <input+ type="text"+ value={contactName}+ onChange={e => setContactName(e.target.value)}+ placeholder={t('messageTester.contactNamePlaceholder')}+ />+ </div>+ <div className="form-group">+ <label>{t('messageTester.contactNumber')}</label>+ <input+ type="text"+ value={contactNumber}+ onChange={e => setContactNumber(e.target.value)}+ placeholder="+62812345678"+ />+ </div>+ </>+ )}++ {messageType === 'poll' && (+ <>+ <div className="form-group">+ <label>{t('messageTester.pollQuestion')}</label>+ <input+ type="text"+ value={pollQuestion}+ onChange={e => setPollQuestion(e.target.value)}+ placeholder={t('messageTester.pollQuestionPlaceholder')}+ />+ </div>+ <div className="form-group">+ <label>{t('messageTester.pollOptions')}</label>+ {pollOptions.map((option, index) => (+ <div className="poll-option-row" key={index}>+ <input+ type="text"+ value={option}+ onChange={e => setPollOptions(prev => prev.map((o, i) => (i === index ? e.target.value : o)))}+ placeholder={t('messageTester.pollOptionPlaceholder', { index: index + 1 })}+ />+ <button+ type="button"+ className="remove-option-btn"+ onClick={() => setPollOptions(prev => prev.filter((_, i) => i !== index))}+ disabled={pollOptions.length <= 2}+ aria-label={t('messageTester.removeOption')}+ >+ <X size={14} />+ </button>+ </div>+ ))}+ <button+ type="button"+ className="add-option-btn"+ onClick={() => setPollOptions(prev => [...prev, ''])}+ disabled={pollOptions.length >= 12}+ >+ <Plus size={14} /> {t('messageTester.addOption')}+ </button>+ <span className="hint">{t('messageTester.pollOptionsHint')}</span>+ </div>+ <div className="form-group">+ <label className="checkbox-label">+ <input+ type="checkbox"+ checked={allowMultipleAnswers}+ onChange={e => setAllowMultipleAnswers(e.target.checked)}+ />+ {t('messageTester.allowMultipleAnswers')}+ </label>+ </div>+ </>+ )}++ {messageType === 'forward' && (+ <>+ <div className="form-group">+ <label>+ {t('messageTester.forwardFromChatId')} ({t('common.optional')})+ </label>+ <input+ type="text"+ value={forwardFrom}+ onChange={e => setForwardFrom(e.target.value)}+ placeholder={+ (recipientType === 'group' ? selectedGroup : recipient) || t('messageTester.forwardFromPlaceholder')+ }+ />+ <span className="hint">{t('messageTester.forwardFromHint')}</span>+ </div>+ <div className="form-group">+ <label>{t('messageTester.forwardToChatId')}</label>+ <input+ type="text"+ value={forwardTo}+ onChange={e => setForwardTo(e.target.value)}+ placeholder={t('messageTester.forwardToPlaceholder')}+ />+ </div>+ <div className="form-group">+ <label>{t('messageTester.forwardMessageId')}</label>+ <input type="text" value={forwardMessageId} onChange={e => setForwardMessageId(e.target.value)} />+ <span className="hint">{t('messageTester.forwardMessageIdHint')}</span>+ </div>+ </>+ )}++ {messageType === 'bulk' && (+ <>+ <div className="form-group">+ <label>{t('messageTester.bulkRecipients')}</label>+ <textarea+ value={bulkRecipients}+ onChange={e => setBulkRecipients(e.target.value)}+ placeholder={t('messageTester.bulkRecipientsPlaceholder')}+ rows={4}+ />+ <span className="hint">+ {t('messageTester.bulkRecipientsHint')} ·{' '}+ {t('messageTester.bulkRecipientsCount', { count: bulkRecipientList.length })}+ </span>+ </div>+ <div className="form-group">+ <label>{t('messageTester.messageContent')}</label>+ <textarea+ value={content}+ onChange={e => setContent(e.target.value)}+ placeholder={t('messageTester.messagePlaceholder')}+ rows={4}+ />+ </div>+ <div className="form-group">+ <label>+ {t('messageTester.bulkDelay')} ({t('common.optional')})+ </label>+ <input+ type="number"+ min={1000}+ max={60000}+ step={500}+ value={bulkDelay}+ onChange={e => setBulkDelay(e.target.value)}+ placeholder="3000"+ />+ <span className="hint">{t('messageTester.bulkDelayHint')}</span>+ </div>+ </>+ )}++ <button className="send-btn" onClick={handleSend} disabled={isSendDisabled}>{isLoading ? <Loader2 className="animate-spin" size={18} /> : <Send size={18} />}{isLoading ? t('messageTester.sending') : canWrite ? t('messageTester.send') : t('messageTester.viewOnly')}</button>@@ -386,6 +825,12 @@ export function MessageTester() {<span className="detail-value mono">{response.messageId}</span></div>)}+ {response.batchId && (+ <div className="detail-row">+ <span className="detail-label">{t('messageTester.response.batchId')}</span>+ <span className="detail-value mono">{response.batchId}</span>+ </div>+ )}{response.error && (<div className="detail-row"><span className="detail-label">{t('messageTester.response.error')}</span>@@ -396,6 +841,38 @@ export function MessageTester() {)}</div>+ {response.batchId && batchStatus && response.batchId === batchStatus.batchId && (+ <div className="batch-status">+ <div className="batch-status-row">+ <span className={`batch-badge ${batchStatus.status}`}>+ {t(`messageTester.batch.status.${batchStatus.status}`)}+ </span>+ {(batchStatus.status === 'pending' || batchStatus.status === 'processing') && (+ <button+ type="button"+ className="batch-cancel-btn"+ onClick={handleCancelBatch}+ disabled={batchCancelling}+ >+ {batchCancelling ? t('messageTester.batch.cancelling') : t('messageTester.batch.cancel')}+ </button>+ )}+ </div>+ <div className="batch-progress-bar">+ <div className="batch-progress-fill" style={{ width: `${batchPercent}%` }} />+ </div>+ <div className="batch-progress-line">+ {t('messageTester.batch.progress', {+ sent: batchStatus.progress.sent,+ failed: batchStatus.progress.failed,+ pending: batchStatus.progress.pending,+ total: batchStatus.progress.total,+ })}+ </div>+ {batchError && <div className="batch-error">{batchError}</div>}+ </div>+ )}+<div className="response-json"><pre>{JSON.stringify(response, null, 2)}</pre></div>diff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.tsindex 2e9192415..e9ae03b2d 100644--- a/dashboard/src/services/api.ts+++ b/dashboard/src/services/api.ts@@ -210,6 +210,104 @@ export interface SendMediaPayload {caption?: string;}+// Payloads below mirror the backend DTOs in src/modules/message/dto (raw bodies, no envelope).+export interface SendLocationPayload {+ chatId: string;+ latitude: number;+ longitude: number;+ description?: string;+ address?: string;+}++export interface SendContactPayload {+ chatId: string;+ contactName: string;+ contactNumber: string;+}++export interface SendPollPayload {+ chatId: string;+ name: string;+ options: string[];+ allowMultipleAnswers?: boolean;+}++export interface ForwardMessagePayload {+ fromChatId: string;+ toChatId: string;+ messageId: string;+}++// Media block of a single bulk message (BulkMediaDto — no caption; caption sits next to it).+export interface BulkMediaPayload {+ url?: string;+ base64?: string;+ mimetype?: string;+ filename?: string;+ ptt?: boolean;+}++export interface BulkMessageItem {+ chatId: string;+ type: 'text' | 'image' | 'video' | 'audio' | 'document';+ content: {+ text?: string;+ image?: BulkMediaPayload;+ video?: BulkMediaPayload;+ audio?: BulkMediaPayload;+ document?: BulkMediaPayload;+ caption?: string;+ };+ variables?: Record<string, string>;+}++export interface SendBulkPayload {+ batchId?: string;+ messages: BulkMessageItem[];+ options?: {+ delayBetweenMessages?: number;+ randomizeDelay?: boolean;+ stopOnError?: boolean;+ };+}++/** 202 response of POST send-bulk — the batch is processing asynchronously; poll getBatchStatus. */+export interface BulkBatchResponse {+ batchId: string;+ status: string;+ totalMessages: number;+ estimatedCompletionTime?: string;+ statusUrl: string;+}++export type BatchStatus = 'pending' | 'processing' | 'completed' | 'cancelled' | 'failed';++export interface BatchProgress {+ total: number;+ sent: number;+ failed: number;+ pending: number;+ cancelled: number;+}++export interface BatchMessageResult {+ chatId: string;+ status: 'pending' | 'sent' | 'failed' | 'cancelled';+ messageId?: string;+ error?: { code: string; message: string };+ sentAt?: string;+}++/** GET batch/:batchId shape; the cancel endpoint returns the same minus results/timestamps. */+export interface BatchStatusResponse {+ batchId: string;+ status: BatchStatus;+ progress: BatchProgress;+ results?: BatchMessageResult[];+ startedAt?: string;+ completedAt?: string;+}+export interface HealthStatus {status: 'ok' | 'error';timestamp?: string;@@ -633,6 +731,44 @@ export const messageApi = {method: 'POST',body: JSON.stringify({ chatId, ...payload }),}),+ sendLocation: (sessionId: string, data: SendLocationPayload) =>+ request<MessageResponse>(`/sessions/${sessionId}/messages/send-location`, {+ method: 'POST',+ body: JSON.stringify(data),+ }),+ sendContact: (sessionId: string, data: SendContactPayload) =>+ request<MessageResponse>(`/sessions/${sessionId}/messages/send-contact`, {+ method: 'POST',+ body: JSON.stringify(data),+ }),+ // Stickers take the same media body as the other send-* endpoints (base64 XOR url + mimetype).+ sendSticker: (sessionId: string, chatId: string, payload: SendMediaPayload) =>+ request<MessageResponse>(`/sessions/${sessionId}/messages/send-sticker`, {+ method: 'POST',+ body: JSON.stringify({ chatId, ...payload }),+ }),+ sendPoll: (sessionId: string, data: SendPollPayload) =>+ request<MessageResponse>(`/sessions/${sessionId}/messages/send-poll`, {+ method: 'POST',+ body: JSON.stringify(data),+ }),+ forward: (sessionId: string, data: ForwardMessagePayload) =>+ request<MessageResponse>(`/sessions/${sessionId}/messages/forward`, {+ method: 'POST',+ body: JSON.stringify(data),+ }),+ // Async batch: returns 202 immediately; poll getBatchStatus until a terminal status.+ sendBulk: (sessionId: string, data: SendBulkPayload) =>+ request<BulkBatchResponse>(`/sessions/${sessionId}/messages/send-bulk`, {+ method: 'POST',+ body: JSON.stringify(data),+ }),+ getBatchStatus: (sessionId: string, batchId: string) =>+ request<BatchStatusResponse>(`/sessions/${sessionId}/messages/batch/${encodeURIComponent(batchId)}`),+ cancelBatch: (sessionId: string, batchId: string) =>+ request<BatchStatusResponse>(`/sessions/${sessionId}/messages/batch/${encodeURIComponent(batchId)}/cancel`, {+ method: 'POST',+ }),reply: (sessionId: string, data: { chatId: string; quotedMessageId: string; text: string }) =>request<MessageResponse>(`/sessions/${sessionId}/messages/reply`, {method: 'POST',diff --git a/dashboard/src/utils/bulkRecipients.test.ts b/dashboard/src/utils/bulkRecipients.test.tsnew file mode 100644index 000000000..8c5dd07d3--- /dev/null+++ b/dashboard/src/utils/bulkRecipients.test.ts@@ -0,0 +1,30 @@+import { test } from 'node:test';+import assert from 'node:assert/strict';+import { parseBulkRecipients } from './bulkRecipients.ts';++test('parses one recipient per line, trimming whitespace and dropping blanks', () => {+ const text = ' +62 812-3456-78 \n\[email protected]\n \[email protected]';+ assert.deepEqual(parseBulkRecipients(text), ['[email protected]', '[email protected]', '[email protected]']);+});++test('normalizes bare phone numbers to @c.us chat IDs', () => {+ assert.deepEqual(parseBulkRecipients('+1 (555) 010-2233'), ['[email protected]']);+});++test('passes full chat IDs through untouched', () => {+ assert.deepEqual(parseBulkRecipients('123@lid\[email protected]'), ['123@lid', '[email protected]']);+});++test('de-dupes entries that normalize to the same chat ID', () => {+ const text = '+62 812 3456 78\n62812345678\[email protected]';+ assert.deepEqual(parseBulkRecipients(text), ['[email protected]']);+});++test('drops lines with neither an @ nor any digits instead of sending "@c.us"', () => {+ assert.deepEqual(parseBulkRecipients('not-a-number\n---\n628123456789'), ['[email protected]']);+});++test('returns an empty list for empty input', () => {+ assert.deepEqual(parseBulkRecipients(''), []);+ assert.deepEqual(parseBulkRecipients(' \n \n'), []);+});diff --git a/dashboard/src/utils/bulkRecipients.ts b/dashboard/src/utils/bulkRecipients.tsnew file mode 100644index 000000000..245fd1394--- /dev/null+++ b/dashboard/src/utils/bulkRecipients.ts@@ -0,0 +1,23 @@+// The backend caps a bulk batch at 100 messages (ArrayMaxSize on SendBulkMessageDto).+export const BULK_MAX_RECIPIENTS = 100;++/**+ * Parse the bulk-recipients textarea (one entry per line) into chat IDs: trims whitespace,+ * drops blank lines, de-dupes, and normalizes bare phone numbers to `<digits>@c.us`. Lines+ * containing '@' are treated as full chat IDs and pass through untouched; lines with no '@'+ * and no digits at all are dropped rather than sent as the meaningless '@c.us'.+ */+export function parseBulkRecipients(text: string): string[] {+ const seen = new Set<string>();+ for (const rawLine of text.split('\n')) {+ const line = rawLine.trim();+ if (!line) continue;+ if (line.includes('@')) {+ seen.add(line);+ continue;+ }+ const digits = line.replace(/[^0-9]/g, '');+ if (digits) seen.add(`${digits}@c.us`);+ }+ return [...seen];+}