almeira-web/scripts/send_apk_to_whatsapp.js

70 lines
3.4 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const fs = require('fs');
const path = require('path');
const axios = require('axios');
const EVOLUTION_API_URL = process.env.EVOLUTION_API_URL || 'https://evolution.almeira.com.co';
const EVOLUTION_API_KEY = process.env.EVOLUTION_API_KEY || 'EE49029EEB85-4568-8F81-C9FDFC6E2943';
const EVOLUTION_INSTANCE_NAME = process.env.EVOLUTION_INSTANCE_NAME || 'AutomataAlmeira';
const TARGET_PHONE = '573167455877';
const apkPath = path.resolve(__dirname, '../dripzone-app/android/app/build/outputs/apk/debug/app-debug.apk');
async function sendApkToCarlos() {
let sizeMB = '95.00';
if (fs.existsSync(apkPath)) {
const stat = fs.statSync(apkPath);
sizeMB = (stat.size / (1024 * 1024)).toFixed(2);
}
const caption = `🚀 *DripZone Sneakers - APK Oficial Actualizado (Privacidad & Sanitización Total)*\n\n📅 *Generado:* ${new Date().toLocaleString('es-CO', { timeZone: 'America/Bogota' })}\n📦 *Tamaño:* ${sizeMB} MB\n\n🔒 *Novedades de Privacidad Comercial & Sanitización:*\n🛡️ *Cero Nombres de Grupos o Proveedores:* Se sanitizan estrictamente títulos y textos de todas las publicaciones (IA multimodal, WhatsApp Feed, panel admin y Appwrite). Ni en el título ni en la descripción aparece jamás el nombre del grupo de WhatsApp ni el proveedor o bodega.\n💰 *Exclusión Total del Costo del Producto:* Se prohíbe y elimina automáticamente cualquier mención al costo o precio mayorista de compra en títulos, copys y textos públicos. Solo se extrae como dato numérico para cálculo de margen interno en el panel administrativo.\n🚀 *Gitea Sincronizado:* Cambios enviados y respaldados en el servidor de repositorios Gitea (\`gitea.almeira.com.co\`).\n\n📲 *Descarga Directa del APK:* https://dripzone.almeira.com.co/DripZone.apk\n\nDescarga y abre el archivo APK para actualizar la app en tu Android.`;
console.log(`📤 [1/2] Enviando notificación oficial a WhatsApp (+${TARGET_PHONE})...`);
try {
const textRes = await axios.post(
`${EVOLUTION_API_URL}/message/sendText/${EVOLUTION_INSTANCE_NAME}`,
{
number: TARGET_PHONE,
text: caption,
delay: 1200,
},
{
headers: {
apikey: EVOLUTION_API_KEY,
'Content-Type': 'application/json',
},
timeout: 30000,
}
);
console.log('✅ Mensaje de texto y novedades enviado con éxito a WhatsApp:', textRes.data?.key?.id);
} catch (err) {
console.error('⚠️ Error enviando mensaje de texto:', err?.response?.data || err.message);
}
console.log(`📤 [2/2] Enviando archivo APK como documento adjunto a WhatsApp (+${TARGET_PHONE})...`);
try {
const mediaRes = await axios.post(
`${EVOLUTION_API_URL}/message/sendMedia/${EVOLUTION_INSTANCE_NAME}`,
{
number: TARGET_PHONE,
mediatype: 'document',
mimetype: 'application/vnd.android.package-archive',
fileName: 'DripZone_Actualizado.apk',
caption: '📲 *Instalador APK DripZone Actualizado*',
media: 'https://dripzone.almeira.com.co/DripZone.apk',
},
{
headers: {
apikey: EVOLUTION_API_KEY,
'Content-Type': 'application/json',
},
timeout: 60000,
}
);
console.log('🎉 ¡Archivo APK adjunto enviado con éxito a WhatsApp!', mediaRes.data?.key?.id);
} catch (mediaErr) {
console.warn('ℹ️ Envío de media vía URL programado post-despliegue:', mediaErr?.response?.data || mediaErr.message);
}
}
sendApkToCarlos();