Reverted a change to the type for the serverId of a TSAttachment (change didn't match the protobuf)

pull/592/head
Morgan Pretty 3 years ago
parent c44256b1d6
commit 5710fe18fb

@ -66,7 +66,7 @@ public final class AttachmentUploadJob : NSObject, Job, NSCoding { // NSObject/N
guard let stream = TSAttachment.fetch(uniqueId: attachmentID) as? TSAttachmentStream else {
return handleFailure(error: Error.noAttachment)
}
guard !stream.isUploaded else { return handleSuccess(stream.serverId) } // Should never occur
guard !stream.isUploaded else { return handleSuccess("\(stream.serverId)") } // Should never occur
let storage = SNMessagingKitConfiguration.shared.storage
if let openGroup = storage.getOpenGroup(for: threadID) {
@ -124,8 +124,13 @@ public final class AttachmentUploadJob : NSObject, Job, NSCoding { // NSObject/N
stream.isUploaded = false
stream.save()
upload(data).done(on: DispatchQueue.global(qos: .userInitiated)) { fileId in
guard let intFileId: UInt64 = UInt64(fileId) else {
onFailure?(HTTP.Error.parsingFailed)
return
}
let downloadURL = "\(FileServerAPI.server)/files/\(fileId)"
stream.serverId = fileId
stream.serverId = intFileId
stream.isUploaded = true
stream.downloadURL = downloadURL
stream.save()

@ -23,7 +23,7 @@ typedef NS_ENUM(NSUInteger, TSAttachmentType) {
// The attachmentSchemaVersion and serverId properties only apply to
// TSAttachmentPointer, which can be distinguished by the isDownloaded
// property.
@property (atomic, readwrite) NSString *serverId;
@property (atomic, readwrite) UInt64 serverId;
@property (atomic, readwrite, nullable) NSData *encryptionKey;
@property (nonatomic, readonly) NSString *contentType;
@property (atomic, readwrite) BOOL isDownloaded;

@ -27,7 +27,7 @@ NSUInteger const TSAttachmentSchemaVersion = 4;
// This constructor is used for new instances of TSAttachmentPointer,
// i.e. undownloaded incoming attachments.
- (instancetype)initWithServerId:(NSString *)serverId
- (instancetype)initWithServerId:(UInt64)serverId
encryptionKey:(nullable NSData *)encryptionKey
byteCount:(UInt32)byteCount
contentType:(NSString *)contentType

@ -170,7 +170,7 @@ NS_ASSUME_NONNULL_BEGIN
// uniqueId.
if (attachmentSchemaVersion < 2 && self.serverId == 0) {
// For legacy instances, try to parse the serverId from the uniqueId.
self.serverId = self.uniqueId;
self.serverId = (UInt64)[self.uniqueId integerValue];
}
}

Loading…
Cancel
Save