session-ios/SessionMessagingKit/Sending & Receiving/Attachments/TSAttachmentPointer+Conversion.swift

25 lines
813 B
Swift
Raw Normal View History

2020-11-20 01:10:53 +01:00
extension TSAttachmentPointer {
public static func from(_ attachment: VisibleMessage.Attachment) -> TSAttachmentPointer {
let kind: TSAttachmentType
switch attachment.kind! {
case .generic: kind = .default
case .voiceMessage: kind = .voiceMessage
}
2020-11-27 00:43:14 +01:00
let result = TSAttachmentPointer(
2020-11-20 01:10:53 +01:00
serverId: 0,
key: attachment.key,
digest: attachment.digest,
byteCount: UInt32(attachment.sizeInBytes!),
contentType: attachment.contentType!,
sourceFilename: attachment.fileName,
caption: attachment.caption,
albumMessageId: nil,
attachmentType: kind,
mediaSize: attachment.size!)
2020-11-27 00:43:14 +01:00
result.downloadURL = attachment.url!
return result
2020-11-20 01:10:53 +01:00
}
}