diff --git a/rest/controllers/servidor_controller.go b/rest/controllers/servidor_controller.go index 9736426..879d7cd 100755 --- a/rest/controllers/servidor_controller.go +++ b/rest/controllers/servidor_controller.go @@ -227,9 +227,10 @@ func SyncServidorFromHostinger(c *fiber.Ctx) error { updates["nucleos"] = fmt.Sprintf("%d", vps.CPU) } - // Disco: Hostinger devuelve en GB directamente + // Disco: Hostinger devuelve en MB (igual que memory) → convertir a GB if vps.DiskBytes > 0 { - updates["disco"] = fmt.Sprintf("%d GB", vps.DiskBytes) + gbDisk := vps.DiskBytes / 1024 + updates["disco"] = fmt.Sprintf("%d GB", gbDisk) } // Vencimiento: resolución en cascada @@ -243,17 +244,29 @@ func SyncServidorFromHostinger(c *fiber.Ctx) error { if subID != "" { // Lookup directo — sin ambigüedad - if sub, sErr := client.GetSubscriptionByID(subID); sErr == nil && sub.ExpiresAt != "" && len(sub.ExpiresAt) >= 10 { - updates["vencimiento"] = sub.ExpiresAt[:10] + if sub, sErr := client.GetSubscriptionByID(subID); sErr == nil { + // Para suscripciones activas con auto-renovación, expires_at viene vacío; + // en ese caso usar next_billing_at como fecha de vencimiento. + venc := sub.ExpiresAt + if venc == "" { + venc = sub.NextBillingAt + } + if venc != "" && len(venc) >= 10 { + updates["vencimiento"] = venc[:10] + } updates["hostinger_subscription_id"] = subID } } else { // Fallback: buscar por nombre si aún no tenemos subscription_id if subs, sErr := client.GetOrders(); sErr == nil { for _, sub := range subs { - if sub.ExpiresAt != "" && len(sub.ExpiresAt) >= 10 && + venc := sub.ExpiresAt + if venc == "" { + venc = sub.NextBillingAt + } + if venc != "" && len(venc) >= 10 && strings.Contains(strings.ToLower(sub.Name), strings.ToLower(vps.Hostname)) { - updates["vencimiento"] = sub.ExpiresAt[:10] + updates["vencimiento"] = venc[:10] updates["hostinger_subscription_id"] = sub.ID break }