Respond to CR.

// FREEBIE
pull/1/head
Matthew Chen 7 years ago
parent 3eaeb4e0ec
commit 1c8dbcd223

@ -30,6 +30,7 @@
#import <SignalServiceKit/OWSFailedMessagesJob.h>
#import <SignalServiceKit/OWSMessageManager.h>
#import <SignalServiceKit/OWSMessageSender.h>
#import <SignalServiceKit/OWSReadReceiptManager.h>
#import <SignalServiceKit/TSAccountManager.h>
#import <SignalServiceKit/TSDatabaseView.h>
#import <SignalServiceKit/TSPreKeyManager.h>
@ -809,6 +810,8 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[[OWSBatchMessageProcessor sharedInstance] handleAnyUnprocessedEnvelopesAsync];
[OWSProfileManager.sharedManager fetchLocalUsersProfile];
// Make sure this manager is started.
[OWSReadReceiptManager sharedManager];
}
- (void)registrationStateDidChange

@ -114,13 +114,35 @@ def sort_include_block(text, filepath, filename, file_extension):
for include in includes:
include.isInclude = False
# Make sure matching header is first.
matching_header_includes = []
other_includes = []
def is_matching_header(include):
filename_wo_ext = os.path.splitext(filename)[0]
include_filename_wo_ext = os.path.splitext(os.path.basename(include.body))[0]
return filename_wo_ext == include_filename_wo_ext
for include in includes:
if is_matching_header(include):
matching_header_includes.append(include)
else:
other_includes.append(include)
includes = other_includes
def formatBlock(includes):
lines = [include.format() for include in includes]
lines = list(set(lines))
def include_sorter(a, b):
return cmp(a.lower(), b.lower())
# return cmp(a.lower(), b.lower())
return cmp(a, b)
# print 'before'
# for line in lines:
# print '\t', line
# print
lines.sort(include_sorter)
# print 'after'
# for line in lines:
# print '\t', line
# print
# print
# print 'filepath'
# for line in lines:
@ -132,6 +154,8 @@ def sort_include_block(text, filepath, filename, file_extension):
includeQuotes = [include for include in includes if include.isInclude and include.isQuote]
importAngles = [include for include in includes if (not include.isInclude) and not include.isQuote]
importQuotes = [include for include in includes if (not include.isInclude) and include.isQuote]
if matching_header_includes:
blocks.append(formatBlock(matching_header_includes))
if includeQuotes:
blocks.append(formatBlock(includeQuotes))
if includeAngles:

@ -59,14 +59,8 @@ NSString *const OWSReadReceiptsProcessorMarkedMessageAsReadNotification =
- (instancetype)initWithIncomingMessage:(TSIncomingMessage *)message storageManager:(TSStorageManager *)storageManager
{
// authorId isn't set on all legacy messages, so we take
// extra measures to ensure we obtain a valid value.
NSString *messageAuthorId;
if (message.authorId) { // Group Thread
messageAuthorId = message.authorId;
} else { // Contact Thread
messageAuthorId = [TSContactThread contactIdFromThreadId:message.uniqueThreadId];
}
NSString *messageAuthorId = message.messageAuthorId;
OWSAssert(messageAuthorId.length > 0);
OWSReadReceipt *readReceipt = [OWSReadReceipt firstWithSenderId:messageAuthorId timestamp:message.timestamp];
if (readReceipt) {

@ -103,11 +103,11 @@ NS_ASSUME_NONNULL_BEGIN
timestamp:(uint64_t)timestamp
transaction:(YapDatabaseReadWriteTransaction *)transaction;
@property (nonatomic, readonly) NSString *authorId;
// This will be 0 for messages created before we were tracking sourceDeviceId
@property (nonatomic, readonly) UInt32 sourceDeviceId;
- (NSString *)messageAuthorId;
@end
NS_ASSUME_NONNULL_END

@ -15,6 +15,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface TSIncomingMessage ()
@property (nonatomic, readonly) NSString *authorId;
@property (nonatomic, getter=wasRead) BOOL read;
@end
@ -91,15 +93,8 @@ NS_ASSUME_NONNULL_BEGIN
if ([interaction isKindOfClass:[TSIncomingMessage class]]) {
TSIncomingMessage *message = (TSIncomingMessage *)interaction;
// authorId isn't set on all legacy messages, so we take
// extra measures to ensure we obtain a valid value.
NSString *messageAuthorId;
if (message.authorId) { // Group Thread
messageAuthorId = message.authorId;
} else { // Contact Thread
messageAuthorId =
[TSContactThread contactIdFromThreadId:message.uniqueThreadId];
}
NSString *messageAuthorId = message.messageAuthorId;
OWSAssert(messageAuthorId.length > 0);
if ([messageAuthorId isEqualToString:authorId]) {
foundMessage = message;
@ -111,6 +106,22 @@ NS_ASSUME_NONNULL_BEGIN
return foundMessage;
}
- (NSString *)messageAuthorId
{
// authorId isn't set on all legacy messages, so we take
// extra measures to ensure we obtain a valid value.
NSString *messageAuthorId;
if (self.authorId) {
// Group Thread
messageAuthorId = self.authorId;
} else {
// Contact Thread
messageAuthorId = [TSContactThread contactIdFromThreadId:self.uniqueThreadId];
}
OWSAssert(messageAuthorId.length > 0);
return messageAuthorId;
}
#pragma mark - OWSReadTracking
- (BOOL)shouldAffectUnreadCounts
@ -138,8 +149,6 @@ NS_ASSUME_NONNULL_BEGIN
}
if (sendReadReceipt) {
// Notification must happen outside of the transaction, else we'll likely crash when the notification receiver
// tries to do anything with the DB.
[OWSReadReceiptManager.sharedManager messageWasReadLocally:self];
}
}

@ -264,7 +264,7 @@ NS_ASSUME_NONNULL_BEGIN
if ([message isKindOfClass:[TSIncomingMessage class]]) {
TSIncomingMessage *incomingMessage = (TSIncomingMessage *)message;
NSString *contactName = [contactsManager displayNameForPhoneIdentifier:incomingMessage.authorId];
NSString *contactName = [contactsManager displayNameForPhoneIdentifier:incomingMessage.messageAuthorId];
[[[OWSDisappearingConfigurationUpdateInfoMessage alloc] initWithTimestamp:message.timestamp
thread:message.thread

@ -949,25 +949,6 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
}
}
NSString *localNumber = [TSAccountManager localNumber];
if ([localNumber isEqualToString:recipient.uniqueId]) {
if (deviceMessages.count < 1) {
DDLogInfo(@"Ignoring sync message without linked devices: %@", [message class]);
OWSAssert([message isKindOfClass:[OWSOutgoingSyncMessage class]]);
dispatch_async([OWSDispatch sendingQueue], ^{
[recipient save];
[self handleMessageSentLocally:message];
successHandler();
});
return;
}
} else {
OWSAssert(deviceMessages.count > 0);
}
TSSubmitMessageRequest *request = [[TSSubmitMessageRequest alloc] initWithRecipient:recipient.uniqueId
messages:deviceMessages
relay:recipient.relay

@ -70,6 +70,11 @@ NS_ASSUME_NONNULL_BEGIN
name:kNSNotificationName_DatabaseViewRegistrationComplete
object:nil];
// Try to start processing.
dispatch_async(dispatch_get_main_queue(), ^{
[self scheduleProcessing];
});
return self;
}
@ -119,7 +124,7 @@ NS_ASSUME_NONNULL_BEGIN
{
self.isProcessing = NO;
NSArray<OWSReadReceipt *> *readReceiptsToSend = [[self.toLinkedDevicesReadReceiptMap allValues] copy];
NSArray<OWSReadReceipt *> *readReceiptsToSend = [self.toLinkedDevicesReadReceiptMap allValues];
[self.toLinkedDevicesReadReceiptMap removeAllObjects];
if (readReceiptsToSend.count > 0) {
OWSReadReceiptsMessage *message = [[OWSReadReceiptsMessage alloc] initWithReadReceipts:readReceiptsToSend];
@ -143,19 +148,10 @@ NS_ASSUME_NONNULL_BEGIN
{
@synchronized(self)
{
NSString *threadUniqueId = message.thread.uniqueId;
NSString *threadUniqueId = message.uniqueThreadId;
OWSAssert(threadUniqueId.length > 0);
// Only groupthread sets authorId, thus this crappy code.
// TODO Refactor so that ALL incoming messages have an authorId.
NSString *messageAuthorId;
if (message.authorId) {
// Group Thread
messageAuthorId = message.authorId;
} else {
// Contact Thread
messageAuthorId = [TSContactThread contactIdFromThreadId:message.uniqueThreadId];
}
NSString *messageAuthorId = message.messageAuthorId;
OWSAssert(messageAuthorId.length > 0);
OWSReadReceipt *newReadReceipt =

Loading…
Cancel
Save