package handlers

import (
	"github.com/fiskerinc/cloud-services/services/depot/services"

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

func MobileDel(db *services.DB, id string) error {
	client := services.RedisClientPool().GetFromPool()
	defer client.Close()

	err := removeMobileSession(client, id)
	if err != nil {
		logger.Warn().Str("id", id).Err(err).Send()
	}

	return nil
}

func removeMobileSession(client redis.Client, id string) error {
	_, err := client.Execute("SREM", redis.MobileSessionsKey(), id)
	return err
}
