-
-
Notifications
You must be signed in to change notification settings - Fork 103
Use Ktor for Nextcloud Login Flow #1817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main-ose
Are you sure you want to change the base?
Conversation
- Replace OkHttp with Ktor for HTTP requests - Update URL handling to use Ktor's `Url` class - Adjust `postForJson` method to use Ktor's HTTP client - Refactor URL building logic for login flow initiation
- Migrate to Ktor's ContentNegotiation plugin for JSON handling - Update dependencies and configuration for Ktor serialization - Refactor `NextcloudLoginFlow` to use Ktor's JSON serialization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the Nextcloud Login Flow implementation from OkHttp to Ktor, using Kotlin Serialization for JSON parsing instead of manual JSON handling with JSONObject.
Key changes:
- Migrated
NextcloudLoginFlowfrom OkHttp to Ktor HTTP client with automatic JSON deserialization via Kotlin Serialization - Updated
NextcloudLoginModelto use Ktor'sUrltype instead of OkHttp'sHttpUrl - Made Conscrypt loading conditional to support unit tests where it's unavailable
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| gradle/libs.versions.toml | Added Ktor content negotiation and kotlinx serialization dependencies, plus Kotlin serialization plugin |
| app/build.gradle.kts | Applied Kotlin serialization plugin and added Ktor serialization dependencies |
| app/src/main/kotlin/at/bitfire/davdroid/network/NextcloudLoginFlow.kt | Refactored from OkHttp to Ktor with Kotlin Serialization data classes for JSON responses |
| app/src/main/kotlin/at/bitfire/davdroid/ui/setup/NextcloudLoginModel.kt | Updated to use Ktor Url type and simplified URL validation logic |
| app/src/main/kotlin/at/bitfire/davdroid/network/HttpClientBuilder.kt | Added ContentNegotiation plugin with JSON serialization support to Ktor client builder |
| app/src/main/kotlin/at/bitfire/davdroid/network/ConscryptIntegration.kt | Added availability check before loading Conscrypt to enable unit tests |
| app/src/test/kotlin/at/bitfire/davdroid/network/NextcloudLoginFlowTest.kt | Added unit tests for URL transformation logic in login flow |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
app/src/test/kotlin/at/bitfire/davdroid/network/NextcloudLoginFlowTest.kt
Outdated
Show resolved
Hide resolved
app/src/main/kotlin/at/bitfire/davdroid/ui/setup/NextcloudLoginModel.kt
Outdated
Show resolved
Hide resolved
145cc6d to
8580fca
Compare
# Conflicts: # app/src/main/kotlin/at/bitfire/davdroid/network/NextcloudLoginFlow.kt
|
Needs a merge, there is still the empty HttpClient file. |
# Conflicts: # app/src/main/kotlin/at/bitfire/davdroid/network/HttpClient.kt # gradle/libs.versions.toml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Purpose
Refactor Nextcloud Login Flow to Ktor (because we want to rewrite everything to Ktor).
Short description
NextcloudLoginFlowto use KtorNextcloudLoginModelto use the new login flow classTo allow unit tests that include a
HttpClientBuilder, Conscrypt is now only loaded when it's available (and it's not available in unit tests).Checklist