Simplify attachment processor

We've accepted all attachment types for a long while now.

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent 3252866727
commit 351f9ea263

@ -23,9 +23,8 @@ extern NSString *const kAttachmentDownloadAttachmentIDKey;
*/
@interface OWSAttachmentsProcessor : NSObject
@property (nullable, nonatomic, readonly) NSArray<NSString *> *attachmentIds;
@property (nonatomic, readonly) NSArray<NSString *> *supportedAttachmentIds;
@property (nonatomic, readonly) NSArray<TSAttachmentPointer *> *supportedAttachmentPointers;
@property (nonatomic, readonly) NSArray<NSString *> *attachmentIds;
@property (nonatomic, readonly) NSArray<TSAttachmentPointer *> *attachmentPointers;
@property (nonatomic, readonly) BOOL hasSupportedAttachments;
- (instancetype)init NS_UNAVAILABLE;

@ -53,8 +53,8 @@ static const CGFloat kAttachmentDownloadProgressTheta = 0.001f;
_networkManager = networkManager;
_primaryStorage = primaryStorage;
_supportedAttachmentPointers = @[ attachmentPointer ];
_supportedAttachmentIds = @[ attachmentPointer.uniqueId ];
_attachmentPointers = @[ attachmentPointer ];
_attachmentIds = @[ attachmentPointer.uniqueId ];
return self;
}
@ -74,11 +74,9 @@ static const CGFloat kAttachmentDownloadProgressTheta = 0.001f;
_primaryStorage = primaryStorage;
NSMutableArray<NSString *> *attachmentIds = [NSMutableArray new];
NSMutableArray<TSAttachmentPointer *> *supportedAttachmentPointers = [NSMutableArray new];
NSMutableArray<NSString *> *supportedAttachmentIds = [NSMutableArray new];
NSMutableArray<TSAttachmentPointer *> *attachmentPointers = [NSMutableArray new];
for (OWSSignalServiceProtosAttachmentPointer *attachmentProto in attachmentProtos) {
OWSAssert(attachmentProto.id != 0);
OWSAssert(attachmentProto.key != nil);
OWSAssert(attachmentProto.contentType != nil);
@ -104,15 +102,12 @@ static const CGFloat kAttachmentDownloadProgressTheta = 0.001f;
attachmentType:attachmentType];
[attachmentIds addObject:pointer.uniqueId];
[pointer saveWithTransaction:transaction];
[supportedAttachmentPointers addObject:pointer];
[supportedAttachmentIds addObject:pointer.uniqueId];
[attachmentPointers addObject:pointer];
}
_attachmentIds = [attachmentIds copy];
_supportedAttachmentPointers = [supportedAttachmentPointers copy];
_supportedAttachmentIds = [supportedAttachmentIds copy];
_attachmentPointers = [attachmentPointers copy];
return self;
}
@ -138,7 +133,7 @@ static const CGFloat kAttachmentDownloadProgressTheta = 0.001f;
{
OWSAssert(transaction);
for (TSAttachmentPointer *attachmentPointer in self.supportedAttachmentPointers) {
for (TSAttachmentPointer *attachmentPointer in self.attachmentPointers) {
[self retrieveAttachment:attachmentPointer
message:message
transaction:transaction
@ -434,7 +429,7 @@ static const CGFloat kAttachmentDownloadProgressTheta = 0.001f;
- (BOOL)hasSupportedAttachments
{
return self.supportedAttachmentPointers.count > 0;
return self.attachmentPointers.count > 0;
}
@end

@ -561,11 +561,10 @@ NS_ASSUME_NONNULL_BEGIN
return;
}
TSIncomingMessage *_Nullable createdMessage =
[self handleReceivedEnvelope:envelope
withDataMessage:dataMessage
attachmentIds:attachmentsProcessor.supportedAttachmentIds
transaction:transaction];
TSIncomingMessage *_Nullable createdMessage = [self handleReceivedEnvelope:envelope
withDataMessage:dataMessage
attachmentIds:attachmentsProcessor.attachmentIds
transaction:transaction];
if (!createdMessage) {
return;
@ -1111,7 +1110,7 @@ NS_ASSUME_NONNULL_BEGIN
// if (!attachmentsProcessor.hasSupportedAttachments) {
// attachments = @[];
// } else {
// attachments = attachmentsProcessor.supportedAttachmentPointers;
// attachments = attachmentsProcessor.attachmentPointers;
// }
//
// [attachmentsProcessor fetchAttachmentsForMessage:nil

Loading…
Cancel
Save