up
This commit is contained in:
+13
-3
@@ -2257,7 +2257,8 @@
|
||||
// hide reply preview if any
|
||||
this.hideReplyPreview();
|
||||
if (resp && resp.success) {
|
||||
this.addMessageToView(`Plantilla: ${templateName}`, 'outgoing');
|
||||
const replyToTemplate = document.getElementById('message-input').dataset.replyTo || null;
|
||||
this.addMessageToView(`Plantilla: ${templateName}`, 'outgoing', { reply_to_message_id: replyToTemplate });
|
||||
typeof showAlert !== 'undefined' && showAlert('Mensaje de plantilla enviado correctamente', 'success');
|
||||
await this.loadconversations(this.currentUserId, false);
|
||||
await this.loadConversations();
|
||||
@@ -2284,7 +2285,7 @@
|
||||
}
|
||||
|
||||
// Insertar mensaje saliente en la vista inmediatamente (simular envío)
|
||||
addMessageToView(content, type = 'outgoing') {
|
||||
addMessageToView(content, type = 'outgoing', options = {}) {
|
||||
const msg = {
|
||||
message_id: 'local_' + Date.now(),
|
||||
direction: type === 'outgoing' ? 'outgoing' : 'incoming',
|
||||
@@ -2292,6 +2293,15 @@
|
||||
created_at: new Date().toISOString(),
|
||||
status: 'sent'
|
||||
};
|
||||
// Soportar reply preview inmediato
|
||||
if (options && options.reply_to_message_id) {
|
||||
msg.reply_to_message_id = options.reply_to_message_id;
|
||||
}
|
||||
// Soportar attachments/meta si es necesario
|
||||
if (options && options.message_type) {
|
||||
msg.message_type = options.message_type;
|
||||
}
|
||||
|
||||
this.conversations.push(msg);
|
||||
this.renderconversations();
|
||||
this.scrollToBottom();
|
||||
@@ -2417,7 +2427,7 @@
|
||||
if (result && result.success) {
|
||||
input.value = '';
|
||||
// Mostrar inmediatamente en la vista
|
||||
this.addMessageToView(message, 'outgoing');
|
||||
this.addMessageToView(message, 'outgoing', { reply_to_message_id: replyTo });
|
||||
typeof showAlert !== 'undefined' && showAlert('Mensaje enviado correctamente', 'success');
|
||||
// Recargar mensajes y conversaciones en background
|
||||
this.loadconversations(this.currentUserId, false).catch(e=>console.warn(e));
|
||||
|
||||
@@ -551,12 +551,13 @@ class WhatsAppService
|
||||
|
||||
// Si es reply (context)
|
||||
if (isset($data['context']['message_id'])) {
|
||||
$messageData['reply_to_message_id'] = is_numeric($data['context']['message_id']) ? intval($data['context']['message_id']) : null;
|
||||
// WhatsApp message IDs can be alphanumeric (e.g., wamid...), store as string
|
||||
$messageData['reply_to_message_id'] = trim((string)$data['context']['message_id']) ?: null;
|
||||
}
|
||||
|
||||
// Si es reaction
|
||||
if ($data['type'] === 'reaction' && isset($data['reaction'])) {
|
||||
$messageData['reaction_to_message_id'] = is_numeric($data['reaction']['message_id'] ?? null) ? intval($data['reaction']['message_id']) : null;
|
||||
$messageData['reaction_to_message_id'] = isset($data['reaction']['message_id']) ? trim((string)$data['reaction']['message_id']) : null;
|
||||
$messageData['reaction_emoji'] = $data['reaction']['emoji'] ?? null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user