mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-09 06:46:37 +08:00
fix: refresh emby sessions in realtime
This commit is contained in:
@@ -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>"}
|
||||
|
||||
Reference in New Issue
Block a user