From 344b5e0fcef8457c3a3965961473d758424806f2 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Thu, 27 Aug 2020 14:39:59 +1000 Subject: [PATCH 01/30] Increase file size OR multiplier --- SignalServiceKit/src/Loki/API/FileServerAPI.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SignalServiceKit/src/Loki/API/FileServerAPI.swift b/SignalServiceKit/src/Loki/API/FileServerAPI.swift index 2b95c8814..fc2f69535 100644 --- a/SignalServiceKit/src/Loki/API/FileServerAPI.swift +++ b/SignalServiceKit/src/Loki/API/FileServerAPI.swift @@ -12,10 +12,10 @@ public final class FileServerAPI : DotNetAPI { public static let maxFileSize = 10_000_000 // 10 MB /// The file server has a file size limit of `maxFileSize`, which the Service Nodes try to enforce as well. However, the limit applied by the Service Nodes /// is on the **HTTP request** and not the file size. Because of onion request encryption, a file that's about 4 MB will result in a request that's about 18 MB. - /// On average the multiplier appears to be about 4.4, so when checking whether the file will exceed the file size limit when uploading a file we just divide + /// On average the multiplier appears to be about 6, so when checking whether the file will exceed the file size limit when uploading a file we just divide /// the size of the file by this number. The alternative would be to actually check the size of the HTTP request but that's only possible after proof of work /// has been calculated and the onion request encryption has happened, which takes several seconds. - public static let fileSizeORMultiplier = 4.4 + public static let fileSizeORMultiplier: Double = 6 @objc public static let server = "https://file.getsession.org" From 0cc958f39ea2a20f4bca64c06ed23dfb4a9d5bb9 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Wed, 26 Aug 2020 15:07:25 +1000 Subject: [PATCH 02/30] Update version number --- Signal.xcodeproj/project.pbxproj | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 89581bd15..b50488241 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -4088,7 +4088,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -4102,7 +4102,7 @@ INFOPLIST_FILE = SignalShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.5; + MARKETING_VERSION = 1.4.6; MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.share-extension"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -4150,7 +4150,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -4169,7 +4169,7 @@ INFOPLIST_FILE = SignalShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.5; + MARKETING_VERSION = 1.4.6; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.share-extension"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -4204,7 +4204,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; @@ -4223,7 +4223,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 1.4.5; + MARKETING_VERSION = 1.4.6; MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.utilities"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; @@ -4274,7 +4274,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; @@ -4298,7 +4298,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 1.4.5; + MARKETING_VERSION = 1.4.6; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.utilities"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; @@ -4336,7 +4336,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -4348,7 +4348,7 @@ INFOPLIST_FILE = LokiPushNotificationService/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.5; + MARKETING_VERSION = 1.4.6; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.push-notification-service"; @@ -4399,7 +4399,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -4416,7 +4416,7 @@ INFOPLIST_FILE = LokiPushNotificationService/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.5; + MARKETING_VERSION = 1.4.6; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.push-notification-service"; @@ -4600,7 +4600,7 @@ CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4635,7 +4635,7 @@ "$(SRCROOT)", ); LLVM_LTO = NO; - MARKETING_VERSION = 1.4.5; + MARKETING_VERSION = 1.4.6; OTHER_LDFLAGS = "$(inherited)"; OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger"; @@ -4668,7 +4668,7 @@ CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4703,7 +4703,7 @@ "$(SRCROOT)", ); LLVM_LTO = NO; - MARKETING_VERSION = 1.4.5; + MARKETING_VERSION = 1.4.6; OTHER_LDFLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger"; PRODUCT_NAME = Session; From a1ef5c3c716011d7c5006486903291400a7179f9 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Wed, 26 Aug 2020 16:21:18 +1000 Subject: [PATCH 03/30] Update build number --- Signal.xcodeproj/project.pbxproj | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index b50488241..82d991df0 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -4088,7 +4088,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -4150,7 +4150,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -4204,7 +4204,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; @@ -4274,7 +4274,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; @@ -4336,7 +4336,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -4399,7 +4399,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -4600,7 +4600,7 @@ CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4668,7 +4668,7 @@ CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", From 08c1acef51cc22688e97b5af694d7f428ad1b331 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Thu, 27 Aug 2020 14:42:40 +1000 Subject: [PATCH 04/30] Update build number --- Signal.xcodeproj/project.pbxproj | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 82d991df0..acbe04bf1 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -4088,7 +4088,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -4150,7 +4150,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -4204,7 +4204,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; @@ -4274,7 +4274,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; @@ -4336,7 +4336,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -4399,7 +4399,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -4600,7 +4600,7 @@ CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4668,7 +4668,7 @@ CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", From 3bbe8f558df49acc47d1867b068f8b832923f608 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Thu, 27 Aug 2020 15:49:17 +1000 Subject: [PATCH 05/30] Make replies show the user's display name rather than their Session ID --- .../ConversationView/Cells/OWSQuotedMessageView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m index 807914dcc..62493bc4b 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m @@ -549,7 +549,7 @@ const CGFloat kRemotelySourcedContentRowSpacing = 4; } } else { OWSContactsManager *contactsManager = Environment.shared.contactsManager; - __block NSString *quotedAuthor = [contactsManager contactOrProfileNameForPhoneIdentifier:self.quotedMessage.authorId]; + __block NSString *quotedAuthor = [SSKEnvironment.shared.profileManager profileNameForRecipientWithID:self.quotedMessage.authorId] ?: [contactsManager contactOrProfileNameForPhoneIdentifier:self.quotedMessage.authorId]; if (quotedAuthor == self.quotedMessage.authorId) { [OWSPrimaryStorage.sharedManager.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { From 4d13c6bee5c1f0df53521f15c73b687dd7d12238 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Fri, 28 Aug 2020 11:10:59 +1000 Subject: [PATCH 06/30] Patch unread indicator bug --- .../ConversationViewController.m | 1 - .../ConversationView/ConversationViewModel.m | 12 +++++++-- SignalServiceKit/src/Contacts/TSThread.m | 26 +++++++++++++++++-- .../src/Messages/OWSMessageUtils.m | 25 ++++++++++++++++++ .../src/Messages/OWSReadReceiptManager.m | 5 +++- 5 files changed, 63 insertions(+), 6 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 538b73f49..96f84c3ff 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -3607,7 +3607,6 @@ typedef enum : NSUInteger { // and won't update the UI state immediately. - (void)didScrollToBottom { - id _Nullable lastVisibleViewItem = [self.viewItems lastObject]; if (lastVisibleViewItem) { uint64_t lastVisibleSortId = lastVisibleViewItem.interaction.sortId; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m index 9e699b2b3..693392413 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m @@ -63,8 +63,16 @@ NS_ASSUME_NONNULL_BEGIN interactionIndexMap[viewItem.interaction.uniqueId] = @(i); [interactionIds addObject:viewItem.interaction.uniqueId]; - if (viewItem.unreadIndicator != nil) { - _unreadIndicatorIndex = @(i); + if (viewItem.unreadIndicator != nil && [viewItem.interaction conformsToProtocol:@protocol(OWSReadTracking)]) { + id interaction = (id)viewItem.interaction; + + // Under normal circumstances !interaction.read should always evaluate to true at this point, but + // there is a bug that can somehow cause it to be false leading to conversations permanently being + // stuck with "unread" messages. + + if (!interaction.read) { + _unreadIndicatorIndex = @(i); + } } } _interactionIndexMap = [interactionIndexMap copy]; diff --git a/SignalServiceKit/src/Contacts/TSThread.m b/SignalServiceKit/src/Contacts/TSThread.m index ec78d578c..eeb2a87f0 100644 --- a/SignalServiceKit/src/Contacts/TSThread.m +++ b/SignalServiceKit/src/Contacts/TSThread.m @@ -348,7 +348,12 @@ ConversationColorName const kConversationColorName_Default = ConversationColorNa OWSFailDebug(@"Unexpected object in unseen messages: %@", [object class]); return; } - [messages addObject:(id)object]; + id unread = (id)object; + if (unread.read) { + [LKLogger print:@"Found an already read message in the * unseen * messages list."]; + return; + } + [messages addObject:unread]; }]; return [messages copy]; @@ -356,7 +361,24 @@ ConversationColorName const kConversationColorName_Default = ConversationColorNa - (NSUInteger)unreadMessageCountWithTransaction:(YapDatabaseReadTransaction *)transaction { - return [[transaction ext:TSUnreadDatabaseViewExtensionName] numberOfItemsInGroup:self.uniqueId]; + __block NSUInteger count = 0; + + YapDatabaseViewTransaction *unreadMessages = [transaction ext:TSUnreadDatabaseViewExtensionName]; + [unreadMessages enumerateKeysAndObjectsInGroup:self.uniqueId + usingBlock:^(NSString *collection, NSString *key, id object, NSUInteger index, BOOL *stop) { + if (![object conformsToProtocol:@protocol(OWSReadTracking)]) { + OWSFailDebug(@"Unexpected object in unread messages: %@", [object class]); + return; + } + id unread = (id)object; + if (unread.read) { + [LKLogger print:@"Found an already read message in the * unread * messages list."]; + return; + } + count += 1; + }]; + + return count; } - (void)markAllAsReadWithTransaction:(YapDatabaseReadWriteTransaction *)transaction diff --git a/SignalServiceKit/src/Messages/OWSMessageUtils.m b/SignalServiceKit/src/Messages/OWSMessageUtils.m index 5b39aa3af..a3e5e54bc 100644 --- a/SignalServiceKit/src/Messages/OWSMessageUtils.m +++ b/SignalServiceKit/src/Messages/OWSMessageUtils.m @@ -18,6 +18,7 @@ #import "TSThread.h" #import "UIImage+OWS.h" #import +#import NS_ASSUME_NONNULL_BEGIN @@ -65,6 +66,30 @@ NS_ASSUME_NONNULL_BEGIN - (NSUInteger)unreadMessagesCount { + __block NSUInteger count = 0; + + [LKStorage readWithBlock:^(YapDatabaseReadTransaction *transaction) { + YapDatabaseViewTransaction *unreadMessages = [transaction ext:TSUnreadDatabaseViewExtensionName]; + NSArray *allGroups = [unreadMessages allGroups]; + for (NSString *groupID in allGroups) { + [unreadMessages enumerateKeysAndObjectsInGroup:groupID + usingBlock:^(NSString *collection, NSString *key, id object, NSUInteger index, BOOL *stop) { + if (![object conformsToProtocol:@protocol(OWSReadTracking)]) { + OWSFailDebug(@"Unexpected object in unread messages: %@", [object class]); + return; + } + id unread = (id)object; + if (unread.read) { + [LKLogger print:@"Found an already read message in the * unread * messages list."]; + return; + } + count += 1; + }]; + } + }]; + + return count; + __block NSUInteger numberOfItems; [self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { numberOfItems = [[transaction ext:TSUnreadDatabaseViewExtensionName] numberOfItemsInAllGroups]; diff --git a/SignalServiceKit/src/Messages/OWSReadReceiptManager.m b/SignalServiceKit/src/Messages/OWSReadReceiptManager.m index c51fa0578..a5bdb80d5 100644 --- a/SignalServiceKit/src/Messages/OWSReadReceiptManager.m +++ b/SignalServiceKit/src/Messages/OWSReadReceiptManager.m @@ -491,7 +491,10 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE return; } - OWSAssertDebug(!possiblyRead.read); + // Under normal circumstances !possiblyRead.read should always evaluate to true at this point, but + // there is a bug that can somehow cause it to be false leading to conversations permanently being + // stuck with "unread" messages. + OWSAssertDebug(possiblyRead.expireStartedAt == 0); if (!possiblyRead.read) { [newlyReadList addObject:possiblyRead]; From c5df848fe597fb5ec9c1fbf3c52f94fc3aa158b6 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Fri, 28 Aug 2020 13:53:02 +1000 Subject: [PATCH 07/30] Fix typing indicator color --- Signal/src/views/TypingIndicatorView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Signal/src/views/TypingIndicatorView.swift b/Signal/src/views/TypingIndicatorView.swift index f9922008b..0288b78bf 100644 --- a/Signal/src/views/TypingIndicatorView.swift +++ b/Signal/src/views/TypingIndicatorView.swift @@ -127,7 +127,7 @@ fileprivate func startAnimation() { stopAnimation() - let baseColor = UIColor.white + let baseColor = Colors.text let timeIncrement: CFTimeInterval = 0.15 var colorValues = [CGColor]() var pathValues = [CGPath]() From af7a58cc1fe9c302c9caee3a736a8e0e008f18dd Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Fri, 28 Aug 2020 15:27:59 +1000 Subject: [PATCH 08/30] use server timestamp to show the message time in open groups --- .../API/Open Groups/PublicChatPoller.swift | 1 + .../src/Messages/Interactions/TSInteraction.h | 4 ++++ .../src/Messages/Interactions/TSInteraction.m | 18 ++++++++++++++++++ .../src/Messages/OWSMessageManager.m | 5 +++++ 4 files changed, 28 insertions(+) diff --git a/SignalServiceKit/src/Loki/API/Open Groups/PublicChatPoller.swift b/SignalServiceKit/src/Loki/API/Open Groups/PublicChatPoller.swift index 5779c3e1d..b3e3bce27 100644 --- a/SignalServiceKit/src/Loki/API/Open Groups/PublicChatPoller.swift +++ b/SignalServiceKit/src/Loki/API/Open Groups/PublicChatPoller.swift @@ -174,6 +174,7 @@ public final class PublicChatPoller : NSObject { envelope.setSource(senderPublicKey) envelope.setSourceDevice(OWSDevicePrimaryDeviceId) envelope.setContent(try! content.build().serializedData()) + envelope.setServerTimestamp(message.serverTimestamp) try! Storage.writeSync { transaction in transaction.setObject(senderDisplayName, forKey: senderPublicKey, inCollection: publicChat.id) let messageServerID = message.serverID diff --git a/SignalServiceKit/src/Messages/Interactions/TSInteraction.h b/SignalServiceKit/src/Messages/Interactions/TSInteraction.h index 18a9045bd..0af44e964 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSInteraction.h +++ b/SignalServiceKit/src/Messages/Interactions/TSInteraction.h @@ -42,6 +42,10 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value); /// Used for public chats where a message sent from a slave device is interpreted as having been sent from the master device. @property (nonatomic) NSString *actualSenderHexEncodedPublicKey; +- (void)setServerTimestampAsReceiveTimestamp:(uint64_t)receivedAtTimestamp; + +- (uint64_t)timestamp; + - (NSDate *)receivedAtDate; - (OWSInteractionType)interactionType; diff --git a/SignalServiceKit/src/Messages/Interactions/TSInteraction.m b/SignalServiceKit/src/Messages/Interactions/TSInteraction.m index 45ea82714..dc5bc492a 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSInteraction.m +++ b/SignalServiceKit/src/Messages/Interactions/TSInteraction.m @@ -41,6 +41,8 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value) @implementation TSInteraction +@synthesize timestamp = _timestamp; + + (NSArray *)interactionsWithTimestamp:(uint64_t)timestamp ofClass:(Class)clazz withTransaction:(YapDatabaseReadTransaction *)transaction @@ -175,11 +177,27 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value) #pragma mark Date operations +- (uint64_t)timestamp +{ + if (self.thread.isGroupThread) { + TSGroupThread *thread = (TSGroupThread *)self.thread; + if (thread.isPublicChat) { + return _receivedAtTimestamp; + } + } + return _timestamp; +} + - (uint64_t)timestampForLegacySorting { return self.timestamp; } +- (void)setServerTimestampAsReceiveTimestamp:(uint64_t)receivedAtTimestamp +{ + _receivedAtTimestamp = receivedAtTimestamp; +} + - (NSDate *)receivedAtDate { return [NSDate ows_dateWithMillisecondsSince1970:self.receivedAtTimestamp]; diff --git a/SignalServiceKit/src/Messages/OWSMessageManager.m b/SignalServiceKit/src/Messages/OWSMessageManager.m index 1679e5b80..1029e9025 100644 --- a/SignalServiceKit/src/Messages/OWSMessageManager.m +++ b/SignalServiceKit/src/Messages/OWSMessageManager.m @@ -1417,6 +1417,11 @@ NS_ASSUME_NONNULL_BEGIN serverTimestamp:serverTimestamp wasReceivedByUD:wasReceivedByUD]; + //For open group messages, use server timestamp as the receive timestamp + if (oldGroupThread.isPublicChat) { + [incomingMessage setServerTimestampAsReceiveTimestamp:(uint64_t)envelope.serverTimestamp]; + } + // Loki: Set open group server ID if needed if (dataMessage.publicChatInfo != nil && dataMessage.publicChatInfo.hasServerID) { incomingMessage.openGroupServerMessageID = dataMessage.publicChatInfo.serverID; From 2f3fa3adf806409a92ccce9ea48b37db7530721f Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Fri, 28 Aug 2020 16:35:16 +1000 Subject: [PATCH 09/30] fix open group time for self sent messages --- SignalServiceKit/src/Devices/OWSRecordTranscriptJob.h | 1 + SignalServiceKit/src/Devices/OWSRecordTranscriptJob.m | 9 +++++++++ SignalServiceKit/src/Messages/OWSMessageManager.m | 2 ++ 3 files changed, 12 insertions(+) diff --git a/SignalServiceKit/src/Devices/OWSRecordTranscriptJob.h b/SignalServiceKit/src/Devices/OWSRecordTranscriptJob.h index 464db81e9..53f383a20 100644 --- a/SignalServiceKit/src/Devices/OWSRecordTranscriptJob.h +++ b/SignalServiceKit/src/Devices/OWSRecordTranscriptJob.h @@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN + (void)processIncomingSentMessageTranscript:(OWSIncomingSentMessageTranscript *)incomingSentMessageTranscript serverID:(uint64_t)serverID + serverTimestamp:(uint64_t)serverTimestamp attachmentHandler:(void (^)( NSArray *attachmentStreams))attachmentHandler transaction:(YapDatabaseReadWriteTransaction *)transaction; diff --git a/SignalServiceKit/src/Devices/OWSRecordTranscriptJob.m b/SignalServiceKit/src/Devices/OWSRecordTranscriptJob.m index 35ae6e23c..02c4b4cd5 100644 --- a/SignalServiceKit/src/Devices/OWSRecordTranscriptJob.m +++ b/SignalServiceKit/src/Devices/OWSRecordTranscriptJob.m @@ -62,6 +62,7 @@ NS_ASSUME_NONNULL_BEGIN + (void)processIncomingSentMessageTranscript:(OWSIncomingSentMessageTranscript *)transcript serverID:(uint64_t)serverID + serverTimestamp:(uint64_t)serverTimestamp attachmentHandler:(void (^)( NSArray *attachmentStreams))attachmentHandler transaction:(YapDatabaseReadWriteTransaction *)transaction @@ -104,6 +105,14 @@ NS_ASSUME_NONNULL_BEGIN contactShare:transcript.contact linkPreview:transcript.linkPreview]; + + if (transcript.thread.isGroupThread) { + TSGroupThread *thread = (TSGroupThread *)transcript.thread; + if (thread.isPublicChat) { + [outgoingMessage setServerTimestampAsReceiveTimestamp:serverTimestamp]; + } + } + if (serverID != 0) { outgoingMessage.openGroupServerMessageID = serverID; } diff --git a/SignalServiceKit/src/Messages/OWSMessageManager.m b/SignalServiceKit/src/Messages/OWSMessageManager.m index 1029e9025..c97b2fd09 100644 --- a/SignalServiceKit/src/Messages/OWSMessageManager.m +++ b/SignalServiceKit/src/Messages/OWSMessageManager.m @@ -915,6 +915,7 @@ NS_ASSUME_NONNULL_BEGIN [OWSRecordTranscriptJob processIncomingSentMessageTranscript:transcript serverID:0 + serverTimestamp:0 attachmentHandler:^(NSArray *attachmentStreams) { OWSAssertDebug(attachmentStreams.count == 1); TSAttachmentStream *attachmentStream = attachmentStreams.firstObject; @@ -943,6 +944,7 @@ NS_ASSUME_NONNULL_BEGIN [OWSRecordTranscriptJob processIncomingSentMessageTranscript:transcript serverID:(serverID ?: 0) + serverTimestamp:(uint64_t)envelope.serverTimestamp attachmentHandler:^(NSArray *attachmentStreams) { OWSLogDebug(@"successfully fetched transcript attachments: %lu", (unsigned long)attachmentStreams.count); From 1b621fc56df78d114851f67f014e9c0093850577 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Mon, 31 Aug 2020 11:20:22 +1000 Subject: [PATCH 10/30] Clean --- SignalServiceKit/src/Devices/OWSRecordTranscriptJob.m | 2 +- SignalServiceKit/src/Messages/Interactions/TSInteraction.h | 4 +--- SignalServiceKit/src/Messages/Interactions/TSInteraction.m | 2 +- SignalServiceKit/src/Messages/OWSMessageManager.m | 4 ++-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/SignalServiceKit/src/Devices/OWSRecordTranscriptJob.m b/SignalServiceKit/src/Devices/OWSRecordTranscriptJob.m index 02c4b4cd5..9977c9723 100644 --- a/SignalServiceKit/src/Devices/OWSRecordTranscriptJob.m +++ b/SignalServiceKit/src/Devices/OWSRecordTranscriptJob.m @@ -109,7 +109,7 @@ NS_ASSUME_NONNULL_BEGIN if (transcript.thread.isGroupThread) { TSGroupThread *thread = (TSGroupThread *)transcript.thread; if (thread.isPublicChat) { - [outgoingMessage setServerTimestampAsReceiveTimestamp:serverTimestamp]; + [outgoingMessage setServerTimestampToReceivedTimestamp:serverTimestamp]; } } diff --git a/SignalServiceKit/src/Messages/Interactions/TSInteraction.h b/SignalServiceKit/src/Messages/Interactions/TSInteraction.h index 0af44e964..b53c71b17 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSInteraction.h +++ b/SignalServiceKit/src/Messages/Interactions/TSInteraction.h @@ -42,9 +42,7 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value); /// Used for public chats where a message sent from a slave device is interpreted as having been sent from the master device. @property (nonatomic) NSString *actualSenderHexEncodedPublicKey; -- (void)setServerTimestampAsReceiveTimestamp:(uint64_t)receivedAtTimestamp; - -- (uint64_t)timestamp; +- (void)setServerTimestampToReceivedTimestamp:(uint64_t)receivedAtTimestamp; - (NSDate *)receivedAtDate; diff --git a/SignalServiceKit/src/Messages/Interactions/TSInteraction.m b/SignalServiceKit/src/Messages/Interactions/TSInteraction.m index dc5bc492a..502c55d35 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSInteraction.m +++ b/SignalServiceKit/src/Messages/Interactions/TSInteraction.m @@ -193,7 +193,7 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value) return self.timestamp; } -- (void)setServerTimestampAsReceiveTimestamp:(uint64_t)receivedAtTimestamp +- (void)setServerTimestampToReceivedTimestamp:(uint64_t)receivedAtTimestamp { _receivedAtTimestamp = receivedAtTimestamp; } diff --git a/SignalServiceKit/src/Messages/OWSMessageManager.m b/SignalServiceKit/src/Messages/OWSMessageManager.m index c97b2fd09..040dca1cc 100644 --- a/SignalServiceKit/src/Messages/OWSMessageManager.m +++ b/SignalServiceKit/src/Messages/OWSMessageManager.m @@ -1419,9 +1419,9 @@ NS_ASSUME_NONNULL_BEGIN serverTimestamp:serverTimestamp wasReceivedByUD:wasReceivedByUD]; - //For open group messages, use server timestamp as the receive timestamp + // For open group messages, use the server timestamp as the received timestamp if (oldGroupThread.isPublicChat) { - [incomingMessage setServerTimestampAsReceiveTimestamp:(uint64_t)envelope.serverTimestamp]; + [incomingMessage setServerTimestampToReceivedTimestamp:(uint64_t)envelope.serverTimestamp]; } // Loki: Set open group server ID if needed From c118daa061083be2c41632e36575b55f06e935f2 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Mon, 31 Aug 2020 13:49:16 +1000 Subject: [PATCH 11/30] Fix log --- .../src/Loki/API/Onion Requests/OnionRequestAPI.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift index 45a7c0e41..60540fd13 100644 --- a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift +++ b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift @@ -290,8 +290,7 @@ public enum OnionRequestAPI { let url = "\(guardSnode.address):\(guardSnode.port)/onion_req" let finalEncryptionResult = intermediate.finalEncryptionResult let onion = finalEncryptionResult.ciphertext - let requestSizeLimit = Double(FileServerAPI.maxFileSize) / FileServerAPI.fileSizeORMultiplier - if case Destination.server = destination, Double(onion.count) > 0.75 * requestSizeLimit { + if case Destination.server = destination, Double(onion.count) > 0.75 * Double(FileServerAPI.maxFileSize) { print("[Loki] Approaching request size limit: ~\(onion.count) bytes.") } let parameters: JSON = [ From 677b8e3348c2fc85d33c09ef49153209888d7247 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Mon, 31 Aug 2020 13:54:12 +1000 Subject: [PATCH 12/30] Fix SSK based closed group size inconsistency --- Signal/src/Loki/View Controllers/NewClosedGroupVC.swift | 2 +- .../src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Signal/src/Loki/View Controllers/NewClosedGroupVC.swift b/Signal/src/Loki/View Controllers/NewClosedGroupVC.swift index 3e31f2eff..dac0b5f99 100644 --- a/Signal/src/Loki/View Controllers/NewClosedGroupVC.swift +++ b/Signal/src/Loki/View Controllers/NewClosedGroupVC.swift @@ -174,7 +174,7 @@ final class NewClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelegat guard selectedContacts.count >= 1 else { return showError(title: "Please pick at least 1 group member") } - guard selectedContacts.count < 50 else { // Minus one because we're going to include self later + guard selectedContacts.count < ClosedGroupsProtocol.groupSizeLimit else { // Minus one because we're going to include self later return showError(title: NSLocalizedString("vc_create_closed_group_too_many_group_members_error", comment: "")) } let selectedContacts = self.selectedContacts diff --git a/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift b/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift index 8c233519a..3ce59d291 100644 --- a/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift +++ b/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift @@ -13,6 +13,7 @@ import PromiseKit @objc(LKClosedGroupsProtocol) public final class ClosedGroupsProtocol : NSObject { public static let isSharedSenderKeysEnabled = false + public static let groupSizeLimit = 10 // MARK: - Sending From e83205a3024d39c059192b26b3ff979b06e254b1 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Mon, 31 Aug 2020 15:51:12 +1000 Subject: [PATCH 13/30] Debug --- .../Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift b/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift index 3ce59d291..5622fc89a 100644 --- a/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift +++ b/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift @@ -183,6 +183,7 @@ public final class ClosedGroupsProtocol : NSObject { let userRatchet = SharedSenderKeysImplementation.shared.generateRatchet(for: groupPublicKey, senderPublicKey: userPublicKey, using: transaction) let userSenderKey = ClosedGroupSenderKey(chainKey: Data(hex: userRatchet.chainKey), keyIndex: userRatchet.keyIndex, publicKey: Data(hex: userPublicKey)) for member in members { // This internally takes care of multi device + guard member != userPublicKey else { continue } let thread = TSContactThread.getOrCreateThread(withContactId: member, transaction: transaction) thread.save(with: transaction) let closedGroupUpdateMessageKind = ClosedGroupUpdateMessage.Kind.senderKey(groupPublicKey: Data(hex: groupPublicKey), senderKey: userSenderKey) @@ -287,7 +288,7 @@ public final class ClosedGroupsProtocol : NSObject { } let group = thread.groupModel // Check that the sender is a member of the group (before the update) - var membersAndLinkedDevices: Set = Set(group.groupMemberIds) + var membersAndLinkedDevices: Set = Set(members) for member in group.groupMemberIds { let deviceLinks = OWSPrimaryStorage.shared().getDeviceLinks(for: member, in: transaction) membersAndLinkedDevices.formUnion(deviceLinks.flatMap { [ $0.master.publicKey, $0.slave.publicKey ] }) @@ -316,6 +317,7 @@ public final class ClosedGroupsProtocol : NSObject { let userRatchet = SharedSenderKeysImplementation.shared.generateRatchet(for: groupPublicKey, senderPublicKey: userPublicKey, using: transaction) let userSenderKey = ClosedGroupSenderKey(chainKey: Data(hex: userRatchet.chainKey), keyIndex: userRatchet.keyIndex, publicKey: Data(hex: userPublicKey)) for member in members { + guard member != userPublicKey else { continue } let thread = TSContactThread.getOrCreateThread(withContactId: member, transaction: transaction) thread.save(with: transaction) let closedGroupUpdateMessageKind = ClosedGroupUpdateMessage.Kind.senderKey(groupPublicKey: Data(hex: groupPublicKey), senderKey: userSenderKey) From 385dca2a81084d482f8e92c20e3b4ea55ba825fe Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Mon, 31 Aug 2020 16:04:10 +1000 Subject: [PATCH 14/30] Clean --- .../src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift b/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift index 5622fc89a..40aed41e1 100644 --- a/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift +++ b/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift @@ -55,6 +55,7 @@ public final class ClosedGroupsProtocol : NSObject { // Send a closed group update message to all members (and their linked devices) using established channels var promises: [Promise] = [] for member in members { // Not `membersAndLinkedDevices` as this internally takes care of multi device already + guard member != userPublicKey else { continue } let thread = TSContactThread.getOrCreateThread(withContactId: member, transaction: transaction) thread.save(with: transaction) let closedGroupUpdateMessageKind = ClosedGroupUpdateMessage.Kind.new(groupPublicKey: Data(hex: groupPublicKey), name: name, From 7773e9a2809018766133a1d8f80b5a103b878787 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Mon, 31 Aug 2020 16:15:57 +1000 Subject: [PATCH 15/30] fix bugs for open group time handling --- .../ConversationView/Cells/OWSMessageFooterView.m | 2 +- .../ConversationView/ConversationViewController.m | 8 ++++---- .../ConversationView/ConversationViewModel.m | 4 ++-- .../src/Messages/Interactions/TSInteraction.h | 3 +++ .../src/Messages/Interactions/TSInteraction.m | 10 ++++------ 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m index d63a8baa8..09782265d 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m @@ -195,7 +195,7 @@ NS_ASSUME_NONNULL_BEGIN timestampLabelText = NSLocalizedString(@"MESSAGE_STATUS_SEND_FAILED", @"Label indicating that a message failed to send."); } else { - timestampLabelText = [DateUtil formatMessageTimestamp:viewItem.interaction.timestamp]; + timestampLabelText = [DateUtil formatMessageTimestamp:viewItem.interaction.timestampForUI]; } TSMessage *message = [viewItem.interaction as:TSMessage.class]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 96f84c3ff..1d8a91499 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -4683,7 +4683,7 @@ typedef enum : NSUInteger { OWSAssertDebug(left <= mid); OWSAssertDebug(mid < right); id viewItem = self.viewItems[mid]; - if (viewItem.interaction.timestamp >= viewHorizonTimestamp) { + if (viewItem.interaction.timestampForUI >= viewHorizonTimestamp) { right = mid; } else { // This is an optimization; it also ensures that we converge. @@ -4692,7 +4692,7 @@ typedef enum : NSUInteger { } OWSAssertDebug(left == right); id viewItem = self.viewItems[left]; - if (viewItem.interaction.timestamp >= viewHorizonTimestamp) { + if (viewItem.interaction.timestampForUI >= viewHorizonTimestamp) { OWSLogInfo(@"firstIndexPathAtViewHorizonTimestamp: %zd / %zd", left, self.viewItems.count); return [NSIndexPath indexPathForRow:(NSInteger) left inSection:0]; } else { @@ -5402,7 +5402,7 @@ typedef enum : NSUInteger { __block TSInteraction *targetInteraction; [LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [self.thread enumerateInteractionsWithTransaction:transaction usingBlock:^(TSInteraction *interaction, YapDatabaseReadTransaction *t) { - if (interaction.timestamp == timestamp.unsignedLongLongValue) { + if (interaction.timestampForUI == timestamp.unsignedLongLongValue) { targetInteraction = interaction; } }]; @@ -5426,7 +5426,7 @@ typedef enum : NSUInteger { { __block TSInteraction *targetInteraction; [self.thread enumerateInteractionsUsingBlock:^(TSInteraction *interaction) { - if (interaction.timestamp == timestamp.unsignedLongLongValue) { + if (interaction.timestampForUI == timestamp.unsignedLongLongValue) { targetInteraction = interaction; } }]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m index 693392413..1b438a869 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m @@ -1350,7 +1350,7 @@ static const int kYapDatabaseRangeMaxLength = 25000; break; } - uint64_t viewItemTimestamp = viewItem.interaction.timestamp; + uint64_t viewItemTimestamp = viewItem.interaction.timestampForUI; OWSAssertDebug(viewItemTimestamp > 0); BOOL shouldShowDate = NO; @@ -1417,7 +1417,7 @@ static const int kYapDatabaseRangeMaxLength = 25000; NSAttributedString *_Nullable senderName = nil; OWSInteractionType interactionType = viewItem.interaction.interactionType; - NSString *timestampText = [DateUtil formatTimestampShort:viewItem.interaction.timestamp]; + NSString *timestampText = [DateUtil formatTimestampShort:viewItem.interaction.timestampForUI]; if (interactionType == OWSInteractionType_OutgoingMessage) { TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)viewItem.interaction; diff --git a/SignalServiceKit/src/Messages/Interactions/TSInteraction.h b/SignalServiceKit/src/Messages/Interactions/TSInteraction.h index b53c71b17..2d230db56 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSInteraction.h +++ b/SignalServiceKit/src/Messages/Interactions/TSInteraction.h @@ -39,11 +39,14 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value); @property (nonatomic, readonly) uint64_t timestamp; @property (nonatomic, readonly) uint64_t sortId; @property (nonatomic, readonly) uint64_t receivedAtTimestamp; +@property (nonatomic, readonly) BOOL shouldUseServerTime; /// Used for public chats where a message sent from a slave device is interpreted as having been sent from the master device. @property (nonatomic) NSString *actualSenderHexEncodedPublicKey; - (void)setServerTimestampToReceivedTimestamp:(uint64_t)receivedAtTimestamp; +- (uint64_t)timestampForUI; + - (NSDate *)receivedAtDate; - (OWSInteractionType)interactionType; diff --git a/SignalServiceKit/src/Messages/Interactions/TSInteraction.m b/SignalServiceKit/src/Messages/Interactions/TSInteraction.m index 502c55d35..2d818d150 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSInteraction.m +++ b/SignalServiceKit/src/Messages/Interactions/TSInteraction.m @@ -177,13 +177,10 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value) #pragma mark Date operations -- (uint64_t)timestamp +- (uint64_t)timestampForUI { - if (self.thread.isGroupThread) { - TSGroupThread *thread = (TSGroupThread *)self.thread; - if (thread.isPublicChat) { - return _receivedAtTimestamp; - } + if (_shouldUseServerTime) { + return _receivedAtTimestamp; } return _timestamp; } @@ -195,6 +192,7 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value) - (void)setServerTimestampToReceivedTimestamp:(uint64_t)receivedAtTimestamp { + _shouldUseServerTime = YES; _receivedAtTimestamp = receivedAtTimestamp; } From cd7efff6f84cc25db34a851bf86f6e55900f1fa7 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Tue, 1 Sep 2020 10:36:47 +1000 Subject: [PATCH 16/30] Also request sender keys on failed encryption --- .../SharedSenderKeysImplementation.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/SignalServiceKit/src/Loki/Protocol/Closed Groups/SharedSenderKeysImplementation.swift b/SignalServiceKit/src/Loki/Protocol/Closed Groups/SharedSenderKeysImplementation.swift index 9f988f976..cc0da29b5 100644 --- a/SignalServiceKit/src/Loki/Protocol/Closed Groups/SharedSenderKeysImplementation.swift +++ b/SignalServiceKit/src/Loki/Protocol/Closed Groups/SharedSenderKeysImplementation.swift @@ -133,7 +133,17 @@ public final class SharedSenderKeysImplementation : NSObject, SharedSenderKeysPr } public func encrypt(_ plaintext: Data, for groupPublicKey: String, senderPublicKey: String, using transaction: YapDatabaseReadWriteTransaction) throws -> (ivAndCiphertext: Data, keyIndex: UInt) { - let ratchet = try stepRatchetOnce(for: groupPublicKey, senderPublicKey: senderPublicKey, using: transaction) + let ratchet: ClosedGroupRatchet + do { + ratchet = try stepRatchetOnce(for: groupPublicKey, senderPublicKey: senderPublicKey, using: transaction) + } catch { + // FIXME: It'd be cleaner to handle this in OWSMessageDecrypter (where all the other decryption errors are handled), but this was a lot more + // convenient because there's an easy way to get the sender public key from here. + if case RatchetingError.loadingFailed(_, _) = error { + ClosedGroupsProtocol.requestSenderKey(for: groupPublicKey, senderPublicKey: senderPublicKey, using: transaction) + } + throw error + } let iv = Data.getSecureRandomData(ofSize: SharedSenderKeysImplementation.ivSize)! let gcm = GCM(iv: iv.bytes, tagLength: Int(SharedSenderKeysImplementation.gcmTagSize), mode: .combined) let messageKey = ratchet.messageKeys.last! From aa14e9b7adbffbd9268903d0ba81d880218f3b18 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Tue, 1 Sep 2020 10:37:28 +1000 Subject: [PATCH 17/30] Don't show leave group option if user has already left --- .../OWSConversationSettingsViewController.m | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index 3a0da4db5..5e7eb4304 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -683,22 +683,25 @@ const CGFloat kIconViewLength = 24; [weakSelf showGroupMembersView]; }] ]; - [mainSection addItem:[OWSTableItem - itemWithCustomCellBlock:^{ - UITableViewCell *cell = - [weakSelf disclosureCellWithName:NSLocalizedString(@"LEAVE_GROUP_ACTION", - @"table cell label in conversation settings") - iconName:@"table_ic_group_leave" - accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( - OWSConversationSettingsViewController, @"leave_group")]; - cell.userInteractionEnabled = !weakSelf.hasLeftGroup; - - return cell; - } - actionBlock:^{ - [weakSelf didTapLeaveGroup]; - }] - ]; + NSString *userPublicKey = OWSIdentityManager.sharedManager.identityKeyPair.hexEncodedPublicKey; + if ([((TSGroupThread *)self.thread).groupModel.groupMemberIds containsObject:userPublicKey]) { + [mainSection addItem:[OWSTableItem + itemWithCustomCellBlock:^{ + UITableViewCell *cell = + [weakSelf disclosureCellWithName:NSLocalizedString(@"LEAVE_GROUP_ACTION", + @"table cell label in conversation settings") + iconName:@"table_ic_group_leave" + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( + OWSConversationSettingsViewController, @"leave_group")]; + cell.userInteractionEnabled = !weakSelf.hasLeftGroup; + + return cell; + } + actionBlock:^{ + [weakSelf didTapLeaveGroup]; + }] + ]; + } } From 2725e2096d6082f4e3cd5aecb08c01da2b02ee3a Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Tue, 1 Sep 2020 10:37:44 +1000 Subject: [PATCH 18/30] Add logs --- .../src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift b/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift index 40aed41e1..2fb9aa316 100644 --- a/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift +++ b/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift @@ -204,6 +204,7 @@ public final class ClosedGroupsProtocol : NSObject { } public static func requestSenderKey(for groupPublicKey: String, senderPublicKey: String, using transaction: YapDatabaseReadWriteTransaction) { + print("[Loki] Requesting sender key for group public key: \(groupPublicKey), sender public key: \(senderPublicKey).") // Establish session if needed SessionManagementProtocol.sendSessionRequestIfNeeded(to: senderPublicKey, using: transaction) // Send the request @@ -358,6 +359,7 @@ public final class ClosedGroupsProtocol : NSObject { return print("[Loki] Ignoring closed group sender key request from non-member.") } // Respond to the request + print("[Loki] Responding to sender key request from: \(senderPublicKey).") SessionManagementProtocol.sendSessionRequestIfNeeded(to: senderPublicKey, using: transaction) // This internally takes care of multi device let userRatchet = SharedSenderKeysImplementation.shared.generateRatchet(for: groupPublicKey, senderPublicKey: userPublicKey, using: transaction) let userSenderKey = ClosedGroupSenderKey(chainKey: Data(hex: userRatchet.chainKey), keyIndex: userRatchet.keyIndex, publicKey: Data(hex: userPublicKey)) @@ -393,6 +395,7 @@ public final class ClosedGroupsProtocol : NSObject { return print("[Loki] Ignoring invalid closed group sender key.") } // Store the sender key + print("[Loki] Received a sender key from: \(senderPublicKey).") let ratchet = ClosedGroupRatchet(chainKey: senderKey.chainKey.toHexString(), keyIndex: UInt(senderKey.keyIndex), messageKeys: []) Storage.setClosedGroupRatchet(for: groupPublicKey, senderPublicKey: senderPublicKey, ratchet: ratchet, using: transaction) } From 78e6651e8785125f43cbfd7a753fa52fafe32e0e Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Tue, 1 Sep 2020 13:31:11 +1000 Subject: [PATCH 19/30] Fix missed error handling case --- .../Loki/API/Onion Requests/OnionRequestAPI.swift | 8 +++++++- SignalServiceKit/src/Loki/API/SnodeAPI.swift | 14 ++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift index 45a7c0e41..f0b90bac5 100644 --- a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift +++ b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift @@ -339,7 +339,13 @@ public enum OnionRequestAPI { } } promise.catch2 { error in // Must be invoked on LokiAPI.workQueue - guard case HTTP.Error.httpRequestFailed(_, _) = error else { return } + guard case HTTP.Error.httpRequestFailed(let statusCode, let json) = error else { return } + // Marking all the snodes in the path as unreliable here is aggressive, but otherwise users + // can get stuck with a failing path that just refreshes to the same path. + let path = paths.first { $0.contains(guardSnode) } + path?.forEach { snode in + SnodeAPI.handleError(withStatusCode: statusCode, json: json, forSnode: snode) // Intentionally don't throw + } dropAllPaths() // A snode in the path is bad; retry with a different path dropGuardSnode(guardSnode) } diff --git a/SignalServiceKit/src/Loki/API/SnodeAPI.swift b/SignalServiceKit/src/Loki/API/SnodeAPI.swift index 9e24ba37f..5c2255574 100644 --- a/SignalServiceKit/src/Loki/API/SnodeAPI.swift +++ b/SignalServiceKit/src/Loki/API/SnodeAPI.swift @@ -296,7 +296,7 @@ public final class SnodeAPI : NSObject { // MARK: Error Handling /// - Note: Should only be invoked from `LokiAPI.workQueue` to avoid race conditions. - internal static func handleError(withStatusCode statusCode: UInt, json: JSON?, forSnode snode: Snode, associatedWith publicKey: String) -> Error? { + internal static func handleError(withStatusCode statusCode: UInt, json: JSON?, forSnode snode: Snode, associatedWith publicKey: String? = nil) -> Error? { #if DEBUG assertOnQueue(SnodeAPI.workQueue) #endif @@ -307,7 +307,9 @@ public final class SnodeAPI : NSObject { print("[Loki] Couldn't reach snode at: \(snode); setting failure count to \(newFailureCount).") if newFailureCount >= SnodeAPI.snodeFailureThreshold { print("[Loki] Failure threshold reached for: \(snode); dropping it.") - SnodeAPI.dropSnodeFromSwarmIfNeeded(snode, publicKey: publicKey) + if let publicKey = publicKey { + SnodeAPI.dropSnodeFromSwarmIfNeeded(snode, publicKey: publicKey) + } SnodeAPI.dropSnodeFromSnodePool(snode) SnodeAPI.snodeFailureCount[snode] = 0 } @@ -321,8 +323,12 @@ public final class SnodeAPI : NSObject { return SnodeAPI.SnodeAPIError.clockOutOfSync case 421: // The snode isn't associated with the given public key anymore - print("[Loki] Invalidating swarm for: \(publicKey).") - SnodeAPI.dropSnodeFromSwarmIfNeeded(snode, publicKey: publicKey) + if let publicKey = publicKey { + print("[Loki] Invalidating swarm for: \(publicKey).") + SnodeAPI.dropSnodeFromSwarmIfNeeded(snode, publicKey: publicKey) + } else { + print("[Loki] Got a 421 without an associated public key.") + } case 432: // The proof of work difficulty is too low if let powDifficulty = json?["difficulty"] as? UInt { From 2b3e97f6cc8928d1583aea9c56bdf56a5faaf948 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Wed, 2 Sep 2020 09:17:01 +1000 Subject: [PATCH 20/30] Tweak error handling --- .../src/Loki/API/Onion Requests/OnionRequestAPI.swift | 9 ++------- SignalServiceKit/src/Loki/API/SnodeAPI.swift | 5 +++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift index f0b90bac5..e9f2f9035 100644 --- a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift +++ b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift @@ -6,11 +6,6 @@ public enum OnionRequestAPI { public static var guardSnodes: Set = [] public static var paths: [Path] = [] // Not a set to ensure we consistently show the same path to the user - private static var snodePool: Set { - let unreliableSnodes = Set(SnodeAPI.snodeFailureCount.keys) - return SnodeAPI.snodePool.subtracting(unreliableSnodes) - } - // MARK: Settings /// The number of snodes (including the guard snode) in a path. private static let pathSize: UInt = 3 @@ -84,7 +79,7 @@ public enum OnionRequestAPI { } else { print("[Loki] [Onion Request API] Populating guard snode cache.") return SnodeAPI.getRandomSnode().then2 { _ -> Promise> in // Just used to populate the snode pool - var unusedSnodes = snodePool // Sync on LokiAPI.workQueue + var unusedSnodes = SnodeAPI.snodePool // Sync on LokiAPI.workQueue guard unusedSnodes.count >= guardSnodeCount else { throw Error.insufficientSnodes } func getGuardSnode() -> Promise { // randomElement() uses the system's default random generator, which is cryptographically secure @@ -115,7 +110,7 @@ public enum OnionRequestAPI { } return SnodeAPI.getRandomSnode().then2 { _ -> Promise<[Path]> in // Just used to populate the snode pool return getGuardSnodes().map2 { guardSnodes -> [Path] in - var unusedSnodes = snodePool.subtracting(guardSnodes) + var unusedSnodes = SnodeAPI.snodePool.subtracting(guardSnodes) let pathSnodeCount = guardSnodeCount * pathSize - guardSnodeCount guard unusedSnodes.count >= pathSnodeCount else { throw Error.insufficientSnodes } // Don't test path snodes as this would reveal the user's IP to them diff --git a/SignalServiceKit/src/Loki/API/SnodeAPI.swift b/SignalServiceKit/src/Loki/API/SnodeAPI.swift index 5c2255574..420a8aa22 100644 --- a/SignalServiceKit/src/Loki/API/SnodeAPI.swift +++ b/SignalServiceKit/src/Loki/API/SnodeAPI.swift @@ -15,10 +15,10 @@ public final class SnodeAPI : NSObject { // MARK: Settings private static let maxRetryCount: UInt = 4 - private static let minimumSnodePoolCount = 32 + private static let minimumSnodePoolCount = 64 private static let minimumSwarmSnodeCount = 2 private static let seedNodePool: Set = [ "https://storage.seed1.loki.network", "https://storage.seed3.loki.network", "https://public.loki.foundation" ] - private static let snodeFailureThreshold = 2 + private static let snodeFailureThreshold = 1 private static let targetSwarmSnodeCount = 2 internal static var powDifficulty: UInt = 1 @@ -311,6 +311,7 @@ public final class SnodeAPI : NSObject { SnodeAPI.dropSnodeFromSwarmIfNeeded(snode, publicKey: publicKey) } SnodeAPI.dropSnodeFromSnodePool(snode) + print("[Loki] Snode pool count: \(snodePool.count).") SnodeAPI.snodeFailureCount[snode] = 0 } } From 5ee52c2793bbea5c912e82e0ab4a5443226734a6 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Wed, 2 Sep 2020 10:29:31 +1000 Subject: [PATCH 21/30] Update version number --- Signal.xcodeproj/project.pbxproj | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index acbe04bf1..ff9ed4026 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -4088,7 +4088,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 106; + CURRENT_PROJECT_VERSION = 107; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -4102,7 +4102,7 @@ INFOPLIST_FILE = SignalShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.6; + MARKETING_VERSION = 1.4.7; MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.share-extension"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -4150,7 +4150,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 106; + CURRENT_PROJECT_VERSION = 107; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -4169,7 +4169,7 @@ INFOPLIST_FILE = SignalShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.6; + MARKETING_VERSION = 1.4.7; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.share-extension"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -4204,7 +4204,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 106; + CURRENT_PROJECT_VERSION = 107; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; @@ -4223,7 +4223,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 1.4.6; + MARKETING_VERSION = 1.4.7; MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.utilities"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; @@ -4274,7 +4274,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 106; + CURRENT_PROJECT_VERSION = 107; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; @@ -4298,7 +4298,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 1.4.6; + MARKETING_VERSION = 1.4.7; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.utilities"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; @@ -4336,7 +4336,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 106; + CURRENT_PROJECT_VERSION = 107; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -4348,7 +4348,7 @@ INFOPLIST_FILE = LokiPushNotificationService/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.6; + MARKETING_VERSION = 1.4.7; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.push-notification-service"; @@ -4399,7 +4399,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 106; + CURRENT_PROJECT_VERSION = 107; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -4416,7 +4416,7 @@ INFOPLIST_FILE = LokiPushNotificationService/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.6; + MARKETING_VERSION = 1.4.7; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.push-notification-service"; @@ -4600,7 +4600,7 @@ CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 106; + CURRENT_PROJECT_VERSION = 107; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4635,7 +4635,7 @@ "$(SRCROOT)", ); LLVM_LTO = NO; - MARKETING_VERSION = 1.4.6; + MARKETING_VERSION = 1.4.7; OTHER_LDFLAGS = "$(inherited)"; OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger"; @@ -4668,7 +4668,7 @@ CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 106; + CURRENT_PROJECT_VERSION = 107; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4703,7 +4703,7 @@ "$(SRCROOT)", ); LLVM_LTO = NO; - MARKETING_VERSION = 1.4.6; + MARKETING_VERSION = 1.4.7; OTHER_LDFLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger"; PRODUCT_NAME = Session; From 17e84169a2ac342de9235f8f9dcac63e2a24095e Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Wed, 2 Sep 2020 13:22:32 +1000 Subject: [PATCH 22/30] Update light mode sheet copy --- Signal/src/Loki/View Controllers/LightModeSheet.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Signal/src/Loki/View Controllers/LightModeSheet.swift b/Signal/src/Loki/View Controllers/LightModeSheet.swift index 6f956bed5..c84482e71 100644 --- a/Signal/src/Loki/View Controllers/LightModeSheet.swift +++ b/Signal/src/Loki/View Controllers/LightModeSheet.swift @@ -21,9 +21,11 @@ final class LightModeSheet : Sheet { explanationLabel.textColor = Colors.text explanationLabel.font = .systemFont(ofSize: Values.smallFontSize) explanationLabel.text = """ - Who left the lights on? bla bla bla + Whoops, who left the lights on? - Feeling the dark side more? Just pop into the in-app settings and tap the app mode button in the top-right to toggle dark mode again. + That’s right, Session has a spiffy new light mode! Take the fresh new color palette for a spin — it’s now the default mode. + + Want to go back to the dark side? Just tap the moon symbol in the in-app settings to switch modes. """ explanationLabel.numberOfLines = 0 explanationLabel.lineBreakMode = .byWordWrapping From f0d9df0e120fae918a0226999fe9f7dffacbf388 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Wed, 2 Sep 2020 16:32:53 +1000 Subject: [PATCH 23/30] Fix crash --- Signal/src/Loki/Components/ConversationTitleView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Signal/src/Loki/Components/ConversationTitleView.swift b/Signal/src/Loki/Components/ConversationTitleView.swift index 6de074a79..14ca28b27 100644 --- a/Signal/src/Loki/Components/ConversationTitleView.swift +++ b/Signal/src/Loki/Components/ConversationTitleView.swift @@ -114,8 +114,8 @@ final class ConversationTitleView : UIView { guard let timestamp = notification.object as? NSNumber else { return } setStatusIfNeeded(to: .messageSent, forMessageWithTimestamp: timestamp) handledMessageTimestamps.insert(timestamp) - DispatchQueue.main.asyncAfter(deadline: .now() + 1) { - self.clearStatusIfNeededForMessageWithTimestamp(timestamp) + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in + self?.clearStatusIfNeededForMessageWithTimestamp(timestamp) } } From 6cb0cd48c35a297ad7011a195af4f7558471f909 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Thu, 3 Sep 2020 07:16:48 +1000 Subject: [PATCH 24/30] Make error handling a bit less aggressive again --- SignalServiceKit/src/Loki/API/SnodeAPI.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SignalServiceKit/src/Loki/API/SnodeAPI.swift b/SignalServiceKit/src/Loki/API/SnodeAPI.swift index 420a8aa22..161fed6ee 100644 --- a/SignalServiceKit/src/Loki/API/SnodeAPI.swift +++ b/SignalServiceKit/src/Loki/API/SnodeAPI.swift @@ -18,7 +18,7 @@ public final class SnodeAPI : NSObject { private static let minimumSnodePoolCount = 64 private static let minimumSwarmSnodeCount = 2 private static let seedNodePool: Set = [ "https://storage.seed1.loki.network", "https://storage.seed3.loki.network", "https://public.loki.foundation" ] - private static let snodeFailureThreshold = 1 + private static let snodeFailureThreshold = 2 private static let targetSwarmSnodeCount = 2 internal static var powDifficulty: UInt = 1 From 74e3ed6c83e07571d6144b5895db15d9e0a9816c Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Thu, 3 Sep 2020 07:17:30 +1000 Subject: [PATCH 25/30] Update version number --- Signal.xcodeproj/project.pbxproj | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index ff9ed4026..f381a90d6 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -4088,7 +4088,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 107; + CURRENT_PROJECT_VERSION = 108; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -4102,7 +4102,7 @@ INFOPLIST_FILE = SignalShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.7; + MARKETING_VERSION = 1.4.8; MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.share-extension"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -4150,7 +4150,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 107; + CURRENT_PROJECT_VERSION = 108; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -4169,7 +4169,7 @@ INFOPLIST_FILE = SignalShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.7; + MARKETING_VERSION = 1.4.8; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.share-extension"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -4204,7 +4204,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 107; + CURRENT_PROJECT_VERSION = 108; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; @@ -4223,7 +4223,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 1.4.7; + MARKETING_VERSION = 1.4.8; MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.utilities"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; @@ -4274,7 +4274,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 107; + CURRENT_PROJECT_VERSION = 108; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; @@ -4298,7 +4298,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 1.4.7; + MARKETING_VERSION = 1.4.8; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.utilities"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; @@ -4336,7 +4336,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 107; + CURRENT_PROJECT_VERSION = 108; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -4348,7 +4348,7 @@ INFOPLIST_FILE = LokiPushNotificationService/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.7; + MARKETING_VERSION = 1.4.8; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.push-notification-service"; @@ -4399,7 +4399,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 107; + CURRENT_PROJECT_VERSION = 108; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -4416,7 +4416,7 @@ INFOPLIST_FILE = LokiPushNotificationService/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.7; + MARKETING_VERSION = 1.4.8; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.push-notification-service"; @@ -4600,7 +4600,7 @@ CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 107; + CURRENT_PROJECT_VERSION = 108; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4635,7 +4635,7 @@ "$(SRCROOT)", ); LLVM_LTO = NO; - MARKETING_VERSION = 1.4.7; + MARKETING_VERSION = 1.4.8; OTHER_LDFLAGS = "$(inherited)"; OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger"; @@ -4668,7 +4668,7 @@ CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 107; + CURRENT_PROJECT_VERSION = 108; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4703,7 +4703,7 @@ "$(SRCROOT)", ); LLVM_LTO = NO; - MARKETING_VERSION = 1.4.7; + MARKETING_VERSION = 1.4.8; OTHER_LDFLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger"; PRODUCT_NAME = Session; From 59e1772f218cf550c772e17d047d68fb0cd5a618 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Thu, 3 Sep 2020 10:59:00 +1000 Subject: [PATCH 26/30] Update version number --- Signal.xcodeproj/project.pbxproj | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 5a250754a..1aa535ec6 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -4100,7 +4100,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 108; + CURRENT_PROJECT_VERSION = 109; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -4114,7 +4114,7 @@ INFOPLIST_FILE = SignalShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.8; + MARKETING_VERSION = 1.5.0; MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.share-extension"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -4162,7 +4162,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 108; + CURRENT_PROJECT_VERSION = 109; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -4181,7 +4181,7 @@ INFOPLIST_FILE = SignalShareExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.8; + MARKETING_VERSION = 1.5.0; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.share-extension"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -4216,7 +4216,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 108; + CURRENT_PROJECT_VERSION = 109; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; @@ -4235,7 +4235,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 1.4.8; + MARKETING_VERSION = 1.5.0; MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.utilities"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; @@ -4286,7 +4286,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 108; + CURRENT_PROJECT_VERSION = 109; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = SUQ8J2PCT7; @@ -4310,7 +4310,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 1.4.8; + MARKETING_VERSION = 1.5.0; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.utilities"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; @@ -4348,7 +4348,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 108; + CURRENT_PROJECT_VERSION = 109; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -4360,7 +4360,7 @@ INFOPLIST_FILE = LokiPushNotificationService/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.8; + MARKETING_VERSION = 1.5.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.push-notification-service"; @@ -4411,7 +4411,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 108; + CURRENT_PROJECT_VERSION = 109; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -4428,7 +4428,7 @@ INFOPLIST_FILE = LokiPushNotificationService/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 1.4.8; + MARKETING_VERSION = 1.5.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.push-notification-service"; @@ -4612,7 +4612,7 @@ CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 108; + CURRENT_PROJECT_VERSION = 109; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4647,7 +4647,7 @@ "$(SRCROOT)", ); LLVM_LTO = NO; - MARKETING_VERSION = 1.4.8; + MARKETING_VERSION = 1.5.0; OTHER_LDFLAGS = "$(inherited)"; OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger"; @@ -4680,7 +4680,7 @@ CODE_SIGN_ENTITLEMENTS = Signal/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 108; + CURRENT_PROJECT_VERSION = 109; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4715,7 +4715,7 @@ "$(SRCROOT)", ); LLVM_LTO = NO; - MARKETING_VERSION = 1.4.8; + MARKETING_VERSION = 1.5.0; OTHER_LDFLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger"; PRODUCT_NAME = Session; From 19910c5793c9dc7c34426c89a72350cb50a6a522 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Thu, 3 Sep 2020 11:53:57 +1000 Subject: [PATCH 27/30] Fix text alignment --- Signal/src/Loki/View Controllers/LightModeSheet.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Signal/src/Loki/View Controllers/LightModeSheet.swift b/Signal/src/Loki/View Controllers/LightModeSheet.swift index c84482e71..2e9a9e3bd 100644 --- a/Signal/src/Loki/View Controllers/LightModeSheet.swift +++ b/Signal/src/Loki/View Controllers/LightModeSheet.swift @@ -20,6 +20,7 @@ final class LightModeSheet : Sheet { let explanationLabel = UILabel() explanationLabel.textColor = Colors.text explanationLabel.font = .systemFont(ofSize: Values.smallFontSize) + explanationLabel.textAlignment = .center explanationLabel.text = """ Whoops, who left the lights on? From 4a08e12752be3c141ab19c120d067075c765a9db Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Thu, 3 Sep 2020 15:17:32 +1000 Subject: [PATCH 28/30] Fix session reset bug --- .../ConversationView/ConversationViewController.m | 1 + .../Protocol/Session Management/SessionManagementProtocol.swift | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 1d8a91499..d0319c386 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -1240,6 +1240,7 @@ typedef enum : NSUInteger { [LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [LKSessionManagementProtocol startSessionResetInThread:self.thread transaction:transaction]; } error:nil]; + [self updateSessionRestoreBanner]; }); } diff --git a/SignalServiceKit/src/Loki/Protocol/Session Management/SessionManagementProtocol.swift b/SignalServiceKit/src/Loki/Protocol/Session Management/SessionManagementProtocol.swift index b189ab16a..93e5a2f37 100644 --- a/SignalServiceKit/src/Loki/Protocol/Session Management/SessionManagementProtocol.swift +++ b/SignalServiceKit/src/Loki/Protocol/Session Management/SessionManagementProtocol.swift @@ -141,7 +141,6 @@ public final class SessionManagementProtocol : NSObject { guard let thread = thread as? TSContactThread else { return print("[Loki] Can't restore session for non contact thread.") } - guard thread.sessionResetStatus == .none else { return } // Send end session messages to the devices requiring session restoration let devices = thread.sessionRestoreDevices // TODO: Rename this to something that reads better for device in devices { From 99229800a1d2e4c9cc785803cc653f623de7b913 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Fri, 4 Sep 2020 10:07:05 +1000 Subject: [PATCH 29/30] Add manual session reset button --- .../ConversationViewController.m | 8 +++-- .../OWSConversationSettingsViewController.m | 29 +++++++++++++++++++ .../src/Messages/OWSMessageDecrypter.m | 2 +- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index d0319c386..64a75c45a 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -1236,11 +1236,15 @@ typedef enum : NSUInteger { } - (void)restoreSession { + if (![self.thread isKindOfClass:TSContactThread.class]) { return; } + TSContactThread *thread = (TSContactThread *)self.thread; + __weak ConversationViewController *weakSelf = self; dispatch_async(dispatch_get_main_queue(), ^{ [LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { - [LKSessionManagementProtocol startSessionResetInThread:self.thread transaction:transaction]; + [thread addSessionRestoreDevice:thread.contactIdentifier transaction:transaction]; + [LKSessionManagementProtocol startSessionResetInThread:thread transaction:transaction]; } error:nil]; - [self updateSessionRestoreBanner]; + [weakSelf updateSessionRestoreBanner]; }); } diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index 5e7eb4304..8246b2536 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -860,6 +860,15 @@ const CGFloat kIconViewLength = 24; return cell; } actionBlock:nil]]; + + [mainSection addItem: + [OWSTableItem itemWithCustomCellBlock:^{ + NSString *title = @"Reset Secure Session"; + NSString *accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(OWSConversationSettingsViewController, @"reset_secure_session"); + return [weakSelf disclosureCellWithName:title iconName:@"system_message_security" accessibilityIdentifier:accessibilityIdentifier]; + } + actionBlock:^{ [weakSelf resetSecureSession]; }] + ]; } self.contents = contents; @@ -1421,6 +1430,26 @@ const CGFloat kIconViewLength = 24; [self.conversationSettingsViewDelegate conversationSettingsDidRequestConversationSearch:self]; } +- (void)resetSecureSession +{ + if (![self.thread isKindOfClass:TSContactThread.class]) { return; } + TSContactThread *thread = (TSContactThread *)self.thread; + __weak OWSConversationSettingsViewController *weakSelf = self; + NSString *message = @"This may help if you're having encryption problems in this conversation. Your messages will be kept."; + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Reset Secure Session?" message:message preferredStyle:UIAlertControllerStyleAlert]; + [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"TXT_CANCEL_TITLE", @"") style:UIAlertActionStyleDefault handler:nil]]; + [alert addAction:[UIAlertAction actionWithTitle:@"Reset" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + dispatch_async(dispatch_get_main_queue(), ^{ + [LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { + [thread addSessionRestoreDevice:thread.contactIdentifier transaction:transaction]; + [LKSessionManagementProtocol startSessionResetInThread:thread transaction:transaction]; + } error:nil]; + [weakSelf.navigationController popViewControllerAnimated:YES]; + }); + }]]; + [self presentViewController:alert animated:YES completion:nil]; +} + #pragma mark - Notifications - (void)identityStateDidChange:(NSNotification *)notification diff --git a/SignalServiceKit/src/Messages/OWSMessageDecrypter.m b/SignalServiceKit/src/Messages/OWSMessageDecrypter.m index 3a84b0f80..9c676640e 100644 --- a/SignalServiceKit/src/Messages/OWSMessageDecrypter.m +++ b/SignalServiceKit/src/Messages/OWSMessageDecrypter.m @@ -581,7 +581,7 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes return; } - // FIXME: This is a temporary patch for bad mac issues. At least with this people will be able to message again. We have to figure out the root cause of the issue though. + // Attempt to recover automatically if ([decryptError userInfo][NSUnderlyingErrorKey] != nil) { NSDictionary *underlyingErrorUserInfo = [[decryptError userInfo][NSUnderlyingErrorKey] userInfo]; if (underlyingErrorUserInfo[SCKExceptionWrapperUnderlyingExceptionKey] != nil) { From c98eb5fca04aca4aa452aeaebb56c92ace832d4a Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Fri, 4 Sep 2020 10:15:33 +1000 Subject: [PATCH 30/30] Add version number to settings --- Signal/src/Loki/View Controllers/SettingsVC.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Signal/src/Loki/View Controllers/SettingsVC.swift b/Signal/src/Loki/View Controllers/SettingsVC.swift index d59257085..4ea1833b8 100644 --- a/Signal/src/Loki/View Controllers/SettingsVC.swift +++ b/Signal/src/Loki/View Controllers/SettingsVC.swift @@ -120,8 +120,18 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate { getSettingButtons().forEach { settingButtonOrSeparator in settingButtonsStackView.addArrangedSubview(settingButtonOrSeparator) } + // Set up version label + let versionLabel = UILabel() + versionLabel.textColor = Colors.text.withAlphaComponent(Values.unimportantElementOpacity) + versionLabel.font = .systemFont(ofSize: Values.verySmallFontSize) + versionLabel.numberOfLines = 0 + versionLabel.textAlignment = .center + versionLabel.lineBreakMode = .byCharWrapping + let version = Bundle.main.infoDictionary!["CFBundleShortVersionString"]! + let buildNumber = Bundle.main.infoDictionary!["CFBundleVersion"]! + versionLabel.text = "Version \(version) (\(buildNumber))" // Set up stack view - let stackView = UIStackView(arrangedSubviews: [ topStackView, settingButtonsStackView ]) + let stackView = UIStackView(arrangedSubviews: [ topStackView, settingButtonsStackView, versionLabel ]) stackView.axis = .vertical stackView.spacing = Values.largeSpacing stackView.alignment = .fill