nailed it

This commit is contained in:
cottongin
2025-11-02 16:48:18 -05:00
parent f764519a30
commit 9262ae79dd
3 changed files with 28 additions and 4 deletions

3
.gitignore vendored
View File

@@ -48,3 +48,6 @@ build/
.examples/
chat-summaries/
bin/
# Persistent data directory (contains cached tokens)
data/

View File

@@ -70,12 +70,29 @@ func (b *Bkosmi) Connect() error {
var token string
if email != "" && password != "" {
b.Log.Info("Authenticating with email/password...")
token, err = loginWithChromedp(email, password, b.Log)
// Try to load cached token first
cachedToken, err := loadTokenCache(email, b.Log)
if err != nil {
return fmt.Errorf("authentication failed: %w", err)
b.Log.Warnf("Failed to load token cache: %v", err)
}
if cachedToken != nil {
// Use cached token
token = cachedToken.Token
} else {
// No valid cache, authenticate with browser
b.Log.Info("Authenticating with email/password...")
token, err = loginWithChromedp(email, password, b.Log)
if err != nil {
return fmt.Errorf("authentication failed: %w", err)
}
b.Log.Info("✅ Authentication successful")
// Save token to cache
if err := saveTokenCache(token, email, b.Log); err != nil {
b.Log.Warnf("Failed to cache token: %v", err)
}
}
b.Log.Info("✅ Authentication successful")
} else {
b.Log.Info("No credentials provided, using anonymous access")
// token will be empty, client will get anonymous token

View File

@@ -14,12 +14,16 @@ services:
- ./matterbridge.toml:/app/matterbridge.toml:ro,z
# Optional: Mount a directory for logs
- ./logs:/app/logs:z
# Mount data directory for persistent token cache
- ./data:/app/data:z
# If you need to expose any ports (e.g., for API or webhooks)
# ports:
# - "4242:4242"
environment:
# Optional: Set timezone
- TZ=America/New_York
# Data directory for persistent storage (token cache, etc.)
- MATTERBRIDGE_DATA_DIR=/app/data
# Optional: Set memory limits (much lower now without browser!)
# mem_limit: 128m
# mem_reservation: 64m