Adapt maxTootChars to new API

Use JSON key configuration.statuses.max_characters instead of max_toot_chars
This commit is contained in:
vollkorntomate 2022-11-10 18:07:29 +01:00
parent 96d2ff3a2b
commit 92ef66febc
No known key found for this signature in database
GPG key ID: 87384A836B85D103
2 changed files with 24 additions and 4 deletions

View file

@ -36,6 +36,6 @@ private extension Instance {
stats: record.stats,
thumbnail: record.thumbnail,
contactAccount: contactAccount,
maxTootChars: record.maxTootChars)
configuration: Configuration(statuses: Configuration.Statuses(maxCharacters: record.maxTootChars)))
}
}

View file

@ -13,6 +13,23 @@ public struct Instance: Codable, Hashable {
public let domainCount: Int
}
public struct Configuration: Codable, Hashable {
// swiftlint:disable:next nesting
public struct Statuses: Codable, Hashable {
public let maxCharacters: Int?
public init(maxCharacters: Int?) {
self.maxCharacters = maxCharacters
}
}
public let statuses: Statuses?
public init(statuses: Statuses?) {
self.statuses = statuses
}
}
public let uri: String
public let title: String
public let description: String
@ -27,7 +44,10 @@ public struct Instance: Codable, Hashable {
public let stats: Stats
public let thumbnail: UnicodeURL?
public let contactAccount: Account?
public let maxTootChars: Int?
public var maxTootChars: Int? {
configuration?.statuses?.maxCharacters
}
public let configuration: Configuration?
public init(uri: String,
title: String,
@ -39,7 +59,7 @@ public struct Instance: Codable, Hashable {
stats: Instance.Stats,
thumbnail: UnicodeURL?,
contactAccount: Account?,
maxTootChars: Int?) {
configuration: Configuration?) {
self.uri = uri
self.title = title
self.description = description
@ -50,7 +70,7 @@ public struct Instance: Codable, Hashable {
self.stats = stats
self.thumbnail = thumbnail
self.contactAccount = contactAccount
self.maxTootChars = maxTootChars
self.configuration = configuration
}
}