Update for back-end changes

pull/570/head
Niels Andriesse 6 years ago
parent 060eac7bcc
commit 281db29a6c

@ -46,6 +46,18 @@ public final class LokiPublicChatMessage : NSObject {
public let linkPreviewTitle: String? public let linkPreviewTitle: String?
public enum Kind : String { case attachment, linkPreview = "preview" } public enum Kind : String { case attachment, linkPreview = "preview" }
public var dotNETType: String {
if contentType.hasPrefix("image") {
return "photo"
} else if contentType.hasPrefix("video") {
return "video"
} else if contentType.hasPrefix("audio") {
return "audio"
} else {
return "other"
}
}
} }
public struct Signature { public struct Signature {
@ -118,10 +130,10 @@ public final class LokiPublicChatMessage : NSObject {
} }
let annotation: JSON = [ "type" : type, "value" : value ] let annotation: JSON = [ "type" : type, "value" : value ]
let attachmentAnnotations: [JSON] = attachments.map { attachment in let attachmentAnnotations: [JSON] = attachments.map { attachment in
let type = attachment.contentType.hasPrefix("image") ? "photo" : "video" // TODO: We should do better than this let type: String
var attachmentValue: JSON = [ var attachmentValue: JSON = [
// Fields required by the .NET API // Fields required by the .NET API
"version" : 1, "type" : type, "version" : 1, "type" : attachment.dotNETType,
// Custom fields // Custom fields
"lokiType" : attachment.kind.rawValue, "server" : attachment.server, "id" : attachment.serverID, "contentType" : attachment.contentType, "size" : attachment.size, "fileName" : attachment.fileName, "width" : attachment.width, "height" : attachment.height, "url" : attachment.url "lokiType" : attachment.kind.rawValue, "server" : attachment.server, "id" : attachment.serverID, "contentType" : attachment.contentType, "size" : attachment.size, "fileName" : attachment.fileName, "width" : attachment.width, "height" : attachment.height, "url" : attachment.url
] ]

Loading…
Cancel
Save