From f5d90081ff02e90e5a98a492f2e01823b17869e3 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Mon, 26 Feb 2024 17:21:33 +0100 Subject: [PATCH] fix: Provide v2/instance configuration defaults (#474) Some servers don't include a `urls` or `translation` block, which was preventing parsing of the block, and falling back to the v1 instance data. Fix this by providing sensible defaults. --- .../main/kotlin/app/pachli/core/network/model/InstanceV2.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/network/src/main/kotlin/app/pachli/core/network/model/InstanceV2.kt b/core/network/src/main/kotlin/app/pachli/core/network/model/InstanceV2.kt index 208b67f9e..0f2c60c75 100644 --- a/core/network/src/main/kotlin/app/pachli/core/network/model/InstanceV2.kt +++ b/core/network/src/main/kotlin/app/pachli/core/network/model/InstanceV2.kt @@ -101,8 +101,9 @@ data class ThumbnailVersions( @JsonClass(generateAdapter = true) data class Configuration( + // May be missing (e.g., Friendica), so provide a default /** URLs of interest for clients apps. */ - val urls: InstanceV2Urls, + val urls: InstanceV2Urls = InstanceV2Urls(), /** Limits related to accounts. */ val accounts: InstanceV2Accounts, @@ -116,8 +117,9 @@ data class Configuration( /** Limits related to polls. */ val polls: InstanceV2Polls, + // May be missing, so provide a default /** Hints related to translation. */ - val translation: InstanceV2Translation, + val translation: InstanceV2Translation = InstanceV2Translation(enabled = false), ) @JsonClass(generateAdapter = true)