58 lines
2.4 KiB
JavaScript
58 lines
2.4 KiB
JavaScript
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() {
|
|
if (!fs.existsSync(apkPath)) {
|
|
console.error('❌ El archivo APK no existe en:', apkPath);
|
|
return;
|
|
}
|
|
|
|
const stat = fs.statSync(apkPath);
|
|
const sizeMB = (stat.size / (1024 * 1024)).toFixed(2);
|
|
console.log(`📦 Leyendo APK oficial (${sizeMB} MB)...`);
|
|
|
|
const apkBuffer = fs.readFileSync(apkPath);
|
|
const base64Data = apkBuffer.toString('base64');
|
|
|
|
const caption = `🚀 *DripZone Sneakers - APK Oficial Actualizado*\n\n📅 *Generado:* ${new Date().toLocaleString('es-CO', { timeZone: 'America/Bogota' })}\n📦 *Tamaño:* ${sizeMB} MB\n\n✨ *Novedades de esta versión:*\n✅ Gestión y módulo completo de Proveedores\n✅ Edición, actualización y eliminación de pedidos en tiempo real\n✅ Notificaciones automáticas de pedidos por WhatsApp (Evolution API v2)\n✅ Autenticación biométrica con Huella / Passkey y 2FA OTP\n✅ Splash Screen vertical en alta definición y Dock interactivo optimizado\n\n📲 *Instalación:* Toca este archivo para instalar/actualizar la app en tu teléfono Android.`;
|
|
|
|
console.log(`📤 Enviando APK vía Evolution API a WhatsApp (+${TARGET_PHONE})...`);
|
|
|
|
try {
|
|
const response = 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,
|
|
media: base64Data,
|
|
},
|
|
{
|
|
headers: {
|
|
apikey: EVOLUTION_API_KEY,
|
|
'Content-Type': 'application/json',
|
|
},
|
|
maxContentLength: Infinity,
|
|
maxBodyLength: Infinity,
|
|
timeout: 180000,
|
|
}
|
|
);
|
|
|
|
console.log('🎉 ¡APK enviado con éxito a tu WhatsApp!', response.data?.key?.id);
|
|
} catch (error) {
|
|
console.error('❌ Error enviando APK:', error?.response?.data || error.message);
|
|
}
|
|
}
|
|
|
|
sendApkToCarlos();
|