Add debug UI for multi-image sends.
This commit is contained in:
parent
078503ff2e
commit
d04f1e6e36
|
@ -127,6 +127,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
actionBlock:^{
|
||||
[DebugUIMessages sendNTextMessagesInThread:thread];
|
||||
}],
|
||||
[OWSTableItem itemWithTitle:@"Send multi-image messages"
|
||||
actionBlock:^{
|
||||
[DebugUIMessages sendMultiImageMessageInThread:thread];
|
||||
}],
|
||||
[OWSTableItem itemWithTitle:@"Select Fake"
|
||||
actionBlock:^{
|
||||
[DebugUIMessages selectFakeAction:thread];
|
||||
|
@ -246,7 +250,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
[self.messageSenderJobQueue addMessage:syncGroupsRequestMessage transaction:transaction];
|
||||
}];
|
||||
|
||||
}],
|
||||
[OWSTableItem itemWithTitle:@"Message with stalled timer"
|
||||
actionBlock:^{
|
||||
|
@ -3357,7 +3360,7 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
// style them indistinguishably from a separate text message.
|
||||
attachment.captionText = [self randomCaptionText];
|
||||
}
|
||||
[ThreadUtil enqueueMessageWithAttachment:attachment inThread:thread quotedReplyModel:nil ignoreErrors:YES];
|
||||
[ThreadUtil enqueueMessageWithAttachment:attachment inThread:thread quotedReplyModel:nil];
|
||||
}
|
||||
|
||||
+ (SSKProtoEnvelope *)createEnvelopeForThread:(TSThread *)thread
|
||||
|
@ -4631,6 +4634,41 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
}
|
||||
}
|
||||
|
||||
+ (void)sendMultiImageMessageInThread:(TSThread *)thread
|
||||
{
|
||||
OWSLogInfo(@"");
|
||||
|
||||
const uint32_t kMinImageCount = 2;
|
||||
const uint32_t kMaxImageCount = 10;
|
||||
uint32_t imageCount = kMinImageCount + arc4random_uniform(kMaxImageCount - kMinImageCount);
|
||||
|
||||
NSMutableArray<SignalAttachment *> *attachments = [NSMutableArray new];
|
||||
for (uint32_t i = 0; i < imageCount; i++) {
|
||||
UIColor *imageColor = [UIColor colorWithRed:arc4random_uniform(256) / 255.f
|
||||
green:arc4random_uniform(256) / 255.f
|
||||
blue:arc4random_uniform(256) / 255.f
|
||||
alpha:1.f];
|
||||
UIImage *image = [UIImage imageWithColor:imageColor size:CGSizeMake(10.f, 10.f)];
|
||||
OWSAssertDebug(image);
|
||||
NSData *pngData = UIImagePNGRepresentation(image);
|
||||
OWSAssertDebug(pngData);
|
||||
NSString *filePath = [OWSFileSystem temporaryFilePathWithFileExtension:@"png"];
|
||||
[pngData writeToFile:filePath atomically:YES];
|
||||
OWSAssertDebug([NSFileManager.defaultManager fileExistsAtPath:filePath]);
|
||||
DataSource *dataSource = [DataSourcePath dataSourceWithFilePath:filePath shouldDeleteOnDeallocation:YES];
|
||||
SignalAttachment *attachment = [SignalAttachment attachmentWithDataSource:dataSource
|
||||
dataUTI:(NSString *)kUTTypePNG
|
||||
imageQuality:TSImageQualityOriginal];
|
||||
[attachments addObject:attachment];
|
||||
}
|
||||
|
||||
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
TSOutgoingMessage *message =
|
||||
[ThreadUtil enqueueMessageWithAttachments:attachments inThread:thread quotedReplyModel:nil];
|
||||
OWSLogError(@"timestamp: %llu.", message.timestamp);
|
||||
}];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
|
|
@ -53,10 +53,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
inThread:(TSThread *)thread
|
||||
quotedReplyModel:(nullable OWSQuotedReplyModel *)quotedReplyModel;
|
||||
|
||||
+ (TSOutgoingMessage *)enqueueMessageWithAttachment:(SignalAttachment *)attachment
|
||||
inThread:(TSThread *)thread
|
||||
quotedReplyModel:(nullable OWSQuotedReplyModel *)quotedReplyModel
|
||||
ignoreErrors:(BOOL)ignoreErrors;
|
||||
+ (TSOutgoingMessage *)enqueueMessageWithAttachments:(NSArray<SignalAttachment *> *)attachments
|
||||
inThread:(TSThread *)thread
|
||||
quotedReplyModel:(nullable OWSQuotedReplyModel *)quotedReplyModel;
|
||||
|
||||
+ (TSOutgoingMessage *)enqueueMessageWithContactShare:(OWSContact *)contactShare inThread:(TSThread *)thread;
|
||||
+ (void)enqueueLeaveGroupMessageInThread:(TSGroupThread *)thread;
|
||||
|
|
|
@ -93,35 +93,36 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
inThread:(TSThread *)thread
|
||||
quotedReplyModel:(nullable OWSQuotedReplyModel *)quotedReplyModel
|
||||
{
|
||||
return [self enqueueMessageWithAttachment:attachment
|
||||
inThread:thread
|
||||
quotedReplyModel:quotedReplyModel
|
||||
ignoreErrors:NO];
|
||||
return [self enqueueMessageWithAttachment:attachment inThread:thread quotedReplyModel:quotedReplyModel];
|
||||
}
|
||||
|
||||
+ (TSOutgoingMessage *)enqueueMessageWithAttachment:(SignalAttachment *)attachment
|
||||
inThread:(TSThread *)thread
|
||||
quotedReplyModel:(nullable OWSQuotedReplyModel *)quotedReplyModel
|
||||
ignoreErrors:(BOOL)ignoreErrors
|
||||
+ (TSOutgoingMessage *)enqueueMessageWithAttachments:(NSArray<SignalAttachment *> *)attachments
|
||||
inThread:(TSThread *)thread
|
||||
quotedReplyModel:(nullable OWSQuotedReplyModel *)quotedReplyModel
|
||||
{
|
||||
OWSAssertIsOnMainThread();
|
||||
OWSAssertDebug(attachment);
|
||||
OWSAssertDebug(!attachment.hasError);
|
||||
OWSAssertDebug(attachment.mimeType.length > 0);
|
||||
OWSAssertDebug(attachments.count > 0);
|
||||
OWSAssertDebug(thread);
|
||||
for (SignalAttachment *attachment in attachments) {
|
||||
OWSAssertDebug(!attachment.hasError);
|
||||
OWSAssertDebug(attachment.mimeType.length > 0);
|
||||
}
|
||||
|
||||
OWSDisappearingMessagesConfiguration *configuration =
|
||||
[OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId];
|
||||
|
||||
uint32_t expiresInSeconds = (configuration.isEnabled ? configuration.durationSeconds : 0);
|
||||
BOOL isVoiceMessage = (attachments.count == 1 && attachments.lastObject.isVoiceMessage);
|
||||
// TODO: Support multi-image captions.
|
||||
NSString *_Nullable messageBody = attachments.lastObject.captionText;
|
||||
TSOutgoingMessage *message =
|
||||
[[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:attachment.captionText
|
||||
messageBody:messageBody
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:[attachment isVoiceMessage]
|
||||
isVoiceMessage:isVoiceMessage
|
||||
groupMetaMessage:TSGroupMetaMessageUnspecified
|
||||
quotedMessage:[quotedReplyModel buildQuotedMessageForSending]
|
||||
contactShare:nil];
|
||||
|
|
Loading…
Reference in New Issue