Include attachment IDs in public chat message signature

pull/60/head
Niels Andriesse 6 years ago
parent 52d6b95046
commit 3ffb55fd0e

@ -29,6 +29,7 @@ public final class LokiPublicChatMessage : NSObject {
}
public struct Attachment {
public let serverID: UInt64
public let kind: Kind
public let width: UInt
public let height: UInt
@ -121,9 +122,9 @@ public final class LokiPublicChatMessage : NSObject {
}
// MARK: Convenience
@objc public func addAttachment(kind: String, width: UInt, height: UInt, caption: String, url: String, server: String, serverDisplayName: String) {
@objc public func addAttachment(serverID: UInt64, kind: String, width: UInt, height: UInt, caption: String, url: String, server: String, serverDisplayName: String) {
guard let kind = Attachment.Kind(rawValue: kind) else { preconditionFailure() }
let attachment = Attachment(kind: kind, width: width, height: height, caption: caption, url: url, server: server, serverDisplayName: serverDisplayName)
let attachment = Attachment(serverID: serverID, kind: kind, width: width, height: height, caption: caption, url: url, server: server, serverDisplayName: serverDisplayName)
attachments.append(attachment)
}
@ -135,6 +136,7 @@ public final class LokiPublicChatMessage : NSObject {
string += "\(quotedMessageServerID)"
}
}
string += attachments.map { "\($0.serverID)" }.joined(separator: "")
string += "\(signatureVersion)"
return string.data(using: String.Encoding.utf8)
}

@ -1214,7 +1214,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
TSAttachmentStream *attachment = [TSAttachmentStream fetchObjectWithUniqueID:attachmentID];
if (attachment == nil) { continue; }
// TODO: Videos
[groupMessage addAttachmentWithKind:@"photo" width:@(attachment.imageSize.width).unsignedIntValue height:@(attachment.imageSize.height).unsignedIntValue caption:attachment.caption url:attachment.downloadURL server:publicChat.server serverDisplayName:publicChat.displayName];
[groupMessage addAttachmentWithServerID:attachment.serverId kind:@"photo" width:@(attachment.imageSize.width).unsignedIntValue height:@(attachment.imageSize.height).unsignedIntValue caption:attachment.caption url:attachment.downloadURL server:publicChat.server serverDisplayName:publicChat.displayName];
}
[[LKPublicChatAPI sendMessage:groupMessage toGroup:publicChat.channel onServer:publicChat.server]
.thenOn(OWSDispatch.sendingQueue, ^(LKGroupMessage *groupMessage) {

Loading…
Cancel
Save