Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions internal/chat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"os"
"strconv"
"time"

"github.com/glimesh/broadcast-box/internal/environment"
)

const (
Expand Down Expand Up @@ -53,21 +55,21 @@ type Manager struct {

func NewManager() *Manager {
maxHistory := DefaultMaxHistory
if val := os.Getenv("CHAT_MAX_HISTORY"); val != "" {
if val := os.Getenv(environment.ChatMaxHistory); val != "" {
if i, err := strconv.Atoi(val); err == nil {
maxHistory = i
}
}

defaultTTL := DefaultTTL
if val := os.Getenv("CHAT_DEFAULT_TTL"); val != "" {
if val := os.Getenv(environment.ChatDefaultTTL); val != "" {
if d, err := time.ParseDuration(val); err == nil {
defaultTTL = d
}
}

cleanupInterval := DefaultCleanupInterval
if val := os.Getenv("CHAT_CLEANUP_INTERVAL"); val != "" {
if val := os.Getenv(environment.ChatCleanupInterval); val != "" {
if d, err := time.ParseDuration(val); err == nil && d > 0 {
cleanupInterval = d
}
Expand Down
6 changes: 5 additions & 1 deletion internal/environment/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const (
EnableProfiling = "ENABLE_PROFILING"

// SSL
useSSL = "USE_SSL"
SSLKey = "SSL_KEY"
SSLCert = "SSL_CERT"

Expand All @@ -26,6 +25,11 @@ const (
frontendPath = "FRONTEND_PATH"
FrontendAdminToken = "FRONTEND_ADMIN_TOKEN"

// CHAT
ChatMaxHistory = "CHAT_MAX_HISTORY"
ChatDefaultTTL = "CHAT_DEFAULT_TTL"
ChatCleanupInterval = "CHAT_CLEANUP_INTERVAL"

// WEBRTC
IncludeLoopbackCandidate = "INCLUDE_LOOPBACK_CANDIDATE"
NetworkTypes = "NETWORK_TYPES"
Expand Down
Loading