mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Don't send crash reports as json (#84)
This is a workaround for jellyfin/jellyfin-web#7267 to ensure the client logs are not valid JSON and can be rendered on the `10.11.x` web UI. Related to #82
This commit is contained in:
parent
f1f6b729aa
commit
af0e853c21
1 changed files with 15 additions and 2 deletions
|
|
@ -15,7 +15,9 @@ import org.jellyfin.sdk.Jellyfin
|
|||
import org.jellyfin.sdk.api.client.extensions.clientLogApi
|
||||
import org.jellyfin.sdk.api.okhttp.OkHttpFactory
|
||||
import org.jellyfin.sdk.createJellyfin
|
||||
import org.json.JSONObject
|
||||
import timber.log.Timber
|
||||
import java.util.Date
|
||||
|
||||
@AutoService(ReportSenderFactory::class)
|
||||
class CrashReportSenderFactory : ReportSenderFactory {
|
||||
|
|
@ -53,11 +55,22 @@ class CrashReportSender : ReportSender {
|
|||
minimumServerVersion = Jellyfin.minimumVersion
|
||||
}.createApi(baseUrl = serverUrl, accessToken = accessToken)
|
||||
|
||||
val obj = JSONObject()
|
||||
for ((key, value) in errorContent.toMap()) {
|
||||
obj.put(key, value)
|
||||
}
|
||||
val jsonStr = obj.toString(2)
|
||||
runBlocking {
|
||||
val filename =
|
||||
api.clientLogApi
|
||||
.logFile(errorContent.toJSON())
|
||||
.content.fileName
|
||||
.logFile(
|
||||
"""
|
||||
---
|
||||
Date: ${Date()}
|
||||
---
|
||||
|
||||
""".trimIndent() + jsonStr,
|
||||
).content.fileName
|
||||
Timber.i("Sent report to $serverUrl, filename=$filename")
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue