package cleaners

import (
	"time"

	"git.mstar.dev/mstar/linstrom/storage-new/dbgen"
)

func init() {
	cleanerBuilders = append(cleanerBuilders, buildExpireAccessTokens)
}

func tickExpireAccessTokens(now time.Time) {
	dbgen.AccessToken.Where(dbgen.AccessToken.ExpiresAt.Lt(time.Now())).Delete()
}

func buildExpireAccessTokens() (onTick func(time.Time), name string, tickSpeed time.Duration) {
	return tickExpireAccessTokens, "expire-access-tokens", time.Hour
}
