Files
GL.iNet-Yongping.Xie 9459b4709c feat: add email notification for device events
- SMTP config with TLS/STARTTLS/plain support and test email
- Notification rules for device online, offline, and remote access
- Recipient management with add/remove endpoints
- Async email sending via goroutines to avoid blocking device runtime
- Admin settings page with SMTP, rules, and recipients sections
- Bell icon added to sidebar menu
- i18n support for all 7 languages

Signed-off-by: GL.iNet-Yongping.Xie <yongping.xie@gl-inet.com>
2026-04-07 21:02:24 -07:00

50 lines
1.1 KiB
Go
Executable File

package sqlite
import (
"sync"
"gorm.io/gorm"
"rttys/internal/domain/devicelog"
"rttys/internal/domain/notification"
"rttys/internal/domain/user"
)
type Container struct {
Gorm *gorm.DB
DeviceMeta *DeviceMetaRepo
DeviceLogSvc *devicelog.Service
UserSvc *user.Service
NotificationSvc *notification.Service
}
var (
gContainer *Container
mu sync.RWMutex
)
func SetContainer(c *Container) {
mu.Lock()
defer mu.Unlock()
gContainer = c
}
func MustContainer() *Container {
mu.RLock()
defer mu.RUnlock()
if gContainer == nil {
panic("sqlite container not initialized")
}
return gContainer
}
// TryContainer returns the global container if it has been initialized,
// or nil otherwise. Use this from code paths (e.g. device runtime) that
// may execute before InitAppContainer has finished — calling MustContainer
// there would panic on early connections.
func TryContainer() *Container {
mu.RLock()
defer mu.RUnlock()
return gContainer
}