package handlers

import (
	"github.com/fiskerinc/cloud-services/services/attendant/controllers"
	"github.com/fiskerinc/cloud-services/services/attendant/services"

	"github.com/fiskerinc/cloud-services/pkg/common"
	"github.com/fiskerinc/cloud-services/pkg/logger"
)

var PrivateSeed int64 // Used only for testing. Do not change otherwise

func SendManifest(d *services.DB, ka *services.KeepAwake, device common.Device, id string, data []byte) error {
	logger.Debug().Msgf("SendManifest %v %s", device, id)

	clientPool := services.RedisClientPool()

	configService := services.GetVehicleConfig()

	generator := controllers.NewManifestSender(clientPool, d, configService, device, ka, PrivateSeed)
	defer generator.Release()

	return generator.Process(id, data)
}
