|
|
|
@ -6,6 +6,7 @@
|
|
|
|
|
#import <SignalServiceKit/MIMETypeUtil.h>
|
|
|
|
|
#import <SignalServiceKit/OWSMessageSender.h>
|
|
|
|
|
#import <SignalServiceKit/TSAccountManager.h>
|
|
|
|
|
#import <SignalServiceKit/TSAttachmentPointer.h>
|
|
|
|
|
#import <SignalServiceKit/TSAttachmentStream.h>
|
|
|
|
|
#import <SignalServiceKit/TSIncomingMessage.h>
|
|
|
|
|
#import <SignalServiceKit/TSMessage.h>
|
|
|
|
@ -27,32 +28,9 @@
|
|
|
|
|
thumbnailImage:attachmentStream.thumbnailImage
|
|
|
|
|
contentType:attachmentStream.contentType
|
|
|
|
|
sourceFilename:attachmentStream.sourceFilename
|
|
|
|
|
attachmentStream:attachmentStream];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
|
|
|
|
authorId:(NSString *)authorId
|
|
|
|
|
body:(nullable NSString *)body
|
|
|
|
|
thumbnailImage:(nullable UIImage *)thumbnailImage
|
|
|
|
|
contentType:(nullable NSString *)contentType
|
|
|
|
|
sourceFilename:(nullable NSString *)sourceFilename
|
|
|
|
|
attachmentStream:(nullable TSAttachmentStream *)attachmentStream
|
|
|
|
|
{
|
|
|
|
|
self = [super init];
|
|
|
|
|
if (!self) {
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_timestamp = timestamp;
|
|
|
|
|
_authorId = authorId;
|
|
|
|
|
_body = body;
|
|
|
|
|
_thumbnailImage = thumbnailImage;
|
|
|
|
|
_contentType = contentType;
|
|
|
|
|
_sourceFilename = sourceFilename;
|
|
|
|
|
_attachmentStream = attachmentStream;
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
attachmentStream:attachmentStream
|
|
|
|
|
thumbnailAttachmentPointer:nil
|
|
|
|
|
thumbnailDownloadFailed:NO];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithQuotedMessage:(TSQuotedMessage *)quotedMessage
|
|
|
|
@ -61,7 +39,9 @@
|
|
|
|
|
OWSAssert(quotedMessage.quotedAttachments.count <= 1);
|
|
|
|
|
OWSAttachmentInfo *attachmentInfo = quotedMessage.quotedAttachments.firstObject;
|
|
|
|
|
|
|
|
|
|
BOOL thumbnailDownloadFailed = NO;
|
|
|
|
|
UIImage *_Nullable thumbnailImage;
|
|
|
|
|
TSAttachmentPointer *attachmentPointer;
|
|
|
|
|
if (attachmentInfo.thumbnailAttachmentStreamId) {
|
|
|
|
|
TSAttachment *attachment =
|
|
|
|
|
[TSAttachment fetchObjectWithUniqueID:attachmentInfo.thumbnailAttachmentStreamId transaction:transaction];
|
|
|
|
@ -71,6 +51,16 @@
|
|
|
|
|
attachmentStream = (TSAttachmentStream *)attachment;
|
|
|
|
|
thumbnailImage = attachmentStream.image;
|
|
|
|
|
}
|
|
|
|
|
} else if (attachmentInfo.thumbnailAttachmentPointerId) {
|
|
|
|
|
// download failed, or hasn't completed yet.
|
|
|
|
|
TSAttachment *attachment = [TSAttachment fetchObjectWithUniqueID:attachmentInfo.thumbnailAttachmentPointerId transaction:transaction];
|
|
|
|
|
|
|
|
|
|
if ([attachment isKindOfClass:[TSAttachmentPointer class]]) {
|
|
|
|
|
attachmentPointer = (TSAttachmentPointer *)attachment;
|
|
|
|
|
if (attachmentPointer.state == TSAttachmentPointerStateFailed) {
|
|
|
|
|
thumbnailDownloadFailed = YES;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [self initWithTimestamp:quotedMessage.timestamp
|
|
|
|
@ -79,7 +69,37 @@
|
|
|
|
|
thumbnailImage:thumbnailImage
|
|
|
|
|
contentType:attachmentInfo.contentType
|
|
|
|
|
sourceFilename:attachmentInfo.sourceFilename
|
|
|
|
|
attachmentStream:nil];
|
|
|
|
|
attachmentStream:nil
|
|
|
|
|
thumbnailAttachmentPointer:attachmentPointer
|
|
|
|
|
thumbnailDownloadFailed:thumbnailDownloadFailed];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithTimestamp:(uint64_t)timestamp
|
|
|
|
|
authorId:(NSString *)authorId
|
|
|
|
|
body:(nullable NSString *)body
|
|
|
|
|
thumbnailImage:(nullable UIImage *)thumbnailImage
|
|
|
|
|
contentType:(nullable NSString *)contentType
|
|
|
|
|
sourceFilename:(nullable NSString *)sourceFilename
|
|
|
|
|
attachmentStream:(nullable TSAttachmentStream *)attachmentStream
|
|
|
|
|
thumbnailAttachmentPointer:(nullable TSAttachmentPointer *)thumbnailAttachmentPointer
|
|
|
|
|
thumbnailDownloadFailed:(BOOL)thumbnailDownloadFailed
|
|
|
|
|
{
|
|
|
|
|
self = [super init];
|
|
|
|
|
if (!self) {
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_timestamp = timestamp;
|
|
|
|
|
_authorId = authorId;
|
|
|
|
|
_body = body;
|
|
|
|
|
_thumbnailImage = thumbnailImage;
|
|
|
|
|
_contentType = contentType;
|
|
|
|
|
_sourceFilename = sourceFilename;
|
|
|
|
|
_attachmentStream = attachmentStream;
|
|
|
|
|
_thumbnailAttachmentPointer = thumbnailAttachmentPointer;
|
|
|
|
|
_thumbnailDownloadFailed = thumbnailDownloadFailed;
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (TSQuotedMessage *)buildQuotedMessage
|
|
|
|
|