Fix interaction initializers and tests.
This commit is contained in:
parent
a6dbe5bf7a
commit
9085609087
|
@ -3568,15 +3568,7 @@ typedef enum : NSUInteger {
|
|||
|
||||
groupThread.groupModel = newGroupModel;
|
||||
[groupThread saveWithTransaction:transaction];
|
||||
message = [[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:groupThread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUpdate
|
||||
quotedMessage:nil];
|
||||
message = [TSOutgoingMessage outgoingMessageInThread:groupThread groupMetaMessage:TSGroupMessageUpdate];
|
||||
[message updateWithCustomMessage:updateGroupInfo transaction:transaction];
|
||||
}];
|
||||
|
||||
|
|
|
@ -800,7 +800,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
TSOutgoingMessage *message = [self createFakeOutgoingMessage:thread
|
||||
messageBody:messageBody
|
||||
fakeAssetLoader:fakeAssetLoader
|
||||
messageState:(TSOutgoingMessageState)messageState
|
||||
messageState:messageState
|
||||
isDelivered:YES
|
||||
isRead:NO
|
||||
quotedMessage:nil
|
||||
|
@ -3115,6 +3115,7 @@ isQuotedMessageAttachmentDownloaded:(BOOL)isQuotedMessageAttachmentDownloaded
|
|||
messageState:TSOutgoingMessageStateUnsent
|
||||
isDelivered:NO
|
||||
isRead:NO
|
||||
isVoiceMessage:NO
|
||||
quotedMessage:nil
|
||||
transaction:transaction];
|
||||
break;
|
||||
|
@ -3147,16 +3148,7 @@ isQuotedMessageAttachmentDownloaded:(BOOL)isQuotedMessageAttachmentDownloaded
|
|||
}];
|
||||
OWSAssert(thread);
|
||||
|
||||
TSOutgoingMessage *message =
|
||||
[[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageNew
|
||||
quotedMessage:nil];
|
||||
TSOutgoingMessage *message = [TSOutgoingMessage outgoingMessageInThread:thread groupMetaMessage:TSGroupMessageNew];
|
||||
[message updateWithCustomMessage:NSLocalizedString(@"GROUP_CREATED", nil)];
|
||||
|
||||
OWSMessageSender *messageSender = [Environment current].messageSender;
|
||||
|
@ -3407,16 +3399,11 @@ isQuotedMessageAttachmentDownloaded:(BOOL)isQuotedMessageAttachmentDownloaded
|
|||
NSString *text = [self randomText];
|
||||
OWSDisappearingMessagesConfiguration *configuration =
|
||||
[OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId transaction:transaction];
|
||||
TSOutgoingMessage *message = [[TSOutgoingMessage alloc]
|
||||
initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:text
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:(configuration.isEnabled ? configuration.durationSeconds
|
||||
: 0)expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageNone
|
||||
quotedMessage:nil];
|
||||
TSOutgoingMessage *message =
|
||||
[TSOutgoingMessage outgoingMessageInThread:thread
|
||||
messageBody:text
|
||||
attachmentId:nil
|
||||
expiresInSeconds:(configuration.isEnabled ? configuration.durationSeconds : 0)];
|
||||
DDLogError(@"%@ insertAndDeleteNewOutgoingMessages timestamp: %llu.", self.logTag, message.timestamp);
|
||||
[messages addObject:message];
|
||||
}
|
||||
|
@ -3441,16 +3428,11 @@ isQuotedMessageAttachmentDownloaded:(BOOL)isQuotedMessageAttachmentDownloaded
|
|||
OWSDisappearingMessagesConfiguration *configuration =
|
||||
[OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId
|
||||
transaction:initialTransaction];
|
||||
TSOutgoingMessage *message = [[TSOutgoingMessage alloc]
|
||||
initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:text
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:(configuration.isEnabled ? configuration.durationSeconds
|
||||
: 0)expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageNone
|
||||
quotedMessage:nil];
|
||||
TSOutgoingMessage *message =
|
||||
[TSOutgoingMessage outgoingMessageInThread:thread
|
||||
messageBody:text
|
||||
attachmentId:nil
|
||||
expiresInSeconds:(configuration.isEnabled ? configuration.durationSeconds : 0)];
|
||||
DDLogError(@"%@ resurrectNewOutgoingMessages1 timestamp: %llu.", self.logTag, message.timestamp);
|
||||
[messages addObject:message];
|
||||
}
|
||||
|
@ -3774,6 +3756,7 @@ isQuotedMessageAttachmentDownloaded:(BOOL)isQuotedMessageAttachmentDownloaded
|
|||
messageState:messageState
|
||||
isDelivered:isDelivered
|
||||
isRead:isRead
|
||||
isVoiceMessage:attachment.isVoiceMessage
|
||||
quotedMessage:quotedMessage
|
||||
transaction:transaction];
|
||||
}
|
||||
|
@ -3785,6 +3768,7 @@ isQuotedMessageAttachmentDownloaded:(BOOL)isQuotedMessageAttachmentDownloaded
|
|||
messageState:(TSOutgoingMessageState)messageState
|
||||
isDelivered:(BOOL)isDelivered
|
||||
isRead:(BOOL)isRead
|
||||
isVoiceMessage:(BOOL)isVoiceMessage
|
||||
quotedMessage:(nullable TSQuotedMessage *)quotedMessage
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
{
|
||||
|
|
|
@ -684,15 +684,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|||
[self presentViewController:removingFromGroup animated:YES completion:nil];
|
||||
|
||||
TSOutgoingMessage *message =
|
||||
[[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageQuit
|
||||
quotedMessage:nil];
|
||||
[TSOutgoingMessage outgoingMessageInThread:thread groupMetaMessage:TSGroupMessageQuit];
|
||||
[self.messageSender enqueueMessage:message
|
||||
success:^{
|
||||
[self dismissViewControllerAnimated:YES
|
||||
|
|
|
@ -490,15 +490,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
|
|||
canCancel:NO
|
||||
backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) {
|
||||
TSOutgoingMessage *message =
|
||||
[[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageNew
|
||||
quotedMessage:nil];
|
||||
[TSOutgoingMessage outgoingMessageInThread:thread groupMetaMessage:TSGroupMessageNew];
|
||||
|
||||
[message updateWithCustomMessage:NSLocalizedString(@"GROUP_CREATED", nil)];
|
||||
|
||||
|
|
|
@ -937,15 +937,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
{
|
||||
TSGroupThread *gThread = (TSGroupThread *)self.thread;
|
||||
TSOutgoingMessage *message =
|
||||
[[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:gThread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageQuit
|
||||
quotedMessage:nil];
|
||||
[TSOutgoingMessage outgoingMessageInThread:gThread groupMetaMessage:TSGroupMessageQuit];
|
||||
[self.messageSender enqueueMessage:message
|
||||
success:^{
|
||||
DDLogInfo(@"%@ Successfully left group.", self.logTag);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
@ -23,7 +23,7 @@ class MesssagesBubblesSizeCalculatorTest: XCTestCase {
|
|||
let contactsManager = OWSContactsManager()
|
||||
|
||||
func viewItemForText(_ text: String?) -> ConversationViewItem {
|
||||
let interaction = TSOutgoingMessage(timestamp: 0, in: thread, messageBody: text)
|
||||
let interaction = TSOutgoingMessage(in: thread, messageBody: text, attachmentId: nil)
|
||||
interaction.save()
|
||||
|
||||
var viewItem: ConversationViewItem!
|
||||
|
@ -41,7 +41,7 @@ class MesssagesBubblesSizeCalculatorTest: XCTestCase {
|
|||
// These are the expected values on iPhone SE.
|
||||
let viewWidth = 320
|
||||
let contentWidth = 300
|
||||
return viewItem.cellSize(forViewWidth: Int32(viewWidth), contentWidth:Int32(contentWidth))
|
||||
return viewItem.cellSize(forViewWidth: Int32(viewWidth), contentWidth: Int32(contentWidth))
|
||||
}
|
||||
|
||||
func testHeightForEmptyMessage() {
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
- (ConversationViewItem *)textViewItem
|
||||
{
|
||||
TSOutgoingMessage *message =
|
||||
[[TSOutgoingMessage alloc] initWithTimestamp:1 inThread:nil messageBody:self.fakeTextMessageText];
|
||||
[TSOutgoingMessage outgoingMessageInThread:nil messageBody:self.fakeTextMessageText attachmentId:nil];
|
||||
[message save];
|
||||
__block ConversationViewItem *viewItem = nil;
|
||||
[TSYapDatabaseObject.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
|
@ -62,11 +62,8 @@
|
|||
BOOL success = [attachment writeDataSource:dataSource];
|
||||
OWSAssert(success);
|
||||
[attachment save];
|
||||
NSMutableArray<NSString *> *attachmentIds = [@[
|
||||
attachment.uniqueId,
|
||||
] mutableCopy];
|
||||
TSOutgoingMessage *message =
|
||||
[[TSOutgoingMessage alloc] initWithTimestamp:1 inThread:nil messageBody:nil attachmentIds:attachmentIds];
|
||||
[TSOutgoingMessage outgoingMessageInThread:nil messageBody:nil attachmentId:attachment.uniqueId];
|
||||
[message save];
|
||||
|
||||
__block ConversationViewItem *viewItem = nil;
|
||||
|
|
|
@ -64,7 +64,7 @@ class DisplayableTextTest: XCTestCase {
|
|||
XCTAssertEqual("Příliš žluťoučký kůň úpěl ďábelské ódy.".glyphCount, 39)
|
||||
|
||||
// Excessive diacritics
|
||||
XCTAssertEqual("H҉̸̧͘͠A͢͞V̛̛I̴̸N͏̕͏G҉̵͜͏͢ ̧̧́T̶̛͘͡R̸̵̨̢̀O̷̡U͡҉B̶̛͢͞L̸̸͘͢͟É̸ ̸̛͘͏R͟È͠͞A̸͝Ḑ̕͘͜I̵͘҉͜͞N̷̡̢͠G̴͘͠ ͟͞T͏̢́͡È̀X̕҉̢̀T̢͠?̕͏̢͘͢".glyphCount, 109)
|
||||
XCTAssertEqual("H҉̸̧͘͠A͢͞V̛̛I̴̸N͏̕͏G҉̵͜͏͢ ̧̧́T̶̛͘͡R̸̵̨̢̀O̷̡U͡҉B̶̛͢͞L̸̸͘͢͟É̸ ̸̛͘͏R͟È͠͞A̸͝Ḑ̕͘͜I̵͘҉͜͞N̷̡̢͠G̴͘͠ ͟͞T͏̢́͡È̀X̕҉̢̀T̢͠?̕͏̢͘͢".glyphCount, 115)
|
||||
XCTAssertEqual("L̷̳͔̲͝Ģ̵̮̯̤̩̙͍̬̟͉̹̘̹͍͈̮̦̰̣͟͝O̶̴̮̻̮̗͘͡!̴̷̟͓͓".glyphCount, 43)
|
||||
}
|
||||
|
||||
|
|
|
@ -85,18 +85,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
OWSDisappearingMessagesConfiguration *configuration =
|
||||
[OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId];
|
||||
|
||||
uint32_t expiresInSeconds = (configuration.isEnabled ? configuration.durationSeconds : 0);
|
||||
TSOutgoingMessage *message =
|
||||
[[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:text
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageNone
|
||||
quotedMessage:quotedMessage];
|
||||
[TSOutgoingMessage outgoingMessageInThread:thread
|
||||
messageBody:text
|
||||
attachmentId:nil
|
||||
expiresInSeconds:expiresInSeconds];
|
||||
|
||||
[messageSender enqueueMessage:message success:successHandler failure:failureHandler];
|
||||
|
||||
|
|
|
@ -57,6 +57,18 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
|
|||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentId:(nullable NSString *)attachmentId;
|
||||
|
||||
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentId:(nullable NSString *)attachmentId
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds;
|
||||
|
||||
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage;
|
||||
|
||||
@property (atomic, readonly) TSOutgoingMessageState messageState;
|
||||
|
||||
// The message has been sent to the service and received by at least one recipient client.
|
||||
|
|
|
@ -75,6 +75,47 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
|
|||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentId:(nullable NSString *)attachmentId
|
||||
{
|
||||
return [self outgoingMessageInThread:thread messageBody:body attachmentId:attachmentId expiresInSeconds:0];
|
||||
}
|
||||
|
||||
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
attachmentId:(nullable NSString *)attachmentId
|
||||
expiresInSeconds:(uint32_t)expiresInSeconds
|
||||
{
|
||||
NSMutableArray<NSString *> *attachmentIds = [NSMutableArray new];
|
||||
if (attachmentId) {
|
||||
[attachmentIds addObject:attachmentId];
|
||||
}
|
||||
return [[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:body
|
||||
attachmentIds:attachmentIds
|
||||
expiresInSeconds:expiresInSeconds
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageNone
|
||||
quotedMessage:nil];
|
||||
}
|
||||
|
||||
+ (instancetype)outgoingMessageInThread:(nullable TSThread *)thread
|
||||
groupMetaMessage:(TSGroupMetaMessage)groupMetaMessage
|
||||
{
|
||||
return [[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:groupMetaMessage
|
||||
quotedMessage:nil];
|
||||
}
|
||||
|
||||
- (instancetype)initOutgoingMessageWithTimestamp:(uint64_t)timestamp
|
||||
inThread:(nullable TSThread *)thread
|
||||
messageBody:(nullable NSString *)body
|
||||
|
|
|
@ -890,15 +890,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
NSString *updateGroupInfo =
|
||||
[gThread.groupModel getInfoStringAboutUpdateTo:gThread.groupModel contactsManager:self.contactsManager];
|
||||
TSOutgoingMessage *message =
|
||||
[[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:gThread
|
||||
messageBody:nil
|
||||
attachmentIds:[NSMutableArray new]
|
||||
expiresInSeconds:0
|
||||
expireStartedAt:0
|
||||
isVoiceMessage:NO
|
||||
groupMetaMessage:TSGroupMessageUpdate
|
||||
quotedMessage:nil];
|
||||
[TSOutgoingMessage outgoingMessageInThread:gThread groupMetaMessage:TSGroupMessageUpdate];
|
||||
[message updateWithCustomMessage:updateGroupInfo transaction:transaction];
|
||||
// Only send this group update to the requester.
|
||||
[message updateWithSingleGroupRecipient:envelope.source transaction:transaction];
|
||||
|
|
Loading…
Reference in New Issue