From ef82e8b0d0760b40a1ab7ac94ceb4af94c046f13 Mon Sep 17 00:00:00 2001 From: advplyr Date: Wed, 27 Nov 2024 16:48:07 -0600 Subject: [PATCH] Fix:Server crash deleting user with sessions --- server/controllers/UserController.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server/controllers/UserController.js b/server/controllers/UserController.js index f895c0d0..0fb10513 100644 --- a/server/controllers/UserController.js +++ b/server/controllers/UserController.js @@ -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)