mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-18 20:07:26 +00:00
feat: auto fetch upstream models (#2979)
* feat: add upstream model update detection with scheduled sync and manual apply flows * feat: support upstream model removal sync and selectable deletes in update modal * feat: add detect-only upstream updates and show compact +/- model badges * feat: improve upstream model update UX * feat: improve upstream model update UX * fix: respect model_mapping in upstream update detection * feat: improve upstream update modal to prevent missed add/remove actions * feat: add admin upstream model update notifications with digest and truncation * fix: avoid repeated partial-submit confirmation in upstream update modal * feat: improve ui/ux * feat: suppress upstream update alerts for unchanged channel-count within 24h * fix: submit upstream update choices even when no models are selected * feat: improve upstream model update flow and split frontend updater * fix merge conflict
This commit is contained in:
@@ -22,6 +22,32 @@ func NotifyRootUser(t string, subject string, content string) {
|
||||
}
|
||||
}
|
||||
|
||||
func NotifyUpstreamModelUpdateWatchers(subject string, content string) {
|
||||
var users []model.User
|
||||
if err := model.DB.
|
||||
Select("id", "email", "role", "status", "setting").
|
||||
Where("status = ? AND role >= ?", common.UserStatusEnabled, common.RoleAdminUser).
|
||||
Find(&users).Error; err != nil {
|
||||
common.SysLog(fmt.Sprintf("failed to query upstream update notification users: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
notification := dto.NewNotify(dto.NotifyTypeChannelUpdate, subject, content, nil)
|
||||
sentCount := 0
|
||||
for _, user := range users {
|
||||
userSetting := user.GetSetting()
|
||||
if !userSetting.UpstreamModelUpdateNotifyEnabled {
|
||||
continue
|
||||
}
|
||||
if err := NotifyUser(user.Id, user.Email, userSetting, notification); err != nil {
|
||||
common.SysLog(fmt.Sprintf("failed to notify user %d for upstream model update: %s", user.Id, err.Error()))
|
||||
continue
|
||||
}
|
||||
sentCount++
|
||||
}
|
||||
common.SysLog(fmt.Sprintf("upstream model update notifications sent: %d", sentCount))
|
||||
}
|
||||
|
||||
func NotifyUser(userId int, userEmail string, userSetting dto.UserSetting, data dto.Notify) error {
|
||||
notifyType := userSetting.NotifyType
|
||||
if notifyType == "" {
|
||||
|
||||
Reference in New Issue
Block a user