From e9e2b6415ffe84602a4c5e8f7136b869fe268846 Mon Sep 17 00:00:00 2001 From: davidoskky Date: Sat, 12 Apr 2025 22:43:24 +0200 Subject: [PATCH 1/2] Support SSE for source updates This uses the Server Side Events added in Selfoss API 6.1.0 when calling GET /update This change only supports the new response format but provides no change for the users. The older versions are still supported. --- .../bou/amine/apps/readerforselfossv2/rest/SelfossApi.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/rest/SelfossApi.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/rest/SelfossApi.kt index 9bab495..cc3118e 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/rest/SelfossApi.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/rest/SelfossApi.kt @@ -19,6 +19,7 @@ import io.ktor.client.plugins.cookies.HttpCookies import io.ktor.client.plugins.logging.LogLevel import io.ktor.client.plugins.logging.Logger import io.ktor.client.plugins.logging.Logging +import io.ktor.client.plugins.sse.SSE import io.ktor.client.request.get import io.ktor.client.request.headers import io.ktor.client.request.parameter @@ -89,6 +90,7 @@ class SelfossApi( } } } + install(SSE) expectSuccess = false } @@ -384,6 +386,12 @@ class SelfossApi( ) } } + headers { + append( + HttpHeaders.Accept, + "text/event-stream", + ) + } }, ) -- 2.34.1 From 4b9899c04eefac5edd2c4b570ca0d657531a6325 Mon Sep 17 00:00:00 2001 From: davidoskky Date: Sat, 12 Apr 2025 23:00:24 +0200 Subject: [PATCH 2/2] Remove login information from update request Removed the username and password in the GET /update request. The endpoint does not require authentication and it is unsafe to transmit login credentials over GET requests. --- .../readerforselfossv2/rest/SelfossApi.kt | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/rest/SelfossApi.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/rest/SelfossApi.kt index cc3118e..bd0447f 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/rest/SelfossApi.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/rest/SelfossApi.kt @@ -365,27 +365,6 @@ class SelfossApi( suspend fun update(): StatusAndData = bodyOrFailure( client.tryToGet(url("/update")) { - if (!shouldHavePostLogin()) { - parameter("username", appSettingsService.getUserName()) - parameter("password", appSettingsService.getPassword()) - } - if (appSettingsService - .getBasicUserName() - .isNotEmpty() && - appSettingsService.getBasicPassword().isNotEmpty() - ) { - headers { - append( - HttpHeaders.Authorization, - constructBasicAuthValue( - BasicAuthCredentials( - username = appSettingsService.getBasicUserName(), - password = appSettingsService.getBasicPassword(), - ), - ), - ) - } - } headers { append( HttpHeaders.Accept, -- 2.34.1