From 8a2dbb99f059c019d6879e45d118b0540e497fcb Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Fri, 29 Dec 2023 13:03:55 +0800 Subject: [PATCH] Fix comments not showing after commenting --- .../com/hippo/ehviewer/client/EhEngine.kt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/client/EhEngine.kt b/app/src/main/kotlin/com/hippo/ehviewer/client/EhEngine.kt index 75774fbed..42d5e630b 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/client/EhEngine.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/client/EhEngine.kt @@ -254,13 +254,18 @@ object EhEngine { append("edit_comment", id.toString()) } } - }.fetchUsingAsText { - val document = Jsoup.parse(this) - val elements = document.select("#chd + p") - if (elements.size > 0) { - throw EhException(elements[0].text()) + }.execute { response -> + // Ktor does not handle POST redirect, we need to do it manually + // https://youtrack.jetbrains.com/issue/KTOR-478 + val location = response.headers["Location"] ?: url + ehRequest(location, url).fetchUsingAsText { + val document = Jsoup.parse(this) + val elements = document.select("#chd + p") + if (elements.size > 0) { + throw EhException(elements[0].text()) + } + GalleryDetailParser.parseComments(document) } - GalleryDetailParser.parseComments(document) } suspend fun modifyFavorites(gid: Long, token: String?, dstCat: Int = -1, note: String = "") {