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, stats: record.stats,
thumbnail: record.thumbnail, thumbnail: record.thumbnail,
contactAccount: contactAccount, 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 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 uri: String
public let title: String public let title: String
public let description: String public let description: String
@ -27,7 +44,10 @@ public struct Instance: Codable, Hashable {
public let stats: Stats public let stats: Stats
public let thumbnail: UnicodeURL? public let thumbnail: UnicodeURL?
public let contactAccount: Account? public let contactAccount: Account?
public let maxTootChars: Int? public var maxTootChars: Int? {
configuration?.statuses?.maxCharacters
}
public let configuration: Configuration?
public init(uri: String, public init(uri: String,
title: String, title: String,
@ -39,7 +59,7 @@ public struct Instance: Codable, Hashable {
stats: Instance.Stats, stats: Instance.Stats,
thumbnail: UnicodeURL?, thumbnail: UnicodeURL?,
contactAccount: Account?, contactAccount: Account?,
maxTootChars: Int?) { configuration: Configuration?) {
self.uri = uri self.uri = uri
self.title = title self.title = title
self.description = description self.description = description
@ -50,7 +70,7 @@ public struct Instance: Codable, Hashable {
self.stats = stats self.stats = stats
self.thumbnail = thumbnail self.thumbnail = thumbnail
self.contactAccount = contactAccount self.contactAccount = contactAccount
self.maxTootChars = maxTootChars self.configuration = configuration
} }
} }