From 281db29a6c173c22df762d963fcd53333aafaa9f Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Wed, 23 Oct 2019 14:56:27 +1100 Subject: [PATCH] Update for back-end changes --- .../API/Public Chat/LokiPublicChatMessage.swift | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/SignalServiceKit/src/Loki/API/Public Chat/LokiPublicChatMessage.swift b/SignalServiceKit/src/Loki/API/Public Chat/LokiPublicChatMessage.swift index ef93d8100..bd910cb47 100644 --- a/SignalServiceKit/src/Loki/API/Public Chat/LokiPublicChatMessage.swift +++ b/SignalServiceKit/src/Loki/API/Public Chat/LokiPublicChatMessage.swift @@ -46,6 +46,18 @@ public final class LokiPublicChatMessage : NSObject { public let linkPreviewTitle: String? 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 { @@ -118,10 +130,10 @@ public final class LokiPublicChatMessage : NSObject { } let annotation: JSON = [ "type" : type, "value" : value ] 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 = [ // Fields required by the .NET API - "version" : 1, "type" : type, + "version" : 1, "type" : attachment.dotNETType, // 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 ]