Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 10, 2026

The Capabilities struct now exposes server version information from the OCS capabilities response, enabling downstream clients to adapt behavior based on Nextcloud server version.

Changes

  • Added version properties to Capabilities: major, minor, and patch (non-optional Int64)
  • Parse version from response: Extract values from ocs.data.version.{major,minor,micro} in the capabilities JSON
  • Added test coverage: Validate parsing with valid versions, missing versions, and edge cases

Usage

let capabilities = Capabilities(data: capabilitiesData)
let serverVersion = "\(capabilities.major).\(capabilities.minor).\(capabilities.patch)"
// e.g., "31.0.9"

// Adapt logic based on version
if capabilities.major >= 28 {
    // Use features available in NC 28+
}

The initialization returns nil if version information is absent, consistent with existing validation behavior.

Original prompt

This section details on the original issue you should resolve

<issue_title>Provide Server Version</issue_title>
<issue_description>## Problem

The package currently ignores the server version information returned as part of the capabilities response. Upstream projects may need this information, though, to adapt their business logic and flow to the server version.

Goal

Have the Capabilities struct provide the major, minor and patch version of a server. All of those values are not optional, safe to expect and of type Int64.

Response Reference

An unauthenticated example response by the server for a capabilities request looks like this:

<ocs>
  <meta>
    <status>ok</status>
    <statuscode>200</statuscode>
    <message>OK</message>
  </meta>
  <data>
    <version>
      <major>31</major>
      <minor>0</minor>
      <micro>9</micro>
      <string>31.0.9</string>
      <edition/>
      <extendedSupport/>
    </version>
    <capabilities>
      <bruteforce>
        <delay>800</delay>
        <allow-listed/>
      </bruteforce>
      <app_api>
        <version>5.0.2</version>
      </app_api>
      <theming>
        <name>Debugging Cloud</name>
        <url>http://localhost:8080</url>
        <slogan>Ein Back-End für die Client-Entwicklung</slogan>
        <color>#F0FDBB</color>
        <color-text>#000000</color-text>
        <color-element>#cff926</color-element>
        <color-element-bright>#cff926</color-element-bright>
        <color-element-dark>#F0FDBB</color-element-dark>
        <logo>http://localhost:8080/core/img/logo/logo.svg?v=4</logo>
        <background>#4CCE79</background>
        <background-text>#000000</background-text>
        <background-plain>1</background-plain>
        <background-default>1</background-default>
        <logoheader>http://localhost:8080/core/img/logo/logo.svg?v=4</logoheader>
        <favicon>http://localhost:8080/core/img/logo/logo.svg?v=4</favicon>
      </theming>
    </capabilities>
  </data>
</ocs>

The ocsdataversion tag contains the major, minor and micro children. These are the properties of interest.

Reference

Documentation on the OCS API capabilities endpoint: https://docs.nextcloud.com/server/stable/developer_manual/_static/openapi.html#/operations/core-ocs-get-capabilities</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 10, 2026 15:49
Co-authored-by: i2h3 <142165879+i2h3@users.noreply.github.com>
Co-authored-by: i2h3 <142165879+i2h3@users.noreply.github.com>
Copilot AI changed the title [WIP] Add server version information to Capabilities struct Expose server version information in Capabilities Feb 10, 2026
Copilot AI requested a review from i2h3 February 10, 2026 15:52
@i2h3 i2h3 marked this pull request as ready for review February 11, 2026 08:28
Copilot AI review requested due to automatic review settings February 11, 2026 08:28
@i2h3 i2h3 added the enhancement New feature or request label Feb 11, 2026
@github-project-automation github-project-automation bot moved this to 🧭 Planning evaluation (don't pick) in 💻 Desktop Clients team Feb 11, 2026
@i2h3 i2h3 moved this from 🧭 Planning evaluation (don't pick) to 🏗️ In progress in 💻 Desktop Clients team Feb 11, 2026
@i2h3 i2h3 merged commit 8330deb into main Feb 11, 2026
9 checks passed
@i2h3 i2h3 deleted the copilot/add-server-version-info branch February 11, 2026 08:31
@github-project-automation github-project-automation bot moved this from 🏗️ In progress to ☑️ Done in 💻 Desktop Clients team Feb 11, 2026
Copy link

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

Adds server version information to Capabilities by parsing ocs.data.version from the OCS capabilities response, so downstream clients can gate behavior by Nextcloud version.

Changes:

  • Add major, minor, patch (Int64) to Capabilities
  • Parse version.major, version.minor, version.micro from the capabilities JSON during initialization
  • Update/add tests to validate version parsing and handling of missing version data

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Sources/NextcloudCapabilitiesKit/Capabilities.swift Adds version fields and parsing logic to the main Capabilities initializer.
Tests/NextcloudCapabilitiesKitTests/CapabilitiesTests.swift Adds assertions for version parsing and adds cases for missing/different versions.
Tests/NextcloudCapabilitiesKitTests/Talk/Config/SpreedCallTests.swift Reorders imports (no functional change).
Tests/NextcloudCapabilitiesKitTests/Shares/ShareeTests.swift Reorders imports (no functional change).
Tests/NextcloudCapabilitiesKitTests/Shares/FilesSharingTests.swift Reorders imports (no functional change).
Tests/NextcloudCapabilitiesKitTests/NotifyPush/EndpointsTests.swift Reorders imports (no functional change).
Tests/NextcloudCapabilitiesKitTests/Files/FilesTests.swift Reorders imports (no functional change).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 19 to 21
"capabilities": {
"core": {
"webdav-root": "remote.php/webdav"
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validData JSON string is currently invalid because there’s a trailing comma before the closing } of the capabilities object. JSONSerialization will fail to parse this and the test will fail; remove the trailing comma so the JSON is valid.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: ☑️ Done

Development

Successfully merging this pull request may close these issues.

Provide Server Version

2 participants