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.
This commit is contained in:
Nik Clayton 2024-02-26 17:21:33 +01:00 committed by GitHub
parent 486acecfe7
commit f5d90081ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -101,8 +101,9 @@ data class ThumbnailVersions(
@JsonClass(generateAdapter = true) @JsonClass(generateAdapter = true)
data class Configuration( data class Configuration(
// May be missing (e.g., Friendica), so provide a default
/** URLs of interest for clients apps. */ /** URLs of interest for clients apps. */
val urls: InstanceV2Urls, val urls: InstanceV2Urls = InstanceV2Urls(),
/** Limits related to accounts. */ /** Limits related to accounts. */
val accounts: InstanceV2Accounts, val accounts: InstanceV2Accounts,
@ -116,8 +117,9 @@ data class Configuration(
/** Limits related to polls. */ /** Limits related to polls. */
val polls: InstanceV2Polls, val polls: InstanceV2Polls,
// May be missing, so provide a default
/** Hints related to translation. */ /** Hints related to translation. */
val translation: InstanceV2Translation, val translation: InstanceV2Translation = InstanceV2Translation(enabled = false),
) )
@JsonClass(generateAdapter = true) @JsonClass(generateAdapter = true)