fix: refresh emby sessions in realtime

This commit is contained in:
ShukeBta
2026-06-25 02:32:32 +08:00
parent 29f5df673c
commit baa4a38b0a
12 changed files with 441 additions and 27 deletions
+10
View File
@@ -43,6 +43,7 @@ func (s *TelegramBotService) cmdMgoUserInfo(ctx context.Context, args []string)
if user == nil {
return telegramCommandReply{Text: "未找到用户。"}
}
s.applyRealtimeUserActivity(ctx, user)
devices, _ := s.listUserDevices(ctx, user.ID)
var historyCount int64
_ = s.repo.DB.WithContext(ctx).Model(&model.PlaybackHistory{}).Where("user_id = ?", user.ID).Count(&historyCount).Error
@@ -60,6 +61,15 @@ func (s *TelegramBotService) cmdMgoUserInfo(ctx context.Context, args []string)
)}
}
func (s *TelegramBotService) applyRealtimeUserActivity(ctx context.Context, user *model.User) {
if s == nil || user == nil || s.device == nil || s.device.sessions == nil {
return
}
users := []model.User{*user}
s.device.sessions.ApplyToUsers(ctx, users)
*user = users[0]
}
func (s *TelegramBotService) cmdMgoDeleteUser(ctx context.Context, args []string) telegramCommandReply {
if len(args) < 2 || !strings.EqualFold(args[len(args)-1], "confirm") {
return telegramCommandReply{Text: "删除用户需要确认:<code>/rmemby 用户名 confirm</code> 或 <code>/urm 用户名 confirm</code>"}