package config

import (
	"github.com/BurntSushi/toml"
)

var Cfg Config

type Config struct {
	Server   server
	Database database
	Mail     mail
	RabbitMq rabbitmq
	Settings settings
}

type server struct {
	Debug bool
	Host  string
}

type database struct {
	Host     string
	Database string
	Username string
	Password string
}

type mail struct {
	Host string
	Key  string
}

type rabbitmq struct {
	Host     string
	Username string
	Password string
}

type settings struct {
	DefaultLanguageId int
	Expires           settingsExpires `toml:"expires"`
	Lengths           settingsLengths `toml:"lengths"`
	Cookies           settingsCookies `toml:"cookies"`
}

type settingsExpires struct {
	UserSession int
	UserActions userActions `toml:"userActions"`
}

type userActions struct {
	Id_0 int
	Id_1 int
}

type settingsLengths struct {
	UsernameMinLen int
	UsernameMaxLen int
	EmailMinLen    int
	EmailMaxLen    int
	PasswordMinLen int
	PasswordMaxLen int
}

type settingsCookies struct {
	SessionId   string
	Username    string
	UserHashtag string
}

func LoadConfig() {
	toml.DecodeFile("./config.toml", &Cfg)
}
