Listen for user config changes and improved websocket error handling (#2012)
## Description Add better error handling for server web socket messages that are (technically) invalid. For example, I talked to Niels and some third party plugins don't always have the required fields. Since the server isn't as strict as the client SDK, it's fine on the server but will generate an invalid message sent to the client. Also listens for server-side user configuration changes via web socket. ### Related issues Fixes #1979 ### Testing Valid server messages are handled as normal and I did some manual testing to push invalid JSON into the webSocketApi, but the code is gnarly and not viable as an actual unit test ## Screenshots N/A ## AI or LLM usage None
This commit is contained in:
parent
a577ae9f1a
commit
cf74736579
3 changed files with 152 additions and 78 deletions
|
|
@ -29,6 +29,7 @@ import org.jellyfin.sdk.api.client.extensions.quickConnectApi
|
|||
import org.jellyfin.sdk.api.client.extensions.systemApi
|
||||
import org.jellyfin.sdk.api.client.extensions.userApi
|
||||
import org.jellyfin.sdk.model.api.AuthenticationResult
|
||||
import org.jellyfin.sdk.model.api.UserDto
|
||||
import org.jellyfin.sdk.model.serializer.toUUIDOrNull
|
||||
import timber.log.Timber
|
||||
import java.time.ZonedDateTime
|
||||
|
|
@ -318,8 +319,17 @@ class ServerRepository
|
|||
*/
|
||||
suspend fun updateUserDto() {
|
||||
val userDto by apiClient.userApi.getCurrentUser()
|
||||
updateUserDto(userDto)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update [currentUserDto] with the specified [UserDto]
|
||||
*
|
||||
* This will only update if the [UserDto] is for the [currentUser]
|
||||
*/
|
||||
fun updateUserDto(userDto: UserDto) {
|
||||
_currentUserDto.update {
|
||||
if (it?.id == userDto.id && currentUser?.id == userDto.id) ServerUserConfig(userDto) else it
|
||||
if (currentUser?.id == userDto.id) ServerUserConfig(userDto) else it
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue