Skip to content

Conversation

@rfc2822
Copy link
Member

@rfc2822 rfc2822 commented Nov 17, 2025

Purpose

Refactor Nextcloud Login Flow to Ktor (because we want to rewrite everything to Ktor).

Short description

  • Refactored NextcloudLoginFlow to use Ktor
    • Uses Kotlin Serialization for JSON parsing
  • Refactored NextcloudLoginModel to use the new login flow class

To 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

  • The PR has a proper title, description and label.
  • I have self-reviewed the PR.
  • I have added documentation to complex functions and functions that can be used by other modules.
  • I have added reasonable tests or consciously decided to not add tests.

- 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
@rfc2822 rfc2822 linked an issue Nov 17, 2025 that may be closed by this pull request
@rfc2822 rfc2822 self-assigned this Nov 17, 2025
@rfc2822 rfc2822 added the refactoring Internal improvement of existing functions label Nov 17, 2025
@rfc2822 rfc2822 requested a review from Copilot November 17, 2025 12:26
@rfc2822 rfc2822 changed the title 1812-ktor-use-ktor-for-nextcloud-login-flow Use Ktor for Nextcloud Login Flow Nov 17, 2025
Copilot finished reviewing on behalf of rfc2822 November 17, 2025 12:30
Copy link
Contributor

Copilot AI left a 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 NextcloudLoginFlow from OkHttp to Ktor HTTP client with automatic JSON deserialization via Kotlin Serialization
  • Updated NextcloudLoginModel to use Ktor's Url type instead of OkHttp's HttpUrl
  • 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.

@rfc2822 rfc2822 force-pushed the 1812-ktor-use-ktor-for-nextcloud-login-flow branch from 145cc6d to 8580fca Compare November 17, 2025 12:37
# Conflicts:
#	app/src/main/kotlin/at/bitfire/davdroid/network/NextcloudLoginFlow.kt
@rfc2822 rfc2822 marked this pull request as ready for review November 17, 2025 12:40
@rfc2822 rfc2822 requested a review from a team as a code owner November 17, 2025 12:40
@sunkup
Copy link
Member

sunkup commented Nov 20, 2025

Needs a merge, there is still the empty HttpClient file.

@sunkup sunkup marked this pull request as draft November 20, 2025 10:56
# Conflicts:
#	app/src/main/kotlin/at/bitfire/davdroid/network/HttpClient.kt
#	gradle/libs.versions.toml
@rfc2822 rfc2822 requested a review from Copilot November 25, 2025 11:13
Copilot finished reviewing on behalf of rfc2822 November 25, 2025 11:17
Copy link
Contributor

Copilot AI left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Internal improvement of existing functions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Ktor] Use Ktor for Nextcloud Login Flow

2 participants