Skip to content

Commit 5432a08

Browse files
committed
Support unique ID for MTAttachment
1 parent ec3857a commit 5432a08

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Sources/MailTMSwift/MTMessage.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public struct MTMessage: Codable {
108108

109109
public struct MTAttachment: Codable {
110110

111-
public var id, filename, contentType, disposition: String
111+
public var localId, filename, contentType, disposition: String
112112
public let transferEncoding: String
113113
public let related: Bool
114114
public let size: Int
@@ -122,7 +122,7 @@ public struct MTAttachment: Codable {
122122
related: Bool,
123123
size: Int,
124124
downloadURL: String) {
125-
self.id = id
125+
self.localId = id
126126
self.filename = filename
127127
self.contentType = contentType
128128
self.disposition = disposition
@@ -133,8 +133,10 @@ public struct MTAttachment: Codable {
133133
}
134134

135135
enum CodingKeys: String, CodingKey {
136-
case id, filename, contentType, disposition, transferEncoding, related, size
136+
// Server returned ID is not unique. Still we save the returned ID for other purposes.
137+
case localId = "id"
137138
case downloadURL = "downloadUrl"
139+
case filename, contentType, disposition, transferEncoding, related, size
138140
}
139141
}
140142

@@ -178,6 +180,10 @@ extension MTMessage: Hashable, Identifiable {
178180
}
179181

180182
extension MTAttachment: Hashable, Identifiable {
183+
184+
public var id: Int {
185+
hashValue
186+
}
181187

182188
public static func == (lhs: MTAttachment, rhs: MTAttachment) -> Bool {
183189
lhs.id == rhs.id

0 commit comments

Comments
 (0)