refactor: Simplify root user notification and remove global email variable

- Remove global `RootUserEmail` variable
- Modify channel testing and user notification methods to use `GetRootUser()`
- Update user cache and notification service to use more consistent user base type
- Add new channel test notification type
This commit is contained in:
1808837298@qq.com
2025-02-18 15:59:17 +08:00
parent 56f6b2ab56
commit 0907a078b4
8 changed files with 41 additions and 45 deletions

View File

@@ -9,17 +9,12 @@ import (
"strings"
)
func notifyRootUser(subject string, content string) {
if common.RootUserEmail == "" {
common.RootUserEmail = model.GetRootUserEmail()
}
err := common.SendEmail(subject, common.RootUserEmail, content)
if err != nil {
common.SysError(fmt.Sprintf("failed to send email: %s", err.Error()))
}
func NotifyRootUser(t string, subject string, content string) {
user := model.GetRootUser().ToBaseUser()
_ = NotifyUser(&user, dto.NewNotify(t, subject, content, nil))
}
func NotifyUser(user *model.UserCache, data dto.Notify) error {
func NotifyUser(user *model.UserBase, data dto.Notify) error {
userSetting := user.GetSetting()
notifyType, ok := userSetting[constant.UserSettingNotifyType]
if !ok {