Merge branch 'charlesmchen/stress'
This commit is contained in:
commit
29dae9bb99
|
@ -74,6 +74,7 @@
|
|||
34B3F89C1E8DF3270035BE1A /* BlockListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F89B1E8DF3270035BE1A /* BlockListViewController.m */; };
|
||||
34B3F89F1E8DF5490035BE1A /* OWSTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F89E1E8DF5490035BE1A /* OWSTableViewController.m */; };
|
||||
34B3F8A21E8EA6040035BE1A /* ViewControllerUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F8A11E8EA6040035BE1A /* ViewControllerUtils.m */; };
|
||||
34BECE2B1F74C12700D7438D /* DebugUIStress.m in Sources */ = {isa = PBXBuildFile; fileRef = 34BECE2A1F74C12700D7438D /* DebugUIStress.m */; };
|
||||
34C04D801F6195E6004308B3 /* OWSFlatButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34C04D7F1F6195E6004308B3 /* OWSFlatButton.swift */; };
|
||||
34C42D5B1F45F7A80072EC04 /* OWSNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34C42D5A1F45F7A80072EC04 /* OWSNavigationController.m */; };
|
||||
34C42D611F4734CA0072EC04 /* OWSContactOffersCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 34C42D601F4734CA0072EC04 /* OWSContactOffersCell.m */; };
|
||||
|
@ -514,6 +515,8 @@
|
|||
34B3F89E1E8DF5490035BE1A /* OWSTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSTableViewController.m; sourceTree = "<group>"; };
|
||||
34B3F8A01E8EA6040035BE1A /* ViewControllerUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewControllerUtils.h; sourceTree = "<group>"; };
|
||||
34B3F8A11E8EA6040035BE1A /* ViewControllerUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewControllerUtils.m; sourceTree = "<group>"; };
|
||||
34BECE291F74C12700D7438D /* DebugUIStress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebugUIStress.h; sourceTree = "<group>"; };
|
||||
34BECE2A1F74C12700D7438D /* DebugUIStress.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DebugUIStress.m; sourceTree = "<group>"; };
|
||||
34C04D7F1F6195E6004308B3 /* OWSFlatButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OWSFlatButton.swift; sourceTree = "<group>"; };
|
||||
34C42D591F45F7A80072EC04 /* OWSNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSNavigationController.h; sourceTree = "<group>"; };
|
||||
34C42D5A1F45F7A80072EC04 /* OWSNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSNavigationController.m; sourceTree = "<group>"; };
|
||||
|
@ -1121,6 +1124,7 @@
|
|||
34D8C0221ED3673300188D7C /* DebugUI */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
45638BDB1F3DD0D400128435 /* DebugUICalling.swift */,
|
||||
34D8C0291ED3685800188D7C /* DebugUIContacts.h */,
|
||||
34D8C02A1ED3685800188D7C /* DebugUIContacts.m */,
|
||||
34E3EF0B1EFC235B007F6822 /* DebugUIDiskUsage.h */,
|
||||
|
@ -1131,12 +1135,13 @@
|
|||
341F2C0E1F2B8AE700D07D6B /* DebugUIMisc.m */,
|
||||
34E3EF0E1EFC2684007F6822 /* DebugUIPage.h */,
|
||||
34E3EF0F1EFC2684007F6822 /* DebugUIPage.m */,
|
||||
4556FA671F54AA9500AF40DD /* DebugUIProfile.swift */,
|
||||
452037CF1EE84975004E4CDF /* DebugUISessionState.h */,
|
||||
452037D01EE84975004E4CDF /* DebugUISessionState.m */,
|
||||
34BECE291F74C12700D7438D /* DebugUIStress.h */,
|
||||
34BECE2A1F74C12700D7438D /* DebugUIStress.m */,
|
||||
34D8C0251ED3673300188D7C /* DebugUITableViewController.h */,
|
||||
34D8C0261ED3673300188D7C /* DebugUITableViewController.m */,
|
||||
45638BDB1F3DD0D400128435 /* DebugUICalling.swift */,
|
||||
4556FA671F54AA9500AF40DD /* DebugUIProfile.swift */,
|
||||
);
|
||||
path = DebugUI;
|
||||
sourceTree = "<group>";
|
||||
|
@ -2340,6 +2345,7 @@
|
|||
341207271EE19F6A00463194 /* OWSSystemMessageCell.m in Sources */,
|
||||
341BB7491DB727EE001E2975 /* JSQMediaItem+OWS.m in Sources */,
|
||||
34B3F89C1E8DF3270035BE1A /* BlockListViewController.m in Sources */,
|
||||
34BECE2B1F74C12700D7438D /* DebugUIStress.m in Sources */,
|
||||
45F2B1941D9C9F48000D2C69 /* OWSOutgoingMessageCollectionViewCell.m in Sources */,
|
||||
34C42D5B1F45F7A80072EC04 /* OWSNavigationController.m in Sources */,
|
||||
B68EF9BA1C0B1EBD009C3DCD /* FLAnimatedImage.m in Sources */,
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "AppSettingsViewController.h"
|
||||
#import "AttachmentSharing.h"
|
||||
#import "DebugUIPage.h"
|
||||
|
@ -39,6 +37,7 @@
|
|||
#import "UIView+OWS.h"
|
||||
#import "ViewControllerUtils.h"
|
||||
#import <AxolotlKit/NSData+keyVersionByte.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <JSQMessagesViewController/JSQMediaItem.h>
|
||||
#import <JSQMessagesViewController/JSQMessagesMediaViewBubbleImageMasker.h>
|
||||
#import <JSQMessagesViewController/UIColor+JSQMessages.h>
|
||||
|
@ -53,7 +52,7 @@
|
|||
#import <SignalServiceKit/MIMETypeUtil.h>
|
||||
#import <SignalServiceKit/NSData+Base64.h>
|
||||
#import <SignalServiceKit/NSData+Image.h>
|
||||
#import <SignalServiceKit/NSDate+millisecondTimeStamp.h>
|
||||
#import <SignalServiceKit/NSDate+OWS.h>
|
||||
#import <SignalServiceKit/NSNotificationCenter+OWS.h>
|
||||
#import <SignalServiceKit/NSTimer+OWS.h>
|
||||
#import <SignalServiceKit/OWSAcknowledgeMessageDeliveryRequest.h>
|
||||
|
|
|
@ -2,18 +2,17 @@
|
|||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ConversationViewController.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "AttachmentSharing.h"
|
||||
#import "BlockListUIUtils.h"
|
||||
#import "BlockListViewController.h"
|
||||
#import "ContactsViewHelper.h"
|
||||
#import "ConversationViewController.h"
|
||||
#import "DebugUITableViewController.h"
|
||||
#import "Environment.h"
|
||||
#import "FingerprintViewController.h"
|
||||
#import "FullImageViewController.h"
|
||||
#import "NewGroupViewController.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "OWSAudioAttachmentPlayer.h"
|
||||
#import "OWSCall.h"
|
||||
#import "OWSContactOffersCell.h"
|
||||
|
@ -34,7 +33,6 @@
|
|||
#import "OWSUnreadIndicatorCell.h"
|
||||
#import "Signal-Swift.h"
|
||||
#import "SignalKeyingStorage.h"
|
||||
#import "ThreadUtil.h"
|
||||
#import "TSAttachmentPointer.h"
|
||||
#import "TSCall.h"
|
||||
#import "TSContactThread.h"
|
||||
|
@ -47,14 +45,15 @@
|
|||
#import "TSInfoMessage.h"
|
||||
#import "TSInvalidIdentityKeyErrorMessage.h"
|
||||
#import "TSUnreadIndicatorInteraction.h"
|
||||
#import "ThreadUtil.h"
|
||||
#import "UIFont+OWS.h"
|
||||
#import "UIUtil.h"
|
||||
#import "UIViewController+CameraPermissions.h"
|
||||
#import "UIViewController+OWS.h"
|
||||
#import "ViewControllerUtils.h"
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <AddressBookUI/AddressBookUI.h>
|
||||
#import <AssetsLibrary/AssetsLibrary.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <ContactsUI/CNContactViewController.h>
|
||||
#import <JSQMessagesViewController/JSQMessagesBubbleImage.h>
|
||||
#import <JSQMessagesViewController/JSQMessagesBubbleImageFactory.h>
|
||||
|
@ -80,11 +79,11 @@
|
|||
#import <SignalServiceKit/OWSMessageSender.h>
|
||||
#import <SignalServiceKit/OWSVerificationStateChangeMessage.h>
|
||||
#import <SignalServiceKit/SignalRecipient.h>
|
||||
#import <SignalServiceKit/Threading.h>
|
||||
#import <SignalServiceKit/TSAccountManager.h>
|
||||
#import <SignalServiceKit/TSGroupModel.h>
|
||||
#import <SignalServiceKit/TSInvalidIdentityKeyReceivingErrorMessage.h>
|
||||
#import <SignalServiceKit/TSNetworkManager.h>
|
||||
#import <SignalServiceKit/Threading.h>
|
||||
#import <YapDatabase/YapDatabaseView.h>
|
||||
|
||||
@import Photos;
|
||||
|
|
|
@ -61,13 +61,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
actionBlock:^{
|
||||
[DebugUIMisc clearHasDismissedOffers];
|
||||
}]];
|
||||
if ([thread isKindOfClass:[TSGroupThread class]]) {
|
||||
TSGroupThread *groupThread = (TSGroupThread *)thread;
|
||||
[items addObject:[OWSTableItem itemWithTitle:@"Hallucinate twin group"
|
||||
actionBlock:^{
|
||||
[DebugUIMisc hallucinateTwinGroup:groupThread];
|
||||
}]];
|
||||
}
|
||||
return [OWSTableSection sectionWithTitle:self.name items:items];
|
||||
}
|
||||
|
||||
|
@ -122,28 +115,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
}];
|
||||
}
|
||||
|
||||
// Creates a new group (by cloning the current group) without informing the,
|
||||
// other members. This can be used to test "group info requests", etc.
|
||||
+ (void)hallucinateTwinGroup:(TSGroupThread *)groupThread
|
||||
{
|
||||
__block TSGroupThread *thread;
|
||||
[[TSStorageManager sharedManager].dbReadWriteConnection
|
||||
readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
TSGroupModel *groupModel =
|
||||
[[TSGroupModel alloc] initWithTitle:[groupThread.groupModel.groupName stringByAppendingString:@" Copy"]
|
||||
memberIds:[groupThread.groupModel.groupMemberIds mutableCopy]
|
||||
image:groupThread.groupModel.groupImage
|
||||
groupId:[SecurityUtils generateRandomBytes:16]];
|
||||
thread = [TSGroupThread getOrCreateThreadWithGroupModel:groupModel transaction:transaction];
|
||||
}];
|
||||
OWSAssert(thread);
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[Environment presentConversationForThread:thread];
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "DebugUIPage.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TSThread;
|
||||
|
||||
@interface DebugUIStress : DebugUIPage
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,505 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "DebugUIStress.h"
|
||||
#import "Environment.h"
|
||||
#import "OWSMessageSender.h"
|
||||
#import "OWSTableViewController.h"
|
||||
#import "ThreadUtil.h"
|
||||
#import <SignalServiceKit/Cryptography.h>
|
||||
#import <SignalServiceKit/NSDate+OWS.h>
|
||||
#import <SignalServiceKit/OWSDynamicOutgoingMessage.h>
|
||||
#import <SignalServiceKit/SecurityUtils.h>
|
||||
#import <SignalServiceKit/TSGroupThread.h>
|
||||
#import <SignalServiceKit/TSStorageManager.h>
|
||||
#import <SignalServiceKit/TSThread.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation DebugUIStress
|
||||
|
||||
#pragma mark - Logging
|
||||
|
||||
+ (NSString *)tag
|
||||
{
|
||||
return [NSString stringWithFormat:@"[%@]", self.class];
|
||||
}
|
||||
|
||||
- (NSString *)tag
|
||||
{
|
||||
return self.class.tag;
|
||||
}
|
||||
|
||||
#pragma mark - Factory Methods
|
||||
|
||||
- (NSString *)name
|
||||
{
|
||||
return @"Stress";
|
||||
}
|
||||
|
||||
- (nullable OWSTableSection *)sectionForThread:(nullable TSThread *)thread
|
||||
{
|
||||
OWSAssert(thread);
|
||||
|
||||
NSMutableArray<OWSTableItem *> *items = [NSMutableArray new];
|
||||
[items addObject:[OWSTableItem itemWithTitle:@"Send empty message"
|
||||
actionBlock:^{
|
||||
[DebugUIStress sendStressMessage:thread block:^(SignalRecipient *recipient) {
|
||||
return [NSData new];
|
||||
}];
|
||||
}]];
|
||||
[items addObject:[OWSTableItem itemWithTitle:@"Send random noise message"
|
||||
actionBlock:^{
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
block:^(SignalRecipient *recipient) {
|
||||
NSUInteger contentLength = arc4random_uniform(32);
|
||||
return [Cryptography generateRandomBytes:contentLength];
|
||||
}];
|
||||
}]];
|
||||
[items addObject:[OWSTableItem itemWithTitle:@"Send no payload message"
|
||||
actionBlock:^{
|
||||
[DebugUIStress sendStressMessage:thread block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder = [OWSSignalServiceProtosContentBuilder new];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
[items addObject:[OWSTableItem itemWithTitle:@"Send empty null message"
|
||||
actionBlock:^{
|
||||
[DebugUIStress sendStressMessage:thread block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder = [OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosNullMessageBuilder *nullMessageBuilder = [OWSSignalServiceProtosNullMessageBuilder new];
|
||||
contentBuilder.nullMessage = [nullMessageBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
[items
|
||||
addObject:[OWSTableItem itemWithTitle:@"Send random null message"
|
||||
actionBlock:^{
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosNullMessageBuilder *nullMessageBuilder =
|
||||
[OWSSignalServiceProtosNullMessageBuilder new];
|
||||
NSUInteger contentLength = arc4random_uniform(32);
|
||||
nullMessageBuilder.padding =
|
||||
[Cryptography generateRandomBytes:contentLength];
|
||||
contentBuilder.nullMessage = [nullMessageBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
[items
|
||||
addObject:[OWSTableItem itemWithTitle:@"Send empty sync message"
|
||||
actionBlock:^{
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosSyncMessageBuilder *syncMessageBuilder =
|
||||
[OWSSignalServiceProtosSyncMessageBuilder new];
|
||||
contentBuilder.syncMessage = [syncMessageBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
[items
|
||||
addObject:[OWSTableItem itemWithTitle:@"Send empty sync sent message"
|
||||
actionBlock:^{
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosSyncMessageBuilder *syncMessageBuilder =
|
||||
[OWSSignalServiceProtosSyncMessageBuilder new];
|
||||
OWSSignalServiceProtosSyncMessageSentBuilder *sentBuilder =
|
||||
[OWSSignalServiceProtosSyncMessageSentBuilder new];
|
||||
syncMessageBuilder.sent = [sentBuilder build];
|
||||
contentBuilder.syncMessage = [syncMessageBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
[items addObject:[OWSTableItem itemWithTitle:@"Send whitespace text data message"
|
||||
actionBlock:^{
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosDataMessageBuilder *dataBuilder =
|
||||
[OWSSignalServiceProtosDataMessageBuilder new];
|
||||
dataBuilder.body = @" ";
|
||||
[DebugUIStress ensureGroupOfDataBuilder:dataBuilder
|
||||
thread:thread];
|
||||
contentBuilder.dataMessage = [dataBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
[items addObject:[OWSTableItem
|
||||
itemWithTitle:@"Send bad attachment data message"
|
||||
actionBlock:^{
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosDataMessageBuilder *dataBuilder =
|
||||
[OWSSignalServiceProtosDataMessageBuilder new];
|
||||
OWSSignalServiceProtosAttachmentPointerBuilder *attachmentPointer =
|
||||
[OWSSignalServiceProtosAttachmentPointerBuilder new];
|
||||
[attachmentPointer setId:arc4random_uniform(32) + 1];
|
||||
[attachmentPointer setContentType:@"1"];
|
||||
[attachmentPointer setSize:arc4random_uniform(32) + 1];
|
||||
[attachmentPointer setDigest:[Cryptography generateRandomBytes:1]];
|
||||
[attachmentPointer setFileName:@" "];
|
||||
[DebugUIStress ensureGroupOfDataBuilder:dataBuilder thread:thread];
|
||||
contentBuilder.dataMessage = [dataBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
[items addObject:[OWSTableItem itemWithTitle:@"Send normal text data message"
|
||||
actionBlock:^{
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosDataMessageBuilder *dataBuilder =
|
||||
[OWSSignalServiceProtosDataMessageBuilder new];
|
||||
dataBuilder.body = @"alice";
|
||||
[DebugUIStress ensureGroupOfDataBuilder:dataBuilder
|
||||
thread:thread];
|
||||
contentBuilder.dataMessage = [dataBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
[items addObject:[OWSTableItem itemWithTitle:@"Send N text messages with same timestamp"
|
||||
actionBlock:^{
|
||||
uint64_t timestamp = [NSDate ows_millisecondTimeStamp];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
timestamp:timestamp
|
||||
block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosDataMessageBuilder *dataBuilder =
|
||||
[OWSSignalServiceProtosDataMessageBuilder new];
|
||||
dataBuilder.body = [NSString stringWithFormat:@"%@ %d",
|
||||
[NSUUID UUID].UUIDString,
|
||||
i];
|
||||
[DebugUIStress ensureGroupOfDataBuilder:dataBuilder
|
||||
thread:thread];
|
||||
contentBuilder.dataMessage = [dataBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}
|
||||
}]];
|
||||
[items addObject:[OWSTableItem
|
||||
itemWithTitle:@"Send text message with current timestamp"
|
||||
actionBlock:^{
|
||||
uint64_t timestamp = [NSDate ows_millisecondTimeStamp];
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
timestamp:timestamp
|
||||
block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosDataMessageBuilder *dataBuilder =
|
||||
[OWSSignalServiceProtosDataMessageBuilder new];
|
||||
dataBuilder.body =
|
||||
[[NSUUID UUID].UUIDString stringByAppendingString:@" now"];
|
||||
[DebugUIStress ensureGroupOfDataBuilder:dataBuilder thread:thread];
|
||||
contentBuilder.dataMessage = [dataBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
[items addObject:[OWSTableItem
|
||||
itemWithTitle:@"Send text message with future timestamp"
|
||||
actionBlock:^{
|
||||
uint64_t timestamp = [NSDate ows_millisecondTimeStamp];
|
||||
timestamp += kHourInMs;
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
timestamp:timestamp
|
||||
block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosDataMessageBuilder *dataBuilder =
|
||||
[OWSSignalServiceProtosDataMessageBuilder new];
|
||||
dataBuilder.body =
|
||||
[[NSUUID UUID].UUIDString stringByAppendingString:@" now"];
|
||||
[DebugUIStress ensureGroupOfDataBuilder:dataBuilder thread:thread];
|
||||
contentBuilder.dataMessage = [dataBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
[items addObject:[OWSTableItem
|
||||
itemWithTitle:@"Send text message with past timestamp"
|
||||
actionBlock:^{
|
||||
uint64_t timestamp = [NSDate ows_millisecondTimeStamp];
|
||||
timestamp -= kHourInMs;
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
timestamp:timestamp
|
||||
block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosDataMessageBuilder *dataBuilder =
|
||||
[OWSSignalServiceProtosDataMessageBuilder new];
|
||||
dataBuilder.body =
|
||||
[[NSUUID UUID].UUIDString stringByAppendingString:@" now"];
|
||||
[DebugUIStress ensureGroupOfDataBuilder:dataBuilder thread:thread];
|
||||
contentBuilder.dataMessage = [dataBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
[items addObject:[OWSTableItem itemWithTitle:@"Send N text messages with same timestamp"
|
||||
actionBlock:^{
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosDataMessageBuilder *dataBuilder =
|
||||
[OWSSignalServiceProtosDataMessageBuilder new];
|
||||
dataBuilder.body = @"alice";
|
||||
contentBuilder.dataMessage = [dataBuilder build];
|
||||
[DebugUIStress ensureGroupOfDataBuilder:dataBuilder thread:thread];
|
||||
NSData *data = [[contentBuilder build] data];
|
||||
|
||||
uint64_t timestamp = [NSDate ows_millisecondTimeStamp];
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
[DebugUIStress sendStressMessage:thread
|
||||
timestamp:timestamp
|
||||
block:^(SignalRecipient *recipient) {
|
||||
return data;
|
||||
}];
|
||||
}
|
||||
}]];
|
||||
[items
|
||||
addObject:[OWSTableItem itemWithTitle:@"Send malformed sync sent message 1"
|
||||
actionBlock:^{
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosSyncMessageBuilder *syncMessageBuilder =
|
||||
[OWSSignalServiceProtosSyncMessageBuilder new];
|
||||
OWSSignalServiceProtosSyncMessageSentBuilder *sentBuilder =
|
||||
[OWSSignalServiceProtosSyncMessageSentBuilder new];
|
||||
sentBuilder.destination = @"abc";
|
||||
sentBuilder.timestamp = arc4random_uniform(32) + 1;
|
||||
OWSSignalServiceProtosDataMessageBuilder *dataBuilder =
|
||||
[OWSSignalServiceProtosDataMessageBuilder new];
|
||||
sentBuilder.message = [dataBuilder build];
|
||||
syncMessageBuilder.sent = [sentBuilder build];
|
||||
contentBuilder.syncMessage = [syncMessageBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
[items
|
||||
addObject:[OWSTableItem itemWithTitle:@"Send malformed sync sent message 2"
|
||||
actionBlock:^{
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosSyncMessageBuilder *syncMessageBuilder =
|
||||
[OWSSignalServiceProtosSyncMessageBuilder new];
|
||||
OWSSignalServiceProtosSyncMessageSentBuilder *sentBuilder =
|
||||
[OWSSignalServiceProtosSyncMessageSentBuilder new];
|
||||
sentBuilder.destination = @"abc";
|
||||
sentBuilder.timestamp = 0;
|
||||
OWSSignalServiceProtosDataMessageBuilder *dataBuilder =
|
||||
[OWSSignalServiceProtosDataMessageBuilder new];
|
||||
sentBuilder.message = [dataBuilder build];
|
||||
syncMessageBuilder.sent = [sentBuilder build];
|
||||
contentBuilder.syncMessage = [syncMessageBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
[items
|
||||
addObject:[OWSTableItem itemWithTitle:@"Send malformed sync sent message 3"
|
||||
actionBlock:^{
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosSyncMessageBuilder *syncMessageBuilder =
|
||||
[OWSSignalServiceProtosSyncMessageBuilder new];
|
||||
OWSSignalServiceProtosSyncMessageSentBuilder *sentBuilder =
|
||||
[OWSSignalServiceProtosSyncMessageSentBuilder new];
|
||||
sentBuilder.destination = @"abc";
|
||||
sentBuilder.timestamp = 0;
|
||||
OWSSignalServiceProtosDataMessageBuilder *dataBuilder =
|
||||
[OWSSignalServiceProtosDataMessageBuilder new];
|
||||
dataBuilder.body = @" ";
|
||||
sentBuilder.message = [dataBuilder build];
|
||||
syncMessageBuilder.sent = [sentBuilder build];
|
||||
contentBuilder.syncMessage = [syncMessageBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
[items
|
||||
addObject:[OWSTableItem itemWithTitle:@"Send malformed sync sent message 4"
|
||||
actionBlock:^{
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosSyncMessageBuilder *syncMessageBuilder =
|
||||
[OWSSignalServiceProtosSyncMessageBuilder new];
|
||||
OWSSignalServiceProtosSyncMessageSentBuilder *sentBuilder =
|
||||
[OWSSignalServiceProtosSyncMessageSentBuilder new];
|
||||
sentBuilder.destination = @"abc";
|
||||
sentBuilder.timestamp = 0;
|
||||
OWSSignalServiceProtosDataMessageBuilder *dataBuilder =
|
||||
[OWSSignalServiceProtosDataMessageBuilder new];
|
||||
dataBuilder.body = @" ";
|
||||
OWSSignalServiceProtosGroupContextBuilder *groupBuilder =
|
||||
[OWSSignalServiceProtosGroupContextBuilder new];
|
||||
[groupBuilder setId:[Cryptography generateRandomBytes:1]];
|
||||
dataBuilder.group = [groupBuilder build];
|
||||
sentBuilder.message = [dataBuilder build];
|
||||
syncMessageBuilder.sent = [sentBuilder build];
|
||||
contentBuilder.syncMessage = [syncMessageBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
[items
|
||||
addObject:[OWSTableItem itemWithTitle:@"Send malformed sync sent message 5"
|
||||
actionBlock:^{
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosSyncMessageBuilder *syncMessageBuilder =
|
||||
[OWSSignalServiceProtosSyncMessageBuilder new];
|
||||
OWSSignalServiceProtosSyncMessageSentBuilder *sentBuilder =
|
||||
[OWSSignalServiceProtosSyncMessageSentBuilder new];
|
||||
sentBuilder.destination = @"abc";
|
||||
sentBuilder.timestamp = 0;
|
||||
OWSSignalServiceProtosDataMessageBuilder *dataBuilder =
|
||||
[OWSSignalServiceProtosDataMessageBuilder new];
|
||||
dataBuilder.body = @" ";
|
||||
OWSSignalServiceProtosGroupContextBuilder *groupBuilder =
|
||||
[OWSSignalServiceProtosGroupContextBuilder new];
|
||||
[groupBuilder setId:[Cryptography generateRandomBytes:1]];
|
||||
dataBuilder.group = [groupBuilder build];
|
||||
sentBuilder.message = [dataBuilder build];
|
||||
syncMessageBuilder.sent = [sentBuilder build];
|
||||
contentBuilder.syncMessage = [syncMessageBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
[items
|
||||
addObject:[OWSTableItem itemWithTitle:@"Send empty sync sent message 6"
|
||||
actionBlock:^{
|
||||
[DebugUIStress
|
||||
sendStressMessage:thread
|
||||
block:^(SignalRecipient *recipient) {
|
||||
OWSSignalServiceProtosContentBuilder *contentBuilder =
|
||||
[OWSSignalServiceProtosContentBuilder new];
|
||||
OWSSignalServiceProtosSyncMessageBuilder *syncMessageBuilder =
|
||||
[OWSSignalServiceProtosSyncMessageBuilder new];
|
||||
OWSSignalServiceProtosSyncMessageSentBuilder *sentBuilder =
|
||||
[OWSSignalServiceProtosSyncMessageSentBuilder new];
|
||||
sentBuilder.destination = @"abc";
|
||||
syncMessageBuilder.sent = [sentBuilder build];
|
||||
contentBuilder.syncMessage = [syncMessageBuilder build];
|
||||
return [[contentBuilder build] data];
|
||||
}];
|
||||
}]];
|
||||
|
||||
if ([thread isKindOfClass:[TSGroupThread class]]) {
|
||||
TSGroupThread *groupThread = (TSGroupThread *)thread;
|
||||
[items addObject:[OWSTableItem itemWithTitle:@"Hallucinate twin group"
|
||||
actionBlock:^{
|
||||
[DebugUIStress hallucinateTwinGroup:groupThread];
|
||||
}]];
|
||||
}
|
||||
return [OWSTableSection sectionWithTitle:self.name items:items];
|
||||
}
|
||||
|
||||
+ (void)ensureGroupOfDataBuilder:(OWSSignalServiceProtosDataMessageBuilder *)dataBuilder thread:(TSThread *)thread
|
||||
{
|
||||
OWSAssert(dataBuilder);
|
||||
OWSAssert(thread);
|
||||
|
||||
if (![thread isKindOfClass:[TSGroupThread class]]) {
|
||||
return;
|
||||
}
|
||||
|
||||
TSGroupThread *groupThread = (TSGroupThread *)thread;
|
||||
OWSSignalServiceProtosGroupContextBuilder *groupBuilder = [OWSSignalServiceProtosGroupContextBuilder new];
|
||||
[groupBuilder setType:OWSSignalServiceProtosGroupContextTypeDeliver];
|
||||
[groupBuilder setId:groupThread.groupModel.groupId];
|
||||
[dataBuilder setGroup:groupBuilder.build];
|
||||
}
|
||||
|
||||
+ (void)sendStressMessage:(TSOutgoingMessage *)message
|
||||
{
|
||||
OWSAssert(message);
|
||||
|
||||
OWSMessageSender *messageSender = [Environment getCurrent].messageSender;
|
||||
[messageSender sendMessage:message
|
||||
success:^{
|
||||
DDLogInfo(@"%@ Successfully sent message.", self.tag);
|
||||
}
|
||||
failure:^(NSError *error) {
|
||||
DDLogWarn(@"%@ Failed to deliver message with error: %@", self.tag, error);
|
||||
}];
|
||||
}
|
||||
|
||||
+ (void)sendStressMessage:(TSThread *)thread
|
||||
block:(DynamicOutgoingMessageBlock)block
|
||||
{
|
||||
OWSAssert(thread);
|
||||
OWSAssert(block);
|
||||
|
||||
OWSDynamicOutgoingMessage *message =
|
||||
[[OWSDynamicOutgoingMessage alloc] initWithPlainTextDataBlock:block thread:thread];
|
||||
|
||||
[self sendStressMessage:message];
|
||||
}
|
||||
|
||||
+ (void)sendStressMessage:(TSThread *)thread timestamp:(uint64_t)timestamp block:(DynamicOutgoingMessageBlock)block
|
||||
{
|
||||
OWSAssert(thread);
|
||||
OWSAssert(block);
|
||||
|
||||
OWSDynamicOutgoingMessage *message =
|
||||
[[OWSDynamicOutgoingMessage alloc] initWithPlainTextDataBlock:block timestamp:timestamp thread:thread];
|
||||
|
||||
[self sendStressMessage:message];
|
||||
}
|
||||
|
||||
// Creates a new group (by cloning the current group) without informing the,
|
||||
// other members. This can be used to test "group info requests", etc.
|
||||
+ (void)hallucinateTwinGroup:(TSGroupThread *)groupThread
|
||||
{
|
||||
__block TSGroupThread *thread;
|
||||
[[TSStorageManager sharedManager].dbReadWriteConnection
|
||||
readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
TSGroupModel *groupModel =
|
||||
[[TSGroupModel alloc] initWithTitle:[groupThread.groupModel.groupName stringByAppendingString:@" Copy"]
|
||||
memberIds:[groupThread.groupModel.groupMemberIds mutableCopy]
|
||||
image:groupThread.groupModel.groupImage
|
||||
groupId:[SecurityUtils generateRandomBytes:16]];
|
||||
thread = [TSGroupThread getOrCreateThreadWithGroupModel:groupModel transaction:transaction];
|
||||
}];
|
||||
OWSAssert(thread);
|
||||
|
||||
[Environment presentConversationForThread:thread];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -8,6 +8,7 @@
|
|||
#import "DebugUIMessages.h"
|
||||
#import "DebugUIMisc.h"
|
||||
#import "DebugUISessionState.h"
|
||||
#import "DebugUIStress.h"
|
||||
#import "Signal-Swift.h"
|
||||
#import <SignalServiceKit/TSContactThread.h>
|
||||
#import <SignalServiceKit/TSThread.h>
|
||||
|
@ -96,6 +97,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
addObject:[self itemForSubsection:[DebugUICalling new] viewController:viewController thread:thread]];
|
||||
}
|
||||
[subsectionItems addObject:[self itemForSubsection:[DebugUIProfile new] viewController:viewController thread:thread]];
|
||||
[subsectionItems
|
||||
addObject:[self itemForSubsection:[DebugUIStress new] viewController:viewController thread:thread]];
|
||||
[subsectionItems addObject:[self itemForSubsection:[DebugUIMisc new] viewController:viewController thread:thread]];
|
||||
|
||||
[contents addSection:[OWSTableSection sectionWithTitle:@"Sections" items:subsectionItems]];
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#import "UIFont+OWS.h"
|
||||
#import "UIUtil.h"
|
||||
#import "UIView+OWS.h"
|
||||
#import <SignalServiceKit/NSDate+millisecondTimeStamp.h>
|
||||
#import <SignalServiceKit/NSDate+OWS.h>
|
||||
#import <SignalServiceKit/OWSError.h>
|
||||
#import <SignalServiceKit/OWSFingerprint.h>
|
||||
#import <SignalServiceKit/OWSFingerprintBuilder.h>
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#import "AppSettingsViewController.h"
|
||||
#import "ConversationViewController.h"
|
||||
#import "InboxTableViewCell.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "NewContactThreadViewController.h"
|
||||
#import "OWSContactsManager.h"
|
||||
#import "OWSNavigationController.h"
|
||||
|
@ -23,6 +22,7 @@
|
|||
#import "VersionMigrations.h"
|
||||
#import "ViewControllerUtils.h"
|
||||
#import <PromiseKit/AnyPromise.h>
|
||||
#import <SignalServiceKit/NSDate+OWS.h>
|
||||
#import <SignalServiceKit/OWSBlockingManager.h>
|
||||
#import <SignalServiceKit/OWSDisappearingMessagesJob.h>
|
||||
#import <SignalServiceKit/OWSMessageManager.h>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#import "UIUtil.h"
|
||||
#import "UIView+OWS.h"
|
||||
#import "UIViewController+OWS.h"
|
||||
#import <SignalServiceKit/NSDate+millisecondTimeStamp.h>
|
||||
#import <SignalServiceKit/NSDate+OWS.h>
|
||||
#import <SignalServiceKit/OWSMessageSender.h>
|
||||
#import <SignalServiceKit/SecurityUtils.h>
|
||||
#import <SignalServiceKit/SignalAccount.h>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#import "UIView+OWS.h"
|
||||
#import "UpdateGroupViewController.h"
|
||||
#import <25519/Curve25519.h>
|
||||
#import <SignalServiceKit/NSDate+millisecondTimeStamp.h>
|
||||
#import <SignalServiceKit/NSDate+OWS.h>
|
||||
#import <SignalServiceKit/OWSDisappearingConfigurationUpdateInfoMessage.h>
|
||||
#import <SignalServiceKit/OWSDisappearingMessagesConfiguration.h>
|
||||
#import <SignalServiceKit/OWSMessageSender.h>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#import "UIView+OWS.h"
|
||||
#import "UIViewController+OWS.h"
|
||||
#import "ViewControllerUtils.h"
|
||||
#import <SignalServiceKit/NSDate+millisecondTimeStamp.h>
|
||||
#import <SignalServiceKit/NSDate+OWS.h>
|
||||
#import <SignalServiceKit/OWSMessageSender.h>
|
||||
#import <SignalServiceKit/SecurityUtils.h>
|
||||
#import <SignalServiceKit/SignalAccount.h>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#import "OWSContactsManager.h"
|
||||
#import "Signal-Swift.h"
|
||||
#import "ThreadUtil.h"
|
||||
#import <SignalServiceKit/NSDate+millisecondTimeStamp.h>
|
||||
#import <SignalServiceKit/NSDate+OWS.h>
|
||||
#import <SignalServiceKit/OWSMessageReceiver.h>
|
||||
#import <SignalServiceKit/OWSMessageSender.h>
|
||||
#import <SignalServiceKit/OWSReadReceiptsProcessor.h>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#import "OWSProfileManager.h"
|
||||
#import "Signal-Swift.h"
|
||||
#import "TSUnreadIndicatorInteraction.h"
|
||||
#import <SignalServiceKit/NSDate+millisecondTimeStamp.h>
|
||||
#import <SignalServiceKit/NSDate+OWS.h>
|
||||
#import <SignalServiceKit/OWSAddToContactsOfferMessage.h>
|
||||
#import <SignalServiceKit/OWSAddToProfileWhitelistOfferMessage.h>
|
||||
#import <SignalServiceKit/OWSBlockingManager.h>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
|
||||
#import "OWSDevice.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "OWSError.h"
|
||||
#import "YapDatabaseConnection.h"
|
||||
#import "YapDatabaseTransaction.h"
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
#import "OWSSyncContactsMessage.h"
|
||||
#import "Contact.h"
|
||||
#import "ContactsManagerProtocol.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "OWSContactsOutputStream.h"
|
||||
#import "OWSSignalServiceProtos.pb.h"
|
||||
#import "OWSIdentityManager.h"
|
||||
#import "OWSSignalServiceProtos.pb.h"
|
||||
#import "ProfileManagerProtocol.h"
|
||||
#import "SignalAccount.h"
|
||||
#import "TSAttachment.h"
|
||||
#import "TSAttachmentStream.h"
|
||||
#import "ProfileManagerProtocol.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
|
||||
#import "OWSSyncGroupsMessage.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "OWSGroupsOutputStream.h"
|
||||
#import "OWSSignalServiceProtos.pb.h"
|
||||
#import "TSAttachment.h"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
|
||||
#import "OWSSyncGroupsRequestMessage.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "OWSSignalServiceProtos.pb.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// Created by Michael Kirk on 9/25/16.
|
||||
// Copyright © 2016 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSDisappearingMessagesConfigurationMessage.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "OWSDisappearingMessagesConfiguration.h"
|
||||
#import "OWSSignalServiceProtos.pb.h"
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSOutgoingMessage.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class OWSSignalServiceProtosDataMessageBuilder;
|
||||
@class SignalRecipient;
|
||||
|
||||
typedef NSData *_Nonnull (^DynamicOutgoingMessageBlock)(SignalRecipient *);
|
||||
|
||||
@interface OWSDynamicOutgoingMessage : TSOutgoingMessage
|
||||
|
||||
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block thread:(nullable TSThread *)thread;
|
||||
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block
|
||||
timestamp:(uint64_t)timestamp
|
||||
thread:(nullable TSThread *)thread;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,55 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSDynamicOutgoingMessage.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "OWSSignalServiceProtos.pb.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface OWSDynamicOutgoingMessage ()
|
||||
|
||||
@property (nonatomic, readonly) DynamicOutgoingMessageBlock block;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation OWSDynamicOutgoingMessage
|
||||
|
||||
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block thread:(nullable TSThread *)thread
|
||||
{
|
||||
return [self initWithPlainTextDataBlock:block timestamp:[NSDate ows_millisecondTimeStamp] thread:thread];
|
||||
}
|
||||
|
||||
- (instancetype)initWithPlainTextDataBlock:(DynamicOutgoingMessageBlock)block
|
||||
timestamp:(uint64_t)timestamp
|
||||
thread:(nullable TSThread *)thread
|
||||
{
|
||||
self = [super initWithTimestamp:timestamp inThread:thread];
|
||||
|
||||
if (self) {
|
||||
_block = block;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)saveWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
{
|
||||
// override superclass with no-op.
|
||||
//
|
||||
// There's no need to save this message, since it's not displayed to the user.
|
||||
}
|
||||
|
||||
- (NSData *)buildPlainTextData:(SignalRecipient *)recipient
|
||||
{
|
||||
NSData *plainTextData = self.block(recipient);
|
||||
OWSAssert(plainTextData);
|
||||
return plainTextData;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#import "TSErrorMessage.h"
|
||||
#import "ContactsManagerProtocol.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "OWSMessageManager.h"
|
||||
#import "TSContactThread.h"
|
||||
#import "TSErrorMessage_privateConstructor.h"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
|
||||
#import "TSInfoMessage.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import <YapDatabase/YapDatabaseConnection.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
|
||||
#import "TSInteraction.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "TSDatabaseSecondaryIndexes.h"
|
||||
#import "TSStorageManager+messageIDs.h"
|
||||
#import "TSThread.h"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
|
||||
#import "TSMessage.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "TSAttachment.h"
|
||||
#import "TSAttachmentPointer.h"
|
||||
#import "TSThread.h"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
|
||||
#import "TSOutgoingMessage.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "OWSOutgoingSyncMessage.h"
|
||||
#import "OWSSignalServiceProtos.pb.h"
|
||||
#import "ProfileManagerProtocol.h"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
|
||||
#import "OWSDisappearingMessagesFinder.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "TSMessage.h"
|
||||
#import "TSOutgoingMessage.h"
|
||||
#import "TSStorageManager.h"
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#import "OWSDisappearingMessagesJob.h"
|
||||
#import "ContactsManagerProtocol.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "NSTimer+OWS.h"
|
||||
#import "OWSDisappearingConfigurationUpdateInfoMessage.h"
|
||||
#import "OWSDisappearingMessagesConfiguration.h"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
|
||||
#import "OWSIdentityManager.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "NSNotificationCenter+OWS.h"
|
||||
#import "NotificationsProtocol.h"
|
||||
#import "OWSError.h"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#import "ContactsManagerProtocol.h"
|
||||
#import "Cryptography.h"
|
||||
#import "MimeTypeUtil.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "NotificationsProtocol.h"
|
||||
#import "OWSAttachmentsProcessor.h"
|
||||
#import "OWSBlockingManager.h"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
|
||||
#import "OWSOutgoingCallMessage.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "OWSCallAnswerMessage.h"
|
||||
#import "OWSCallBusyMessage.h"
|
||||
#import "OWSCallHangupMessage.h"
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
#import "OWSOutgoingNullMessage.h"
|
||||
#import "Cryptography.h"
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
#import "TSContactThread.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "OWSSignalServiceProtos.pb.h"
|
||||
#import "OWSVerificationStateSyncMessage.h"
|
||||
#import "TSContactThread.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -11,4 +11,19 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
#define kWeekInterval (7 * kDayInterval)
|
||||
#define kMonthInterval (30 * kDayInterval)
|
||||
|
||||
#define kSecondInMs 1000
|
||||
#define kMinuteInMs (kSecondInMs * 60)
|
||||
#define kHourInMs (kMinuteInMs * 60)
|
||||
#define kDayInMs (kHourInMs * 24)
|
||||
#define kWeekInMs (kDayInMs * 7)
|
||||
#define kMonthInMs (kDayInMs * 30)
|
||||
|
||||
@interface NSDate (millisecondTimeStamp)
|
||||
|
||||
+ (uint64_t)ows_millisecondTimeStamp;
|
||||
+ (NSDate *)ows_dateWithMillisecondsSince1970:(uint64_t)milliseconds;
|
||||
+ (uint64_t)ows_millisecondsSince1970ForDate:(NSDate *)date;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
// Created by Frederic Jacobs on 25/11/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSDate+OWS.h"
|
||||
#import <chrono>
|
||||
#import "NSDate+millisecondTimeStamp.h"
|
||||
|
||||
@implementation NSDate (millisecondTimeStamp)
|
||||
|
||||
+ (uint64_t)ows_millisecondTimeStamp {
|
||||
uint64_t milliseconds =
|
||||
(uint64_t)(std::chrono::system_clock::now().time_since_epoch() / std::chrono::milliseconds(1));
|
||||
+ (uint64_t)ows_millisecondTimeStamp
|
||||
{
|
||||
uint64_t milliseconds
|
||||
= (uint64_t)(std::chrono::system_clock::now().time_since_epoch() / std::chrono::milliseconds(1));
|
||||
return milliseconds;
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
// Created by Frederic Jacobs on 25/11/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
|
||||
|
||||
@interface NSDate (millisecondTimeStamp)
|
||||
|
||||
+ (uint64_t)ows_millisecondTimeStamp;
|
||||
+ (NSDate *)ows_dateWithMillisecondsSince1970:(uint64_t)milliseconds;
|
||||
+ (uint64_t)ows_millisecondsSince1970ForDate:(NSDate *)date;
|
||||
|
||||
@end
|
Loading…
Reference in New Issue