Fix:Server crash deleting user with sessions

This commit is contained in:
advplyr 2024-11-27 16:48:07 -06:00
parent c643d4cec8
commit ef82e8b0d0

View File

@ -368,6 +368,19 @@ class UserController {
await playlist.destroy()
}
// Set PlaybackSessions userId to null
const [sessionsUpdated] = await Database.playbackSessionModel.update(
{
userId: null
},
{
where: {
userId: user.id
}
}
)
Logger.info(`[UserController] Updated ${sessionsUpdated} playback sessions to remove user id`)
const userJson = user.toOldJSONForBrowser()
await user.destroy()
SocketAuthority.adminEmitter('user_removed', userJson)