Remove unnecessary attachment decoding code

For some reason, creating a URL from a string decoded from the container
was producing URL objects that could not be round-tripped through
PropertyListEncoder/Decoder. Decoding a URL directly from the container
works correctly.
This commit is contained in:
Shadowfacts 2020-04-12 12:52:51 -04:00
parent 465aedd43f
commit a0e95d4577
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 4 additions and 12 deletions

View File

@ -29,18 +29,10 @@ public class Attachment: Codable {
let container = try decoder.container(keyedBy: CodingKeys.self) let container = try decoder.container(keyedBy: CodingKeys.self)
self.id = try container.decode(String.self, forKey: .id) self.id = try container.decode(String.self, forKey: .id)
self.kind = try container.decode(Kind.self, forKey: .kind) self.kind = try container.decode(Kind.self, forKey: .kind)
self.url = URL(string: try container.decode(String.self, forKey: .url))! self.url = try container.decode(URL.self, forKey: .url)
self.previewURL = URL(string: try container.decode(String.self, forKey: .previewURL))! self.previewURL = try container.decode(URL.self, forKey: .previewURL)
if let remote = try? container.decode(String.self, forKey: .remoteURL) { self.remoteURL = try? container.decode(URL.self, forKey: .remoteURL)
self.remoteURL = URL(string: remote)! self.textURL = try? container.decode(URL.self, forKey: .textURL)
} else {
self.remoteURL = nil
}
if let text = try? container.decode(String.self, forKey: .textURL) {
self.textURL = URL(string: text)!
} else {
self.textURL = nil
}
self.meta = try? container.decode(Metadata.self, forKey: .meta) self.meta = try? container.decode(Metadata.self, forKey: .meta)
self.description = try? container.decode(String.self, forKey: .description) self.description = try? container.decode(String.self, forKey: .description)
} }