Make things compile again
This commit is contained in:
parent
9bc80ed3b3
commit
d096a2c574
|
@ -8,7 +8,6 @@
|
|||
|
||||
/* Begin PBXBuildFile section */
|
||||
2400888E239F30A600305217 /* SessionRestorationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2400888D239F30A600305217 /* SessionRestorationView.swift */; };
|
||||
241C1192245F8878005CB2F4 /* LK001UpdateFriendRequestStatusStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 241C1191245F8878005CB2F4 /* LK001UpdateFriendRequestStatusStorage.swift */; };
|
||||
241C6314231F64C000B4198E /* JazzIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 241C630E231F5AAC00B4198E /* JazzIcon.swift */; };
|
||||
241C6315231F64CE00B4198E /* CGFloat+Rounding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 241C6312231F5F1D00B4198E /* CGFloat+Rounding.swift */; };
|
||||
241C6316231F64CE00B4198E /* UIColor+Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 241C6310231F5C4400B4198E /* UIColor+Helper.swift */; };
|
||||
|
@ -744,7 +743,6 @@
|
|||
1C93CF3971B64E8B6C1F9AC1 /* Pods-SignalShareExtension.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SignalShareExtension.test.xcconfig"; path = "Pods/Target Support Files/Pods-SignalShareExtension/Pods-SignalShareExtension.test.xcconfig"; sourceTree = "<group>"; };
|
||||
1CE3CD5C23334683BDD3D78C /* Pods-Signal.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Signal.test.xcconfig"; path = "Pods/Target Support Files/Pods-Signal/Pods-Signal.test.xcconfig"; sourceTree = "<group>"; };
|
||||
2400888D239F30A600305217 /* SessionRestorationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionRestorationView.swift; sourceTree = "<group>"; };
|
||||
241C1191245F8878005CB2F4 /* LK001UpdateFriendRequestStatusStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LK001UpdateFriendRequestStatusStorage.swift; sourceTree = "<group>"; };
|
||||
241C630E231F5AAC00B4198E /* JazzIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JazzIcon.swift; sourceTree = "<group>"; };
|
||||
241C6310231F5C4400B4198E /* UIColor+Helper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Helper.swift"; sourceTree = "<group>"; };
|
||||
241C6312231F5F1D00B4198E /* CGFloat+Rounding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CGFloat+Rounding.swift"; sourceTree = "<group>"; };
|
||||
|
@ -1632,14 +1630,6 @@
|
|||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
241C1190245F8765005CB2F4 /* Migrations */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
241C1191245F8878005CB2F4 /* LK001UpdateFriendRequestStatusStorage.swift */,
|
||||
);
|
||||
path = Migrations;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
34074F54203D0722004596AE /* Sounds */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -2796,7 +2786,6 @@
|
|||
B846365922B7417900AF1514 /* Loki */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
241C1190245F8765005CB2F4 /* Migrations */,
|
||||
B8C9689223FA1B05005F64E0 /* Redesign */,
|
||||
B8544E3623D520F600299F14 /* Jazz Icon */,
|
||||
);
|
||||
|
@ -3989,7 +3978,6 @@
|
|||
349EA07C2162AEA800F7B17F /* OWS111UDAttributesMigration.swift in Sources */,
|
||||
34480B561FD0A7A400BC14EF /* DebugLogger.m in Sources */,
|
||||
459B775C207BA46C0071D0AB /* OWSQuotedReplyModel.m in Sources */,
|
||||
241C1192245F8878005CB2F4 /* LK001UpdateFriendRequestStatusStorage.swift in Sources */,
|
||||
340872D622397E6800CB25B0 /* AttachmentCaptionToolbar.swift in Sources */,
|
||||
34ABB2C42090C59700C727A6 /* OWSResaveCollectionDBMigration.m in Sources */,
|
||||
4C948FF72146EB4800349F0D /* BlockListCache.swift in Sources */,
|
||||
|
|
|
@ -713,9 +713,6 @@ static NSTimeInterval launchStartedAt;
|
|||
// Clean up any messages that expired since last launch immediately
|
||||
// and continue cleaning in the background.
|
||||
[self.disappearingMessagesJob startIfNecessary];
|
||||
|
||||
// Loki: Start friend request expiration job
|
||||
[self.lokiFriendRequestExpirationJob startIfNecessary];
|
||||
|
||||
[self enableBackgroundRefreshIfNecessary];
|
||||
|
||||
|
@ -1258,9 +1255,6 @@ static NSTimeInterval launchStartedAt;
|
|||
|
||||
// For non-legacy users, read receipts are on by default.
|
||||
[self.readReceiptManager setAreReadReceiptsEnabled:YES];
|
||||
|
||||
// Loki: Start friend request expiration job
|
||||
[self.lokiFriendRequestExpirationJob startIfNecessary];
|
||||
|
||||
// Loki: Start pollers
|
||||
[self startPollerIfNeeded];
|
||||
|
|
|
@ -196,9 +196,6 @@ final class DeviceLinkingModal : Modal, DeviceLinkingSessionDelegate {
|
|||
let _ = SSKEnvironment.shared.syncManager.syncAllContacts()
|
||||
}
|
||||
let _ = SSKEnvironment.shared.syncManager.syncAllOpenGroups()
|
||||
try! Storage.writeSync { transaction in
|
||||
storage.setFriendRequestStatus(.friends, for: slaveHexEncodedPublicKey, transaction: transaction)
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
self?.dismiss(animated: true, completion: nil)
|
||||
self?.delegate?.handleDeviceLinkAuthorized(signedDeviceLink)
|
||||
|
|
|
@ -161,7 +161,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol
|
|||
let storage = OWSPrimaryStorage.shared()
|
||||
storage.dbReadConnection.read { transaction in
|
||||
TSContactThread.enumerateCollectionObjects(with: transaction) { object, _ in
|
||||
guard let thread = object as? TSContactThread, thread.shouldThreadBeVisible && thread.isContactFriend else { return }
|
||||
guard let thread = object as? TSContactThread, thread.shouldThreadBeVisible else { return }
|
||||
let publicKey = thread.contactIdentifier()
|
||||
guard UserDisplayNameUtilities.getPrivateChatDisplayName(for: publicKey) != nil,
|
||||
storage.getMasterHexEncodedPublicKey(for: publicKey, in: transaction) == nil else { return }
|
||||
|
|
|
@ -8,7 +8,7 @@ final class NewClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelegat
|
|||
let storage = OWSPrimaryStorage.shared()
|
||||
storage.dbReadConnection.read { transaction in
|
||||
TSContactThread.enumerateCollectionObjects(with: transaction) { object, _ in
|
||||
guard let thread = object as? TSContactThread, thread.shouldThreadBeVisible && thread.isContactFriend else { return }
|
||||
guard let thread = object as? TSContactThread, thread.shouldThreadBeVisible else { return }
|
||||
let publicKey = thread.contactIdentifier()
|
||||
guard UserDisplayNameUtilities.getPrivateChatDisplayName(for: publicKey) != nil else { return }
|
||||
// We shouldn't be able to add slave devices to groups
|
||||
|
|
|
@ -94,7 +94,6 @@
|
|||
#import <SessionServiceKit/LKDeviceLinkMessage.h>
|
||||
#import <SessionServiceKit/OWSError.h>
|
||||
#import <SessionServiceKit/OWSFileSystem.h>
|
||||
#import <SessionServiceKit/LKFriendRequestMessage.h>
|
||||
#import <SessionServiceKit/OWSIdentityManager.h>
|
||||
#import <SessionServiceKit/OWSMediaGalleryFinder.h>
|
||||
#import <SessionServiceKit/OWSMessageManager.h>
|
||||
|
|
|
@ -22,7 +22,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@property (nonatomic) NSLayoutConstraint *messageBubbleViewBottomConstraint;
|
||||
@property (nonatomic) LKProfilePictureView *avatarView;
|
||||
@property (nonatomic) UIImageView *moderatorIconImageView;
|
||||
@property (nonatomic, nullable) LKFriendRequestView *friendRequestView;
|
||||
@property (nonatomic, nullable) UIImageView *sendFailureBadgeView;
|
||||
|
||||
@property (nonatomic, nullable) NSMutableArray<NSLayoutConstraint *> *viewConstraints;
|
||||
|
@ -212,24 +211,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
]];
|
||||
}
|
||||
}
|
||||
|
||||
// Loki: Attach the friend request view if needed
|
||||
if ([self shouldShowFriendRequestUIForMessage:self.message]) {
|
||||
self.friendRequestView = [[LKFriendRequestView alloc] initWithMessage:self.message];
|
||||
self.friendRequestView.delegate = self.friendRequestViewDelegate;
|
||||
[self.contentView addSubview:self.friendRequestView];
|
||||
[self.messageBubbleViewBottomConstraint setActive:NO];
|
||||
[self.viewConstraints addObjectsFromArray:@[
|
||||
[self.friendRequestView autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:self.conversationStyle.gutterLeading],
|
||||
[self.friendRequestView autoPinEdgeToSuperviewEdge:ALEdgeTrailing withInset:self.conversationStyle.gutterTrailing],
|
||||
[self.friendRequestView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.messageBubbleView],
|
||||
[self.friendRequestView autoPinEdgeToSuperviewEdge:ALEdgeBottom]
|
||||
]];
|
||||
} else {
|
||||
[self.friendRequestView removeFromSuperview];
|
||||
self.friendRequestView = nil;
|
||||
[self.messageBubbleViewBottomConstraint setActive:YES];
|
||||
}
|
||||
|
||||
if ([self updateAvatarView]) {
|
||||
[self.viewConstraints addObjectsFromArray:@[
|
||||
|
@ -384,11 +365,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
if (self.shouldHaveSendFailureBadge) {
|
||||
cellSize.width += self.sendFailureBadgeSize + self.sendFailureBadgeSpacing;
|
||||
}
|
||||
|
||||
// Loki: Include the friend request view if needed
|
||||
if ([self shouldShowFriendRequestUIForMessage:self.message]) {
|
||||
cellSize.height += [LKFriendRequestView calculateHeightWithMessage:self.message conversationStyle:self.conversationStyle];
|
||||
}
|
||||
|
||||
cellSize = CGSizeCeil(cellSize);
|
||||
|
||||
|
@ -408,9 +384,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[self.messageBubbleView unloadContent];
|
||||
|
||||
[self.headerView removeFromSuperview];
|
||||
|
||||
[self.friendRequestView removeFromSuperview];
|
||||
self.friendRequestView = nil;
|
||||
|
||||
[self.avatarView removeFromSuperview];
|
||||
|
||||
|
@ -469,10 +442,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
- (void)handleLongPressGesture:(UILongPressGestureRecognizer *)sender
|
||||
{
|
||||
OWSAssertDebug(self.delegate);
|
||||
|
||||
if ([self shouldShowFriendRequestUIForMessage:self.message]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender.state != UIGestureRecognizerStateBegan) {
|
||||
return;
|
||||
|
@ -532,13 +501,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return location.y <= headerBottom.y;
|
||||
}
|
||||
|
||||
#pragma mark - Convenience
|
||||
|
||||
- (BOOL)shouldShowFriendRequestUIForMessage:(TSMessage *)message
|
||||
{
|
||||
return message.isFriendRequest;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -124,7 +124,6 @@ typedef enum : NSUInteger {
|
|||
ConversationViewCellDelegate,
|
||||
ConversationInputTextViewDelegate,
|
||||
ConversationSearchControllerDelegate,
|
||||
LKFriendRequestViewDelegate,
|
||||
LongTextViewDelegate,
|
||||
MessageActionsDelegate,
|
||||
MessageDetailViewDelegate,
|
||||
|
@ -420,10 +419,6 @@ typedef enum : NSUInteger {
|
|||
selector:@selector(keyboardDidChangeFrame:)
|
||||
name:UIKeyboardDidChangeFrameNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(handleUserFriendRequestStatusChangedNotification:)
|
||||
name:NSNotification.userFriendRequestStatusChanged
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(handleThreadSessionRestoreDevicesChangedNotifiaction:)
|
||||
name:NSNotification.threadSessionRestoreDevicesChanged
|
||||
|
@ -533,28 +528,6 @@ typedef enum : NSUInteger {
|
|||
[self.collectionView reloadData];
|
||||
}
|
||||
|
||||
- (void)handleUserFriendRequestStatusChangedNotification:(NSNotification *)notification
|
||||
{
|
||||
OWSAssertIsOnMainThread();
|
||||
// Friend request status doesn't apply to group threads
|
||||
if (self.thread.isGroupThread) { return; }
|
||||
NSString *hexEncodedPublicKey = (NSString *)notification.object;
|
||||
// Check if we should update the UI
|
||||
__block NSSet<NSString *> *linkedDevices;
|
||||
[OWSPrimaryStorage.sharedManager.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
linkedDevices = [LKDatabaseUtilities getLinkedDeviceHexEncodedPublicKeysFor:self.thread.contactIdentifier in:transaction];
|
||||
}];
|
||||
if (![linkedDevices containsObject:hexEncodedPublicKey]) { return; }
|
||||
// Update the UI
|
||||
[self updateInputBar];
|
||||
[self.collectionView.collectionViewLayout invalidateLayout];
|
||||
for (id<ConversationViewItem> item in self.viewItems) {
|
||||
[item clearCachedLayoutState];
|
||||
}
|
||||
[self.conversationViewModel reloadViewItems];
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
|
||||
- (void)handleThreadSessionRestoreDevicesChangedNotifiaction:(NSNotification *)notification
|
||||
{
|
||||
// Check thread
|
||||
|
@ -791,7 +764,6 @@ typedef enum : NSUInteger {
|
|||
self.inputToolbar.inputToolbarDelegate = self;
|
||||
self.inputToolbar.inputTextViewDelegate = self;
|
||||
SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _inputToolbar);
|
||||
[self updateInputBar];
|
||||
|
||||
self.loadMoreHeader = [UILabel new];
|
||||
self.loadMoreHeader.text = NSLocalizedString(@"CONVERSATION_VIEW_LOADING_MORE_MESSAGES", @"Indicates that the app is loading more messages in this conversation.");
|
||||
|
@ -1676,17 +1648,6 @@ typedef enum : NSUInteger {
|
|||
self.navigationItem.rightBarButtonItems = [barButtons copy];
|
||||
}
|
||||
|
||||
#pragma mark - Updating
|
||||
|
||||
- (void)updateInputBar {
|
||||
BOOL shouldInputBarBeEnabled = [LKFriendRequestProtocol shouldInputBarBeEnabledForThread:self.thread];
|
||||
[self.inputToolbar setUserInteractionEnabled:shouldInputBarBeEnabled];
|
||||
NSString *placeholderText = shouldInputBarBeEnabled ? NSLocalizedString(@"Message", "") : NSLocalizedString(@"Pending session request", "");
|
||||
[self.inputToolbar setPlaceholderText:placeholderText];
|
||||
BOOL shouldAttachmentButtonBeEnabled = [LKFriendRequestProtocol shouldAttachmentButtonBeEnabledForThread:self.thread];
|
||||
[self.inputToolbar setAttachmentButtonHidden:!shouldAttachmentButtonBeEnabled];
|
||||
}
|
||||
|
||||
#pragma mark - Identity
|
||||
|
||||
/**
|
||||
|
@ -2895,15 +2856,6 @@ typedef enum : NSUInteger {
|
|||
AudioServicesPlaySystemSound(soundId);
|
||||
}
|
||||
[self.typingIndicators didSendOutgoingMessageInThread:self.thread];
|
||||
|
||||
// Loki: Lock the input bar early
|
||||
if ([self.thread isKindOfClass:TSContactThread.class] && [message isKindOfClass:LKFriendRequestMessage.class]) {
|
||||
NSString *recipientID = self.thread.contactIdentifier;
|
||||
OWSAssertIsOnMainThread();
|
||||
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[LKFriendRequestProtocol setFriendRequestStatusToSendingIfNeededForHexEncodedPublicKey:recipientID transaction:transaction];
|
||||
} error:nil];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark UIDocumentMenuDelegate
|
||||
|
@ -4497,24 +4449,6 @@ typedef enum : NSUInteger {
|
|||
animated:YES];
|
||||
}
|
||||
|
||||
#pragma mark - FriendRequestViewDelegate
|
||||
|
||||
- (void)acceptFriendRequest:(TSIncomingMessage *)friendRequest
|
||||
{
|
||||
if (self.thread.isGroupThread || self.thread.contactIdentifier == nil) { return; }
|
||||
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[LKFriendRequestProtocol acceptFriendRequestFromHexEncodedPublicKey:self.thread.contactIdentifier using:transaction];
|
||||
} error:nil];
|
||||
}
|
||||
|
||||
- (void)declineFriendRequest:(TSIncomingMessage *)friendRequest
|
||||
{
|
||||
if (self.thread.isGroupThread || self.thread.contactIdentifier == nil) { return; }
|
||||
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[LKFriendRequestProtocol declineFriendRequestFromHexEncodedPublicKey:self.thread.contactIdentifier using:transaction];
|
||||
} error:nil];
|
||||
}
|
||||
|
||||
#pragma mark - ConversationViewLayoutDelegate
|
||||
|
||||
- (NSArray<id<ConversationViewLayoutItem>> *)layoutItems
|
||||
|
@ -5107,7 +5041,6 @@ typedef enum : NSUInteger {
|
|||
}
|
||||
|
||||
[self dismissMenuActionsIfNecessary];
|
||||
[self updateInputBar];
|
||||
|
||||
if (self.isGroupConversation) {
|
||||
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
|
|
|
@ -413,12 +413,11 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
&& previousLayoutItem.interaction.interactionType == OWSInteractionType_IncomingMessage) {
|
||||
TSIncomingMessage *incomingMessage = (TSIncomingMessage *)self.interaction;
|
||||
TSIncomingMessage *previousIncomingMessage = (TSIncomingMessage *)previousLayoutItem.interaction;
|
||||
if ([incomingMessage.authorId isEqualToString:previousIncomingMessage.authorId] && !previousIncomingMessage.isFriendRequest) {
|
||||
if ([incomingMessage.authorId isEqualToString:previousIncomingMessage.authorId]) {
|
||||
return 2.f;
|
||||
}
|
||||
} else if (self.interaction.interactionType == OWSInteractionType_OutgoingMessage
|
||||
&& previousLayoutItem.interaction.interactionType == OWSInteractionType_OutgoingMessage
|
||||
&& !((TSOutgoingMessage *)previousLayoutItem.interaction).hasFriendRequestStatusMessage) {
|
||||
&& previousLayoutItem.interaction.interactionType == OWSInteractionType_OutgoingMessage) {
|
||||
return 2.f;
|
||||
}
|
||||
|
||||
|
|
|
@ -534,17 +534,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
name = [self.contactsManager attributedContactOrProfileNameForPhoneIdentifier:thread.contactIdentifier
|
||||
primaryFont:self.nameFont
|
||||
secondaryFont:self.nameSecondaryFont];
|
||||
BOOL hasCheckmark = self.thread.threadRecord.isContactFriend;
|
||||
if (hasCheckmark) {
|
||||
NSMutableAttributedString *checkmark = [[NSMutableAttributedString alloc] initWithString:@"✓"];
|
||||
[checkmark beginEditing];
|
||||
[checkmark addAttribute:NSForegroundColorAttributeName value:UIColor.lokiGreen range:NSMakeRange(0, 1)];
|
||||
[checkmark endEditing];
|
||||
NSMutableAttributedString *mutableName = [name mutableCopy];
|
||||
[mutableName appendAttributedString:[[NSAttributedString alloc] initWithString:@" "]];
|
||||
[mutableName appendAttributedString:checkmark];
|
||||
name = [mutableName copy];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
import Foundation
|
||||
import SessionServiceKit
|
||||
|
||||
@objc
|
||||
public class LK001UpdateFriendRequestStatusStorage : OWSDatabaseMigration {
|
||||
|
||||
// MARK: -
|
||||
|
||||
// Increment a similar constant for each migration.
|
||||
// 100-114 are reserved for Signal migrations
|
||||
@objc
|
||||
class func migrationId() -> String {
|
||||
return "001"
|
||||
}
|
||||
|
||||
override public func runUp(completion: @escaping OWSDatabaseMigrationCompletion) {
|
||||
self.doMigrationAsync(completion: completion)
|
||||
}
|
||||
|
||||
private func doMigrationAsync(completion: @escaping OWSDatabaseMigrationCompletion) {
|
||||
DispatchQueue.global().async {
|
||||
try! Storage.writeSync { transaction in
|
||||
var threads: [TSContactThread] = []
|
||||
TSContactThread.enumerateCollectionObjects(with: transaction) { object, _ in
|
||||
guard let thread = object as? TSContactThread else { return }
|
||||
threads.append(thread)
|
||||
}
|
||||
threads.forEach { thread in
|
||||
guard let friendRequestStatus = LKFriendRequestStatus(rawValue: thread.friendRequestStatus) else { return }
|
||||
OWSPrimaryStorage.shared().setFriendRequestStatus(friendRequestStatus, for: thread.contactIdentifier(), transaction: transaction)
|
||||
}
|
||||
self.save(with: transaction)
|
||||
}
|
||||
completion()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -200,7 +200,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
TSThread *thread = [[transaction extension:TSThreadDatabaseViewExtensionName]
|
||||
objectAtIndexPath:[NSIndexPath indexPathForItem:(NSInteger)item inSection:(NSInteger)section]
|
||||
withMappings:self.threadMappings];
|
||||
if (!thread.shouldThreadBeVisible || !thread.isContactFriend) { continue; }
|
||||
if (!thread.shouldThreadBeVisible) { continue; }
|
||||
if ([thread isKindOfClass:TSContactThread.class]) {
|
||||
NSString *publicKey = thread.contactIdentifier;
|
||||
if ([LKUserDisplayNameUtilities getPrivateChatDisplayNameFor:publicKey] == nil) { continue; }
|
||||
|
|
|
@ -125,10 +125,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
syncManager:syncManager
|
||||
typingIndicators:typingIndicators
|
||||
attachmentDownloads:attachmentDownloads]];
|
||||
|
||||
// Loki
|
||||
LKFriendRequestExpirationJob *lokiFriendRequestExpirationJob = [[LKFriendRequestExpirationJob alloc] initWithPrimaryStorage:primaryStorage];
|
||||
SSKEnvironment.shared.lokiFriendRequestExpirationJob = lokiFriendRequestExpirationJob;
|
||||
|
||||
appSpecificSingletonBlock();
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[[OWS112TypingIndicatorsMigration alloc] init],
|
||||
[[OWS113MultiAttachmentMediaMessages alloc] init],
|
||||
[[OWS114RemoveDynamicInteractions alloc] init],
|
||||
[[LK001UpdateFriendRequestStatusStorage alloc] init]
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -934,8 +934,6 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
|
|||
TSGroupThread *groupThread = (TSGroupThread *)thread;
|
||||
NSData *groupId = groupThread.groupModel.groupId;
|
||||
return [self isGroupIdInProfileWhitelist:groupId];
|
||||
} else if ([LKFriendRequestProtocol isFriendsWithAnyLinkedDeviceOfHexEncodedPublicKey:thread.contactIdentifier]) {
|
||||
return true;
|
||||
} else {
|
||||
NSString *recipientId = thread.contactIdentifier;
|
||||
return [self isUserInProfileWhitelist:recipientId];
|
||||
|
|
|
@ -181,13 +181,8 @@ typedef void (^BuildOutgoingMessageCompletionBlock)(TSOutgoingMessage *savedMess
|
|||
|
||||
BOOL isVoiceMessage = (attachments.count == 1 && attachments.lastObject.isVoiceMessage);
|
||||
|
||||
// Loki: If we're not friends then always set the message to a friend request message.
|
||||
// If we're friends then the assumption is that we have the other user's pre key bundle.
|
||||
NSString *messageClassAsString = (thread.isContactFriend || thread.isGroupThread) ? @"TSOutgoingMessage" : @"LKFriendRequestMessage";
|
||||
Class messageClass = NSClassFromString(messageClassAsString);
|
||||
|
||||
TSOutgoingMessage *message =
|
||||
[[messageClass alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
[[TSOutgoingMessage alloc] initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
inThread:thread
|
||||
messageBody:truncatedText
|
||||
attachmentIds:[NSMutableArray new]
|
||||
|
|
|
@ -38,11 +38,6 @@ extern ConversationColorName const kConversationColorName_Default;
|
|||
@property (nonatomic, readonly) NSDate *creationDate;
|
||||
@property (nonatomic, readonly) BOOL isArchivedByLegacyTimestampForSorting;
|
||||
@property (nonatomic, readonly) TSInteraction *lastInteraction;
|
||||
// Loki friend request handling
|
||||
// ========
|
||||
@property (nonatomic) NSInteger friendRequestStatus __deprecated_msg("use OWSPrimaryStorage.getFriendRequestStatusForContact:transaction: instead");
|
||||
@property (nonatomic, readonly) BOOL isContactFriend;
|
||||
// ========
|
||||
@property (nonatomic, readonly) BOOL isSlaveThread;
|
||||
|
||||
/**
|
||||
|
|
|
@ -708,13 +708,6 @@ ConversationColorName const kConversationColorName_Default = ConversationColorNa
|
|||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Loki Friend Request Handling
|
||||
|
||||
- (BOOL)isContactFriend
|
||||
{
|
||||
return [LKFriendRequestProtocol getFriendRequestUIStatusForThread:self] == LKFriendRequestUIStatusFriends;
|
||||
}
|
||||
|
||||
- (BOOL)isSlaveThread
|
||||
{
|
||||
return [LKMultiDeviceProtocol isSlaveThread:self];
|
||||
|
|
|
@ -190,7 +190,7 @@ public final class ClosedGroupsProtocol : NSObject {
|
|||
|
||||
public static func requestSenderKey(for groupPublicKey: String, senderPublicKey: String, using transaction: YapDatabaseReadWriteTransaction) {
|
||||
// Establish session if needed
|
||||
SessionManagementProtocol.establishSessionIfNeeded(with: senderPublicKey, using: transaction)
|
||||
SessionManagementProtocol.sendSessionRequestIfNeeded(to: senderPublicKey, using: transaction)
|
||||
// Send the request
|
||||
let thread = TSContactThread.getOrCreateThread(withContactId: senderPublicKey, transaction: transaction)
|
||||
thread.save(with: transaction)
|
||||
|
@ -329,7 +329,7 @@ public final class ClosedGroupsProtocol : NSObject {
|
|||
return print("[Loki] Ignoring closed group sender key request from non-member.")
|
||||
}
|
||||
// Respond to the request
|
||||
SessionManagementProtocol.establishSessionIfNeeded(with: senderPublicKey, using: transaction) // This internally takes care of multi device
|
||||
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))
|
||||
let thread = TSContactThread.getOrCreateThread(withContactId: senderPublicKey, transaction: transaction)
|
||||
|
@ -370,7 +370,7 @@ public final class ClosedGroupsProtocol : NSObject {
|
|||
@objc(establishSessionsIfNeededWithClosedGroupMembers:transaction:)
|
||||
public static func establishSessionsIfNeeded(with closedGroupMembers: [String], using transaction: YapDatabaseReadWriteTransaction) {
|
||||
closedGroupMembers.forEach { publicKey in
|
||||
SessionManagementProtocol.establishSessionIfNeeded(with: publicKey, using: transaction)
|
||||
SessionManagementProtocol.sendSessionRequestIfNeeded(to: publicKey, using: transaction)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,23 +78,13 @@ public final class SessionMetaProtocol : NSObject {
|
|||
/// to avoid sending them if certain conditions are met.
|
||||
@objc(shouldSendTypingIndicatorInThread:)
|
||||
public static func shouldSendTypingIndicator(in thread: TSThread) -> Bool {
|
||||
guard !thread.isGroupThread(), let publicKey = thread.contactIdentifier() else { return false }
|
||||
var isContactFriend = false
|
||||
storage.dbReadConnection.read { transaction in
|
||||
isContactFriend = (storage.getFriendRequestStatus(for: publicKey, transaction: transaction) == .friends)
|
||||
}
|
||||
return isContactFriend
|
||||
return !thread.isGroupThread()
|
||||
}
|
||||
|
||||
// MARK: Receipts
|
||||
@objc(shouldSendReceiptInThread:)
|
||||
public static func shouldSendReceipt(in thread: TSThread) -> Bool {
|
||||
guard !thread.isGroupThread(), let publicKey = thread.contactIdentifier() else { return false }
|
||||
var isContactFriend = false
|
||||
storage.dbReadConnection.read { transaction in
|
||||
isContactFriend = (storage.getFriendRequestStatus(for: publicKey, transaction: transaction) == .friends)
|
||||
}
|
||||
return isContactFriend
|
||||
return !thread.isGroupThread()
|
||||
}
|
||||
|
||||
// MARK: - Receiving
|
||||
|
|
|
@ -60,7 +60,8 @@ public final class SessionManagementProtocol : NSObject {
|
|||
|
||||
// MARK: - Sending
|
||||
|
||||
@objc public static func shouldUseFallbackEncryption(for message: TSOutgoingMessage) -> Bool {
|
||||
@objc(shouldUseFallbackEncryptionForMessage:)
|
||||
public static func shouldUseFallbackEncryption(for message: TSOutgoingMessage) -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -77,10 +78,10 @@ public final class SessionManagementProtocol : NSObject {
|
|||
let hasSession = storage.containsSession(publicKey, deviceId: Int32(OWSDevicePrimaryDeviceId), protocolContext: transaction)
|
||||
guard !hasSession else { return }
|
||||
// Check that we didn't already send a session request
|
||||
let hasSentRequest = (Storage.getSessionRequestSentTimestamp(for: publicKey) > 0)
|
||||
let hasSentSessionRequestExpired = hasSentSessionRequestExpired(for: publicKey)
|
||||
let hasSentSessionRequest = (Storage.getSessionRequestSentTimestamp(for: publicKey) > 0)
|
||||
let hasSentSessionRequestExpired = SessionManagementProtocol.hasSentSessionRequestExpired(for: publicKey)
|
||||
if hasSentSessionRequestExpired {
|
||||
Storage.setSessionRequestSentTimestamp(for: publicKey, to: 0)
|
||||
Storage.setSessionRequestSentTimestamp(for: publicKey, to: 0, using: transaction)
|
||||
}
|
||||
guard !hasSentSessionRequest || hasSentSessionRequestExpired else { return }
|
||||
// Create the thread if needed
|
||||
|
@ -88,12 +89,12 @@ public final class SessionManagementProtocol : NSObject {
|
|||
thread.save(with: transaction)
|
||||
// Send the session request
|
||||
print("[Loki] Sending session request to: \(publicKey).")
|
||||
Storage.setSessionRequestSentTimestamp(for: publicKey, to: Date(), using: transaction)
|
||||
Storage.setSessionRequestSentTimestamp(for: publicKey, to: NSDate.ows_millisecondTimeStamp(), using: transaction)
|
||||
let sessionRequestMessage = SessionRequestMessage(thread: thread)
|
||||
let messageSenderJobQueue = SSKEnvironment.shared.messageSenderJobQueue
|
||||
messageSenderJobQueue.add(message: sessionRequestMessage, transaction: transaction)
|
||||
|
||||
aushfiuasfhiujoasf
|
||||
// aushfiuasfhiujoasf
|
||||
// TODO: Handle failure
|
||||
}
|
||||
|
||||
|
@ -181,7 +182,7 @@ public final class SessionManagementProtocol : NSObject {
|
|||
return print("[Loki] Ignoring session request from: \(publicKey).")
|
||||
}
|
||||
storage.setPreKeyBundle(preKeyBundle, forContact: publicKey, transaction: transaction)
|
||||
Storage.setSessionRequestSentTimestamp(for: publicKey, to: Date(), using: transaction)
|
||||
Storage.setSessionRequestProcessedTimestamp(for: publicKey, to: NSDate.ows_millisecondTimeStamp(), using: transaction)
|
||||
sendNullMessage(to: publicKey, in: transaction)
|
||||
}
|
||||
|
||||
|
|
|
@ -49,19 +49,23 @@ public final class SyncMessagesProtocol : NSObject {
|
|||
return syncManager.syncContacts(for: [ SignalAccount(recipientId: publicKey) ])
|
||||
}
|
||||
|
||||
private static func getContactsToSync(using transaction: YapDatabaseReadTransaction) -> Set<String> {
|
||||
return Set(TSContactThread.allObjectsInCollection().compactMap { $0 as? TSContactThread }
|
||||
.filter { $0.shouldThreadBeVisible }
|
||||
.map { $0.contactIdentifier() }
|
||||
.filter { ECKeyPair.isValidHexEncodedPublicKey(candidate: $0) }
|
||||
.filter { storage.getMasterHexEncodedPublicKey(for: $0, in: transaction) == nil } // Exclude secondary devices
|
||||
.filter { !LokiDatabaseUtilities.isUserLinkedDevice($0, transaction: transaction) })
|
||||
}
|
||||
|
||||
@objc public static func syncAllContacts() -> AnyPromise {
|
||||
// We need to sync over all contacts whom we are friends with, even if
|
||||
// we don't have a thread for them.
|
||||
var publicKeys: [String] = []
|
||||
storage.dbReadConnection.read { transaction in
|
||||
publicKeys = self.storage
|
||||
.getAllFriends(using: transaction)
|
||||
.filter { ECKeyPair.isValidHexEncodedPublicKey(candidate: $0) }
|
||||
.map { storage.getMasterHexEncodedPublicKey(for: $0, in: transaction) ?? $0 }
|
||||
publicKeys = [String](getContactsToSync(using: transaction))
|
||||
}
|
||||
let friends = Set(publicKeys).map { SignalAccount(recipientId: $0) }
|
||||
let accounts = Set(publicKeys).map { SignalAccount(recipientId: $0) }
|
||||
let syncManager = SSKEnvironment.shared.syncManager
|
||||
let promises = friends.chunked(by: 3).map { friends -> Promise<Void> in // TODO: Does this always fit?
|
||||
let promises = accounts.chunked(by: 3).map { friends -> Promise<Void> in // TODO: Does this always fit?
|
||||
return Promise(syncManager.syncContacts(for: friends)).map2 { _ in }
|
||||
}
|
||||
return AnyPromise.from(when(fulfilled: promises))
|
||||
|
|
|
@ -38,12 +38,6 @@ typedef NS_ENUM(NSInteger, LKMessageFriendRequestStatus) {
|
|||
@property (nonatomic, readonly, nullable) TSQuotedMessage *quotedMessage;
|
||||
@property (nonatomic, readonly, nullable) OWSContact *contactShare;
|
||||
@property (nonatomic, nullable) OWSLinkPreview *linkPreview;
|
||||
// Loki friend request handling
|
||||
@property (nonatomic) LKMessageFriendRequestStatus friendRequestStatus __deprecated_msg("no longer used as of version 1.1.2");
|
||||
/// Only relevant to outgoing messages.
|
||||
@property (nonatomic) uint64_t friendRequestExpiresAt;
|
||||
@property (nonatomic, readonly) BOOL isFriendRequest;
|
||||
@property (nonatomic, readonly) BOOL hasFriendRequestStatusMessage;
|
||||
@property BOOL skipSave;
|
||||
// P2P
|
||||
@property (nonatomic) BOOL isP2P;
|
||||
|
|
|
@ -82,8 +82,6 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
|
|||
_quotedMessage = quotedMessage;
|
||||
_contactShare = contactShare;
|
||||
_linkPreview = linkPreview;
|
||||
_friendRequestStatus = LKMessageFriendRequestStatusNone;
|
||||
_friendRequestExpiresAt = 0;
|
||||
_openGroupServerMessageID = -1;
|
||||
|
||||
return self;
|
||||
|
@ -446,31 +444,6 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
|
|||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Loki Friend Request Handling
|
||||
|
||||
- (void)saveFriendRequestExpiresAt:(u_int64_t)expiresAt withTransaction:(YapDatabaseReadWriteTransaction *_Nullable)transaction
|
||||
{
|
||||
self.friendRequestExpiresAt = expiresAt;
|
||||
if (transaction == nil) {
|
||||
[self save];
|
||||
} else {
|
||||
[self saveWithTransaction:transaction];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isFriendRequest
|
||||
{
|
||||
if (![self.thread isKindOfClass:TSContactThread.class] || self.thread.isContactFriend) { return NO; }
|
||||
return [self.uniqueId isEqual:self.thread.lastInteraction.uniqueId];
|
||||
}
|
||||
|
||||
- (BOOL)hasFriendRequestStatusMessage
|
||||
{
|
||||
LKFriendRequestUIStatus friendRequestStatus = [LKFriendRequestProtocol getFriendRequestUIStatusForThread:self.thread];
|
||||
if (friendRequestStatus == LKFriendRequestUIStatusNone || friendRequestStatus == LKFriendRequestUIStatusFriends) { return NO; };
|
||||
return [self.uniqueId isEqual:self.thread.lastInteraction.uniqueId];
|
||||
}
|
||||
|
||||
#pragma mark - Open Groups
|
||||
|
||||
- (BOOL)isOpenGroupMessage {
|
||||
|
|
|
@ -1096,22 +1096,18 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
|
|||
|
||||
[ProtoUtils addLocalProfileKeyIfNecessary:self.thread recipientId:recipientId dataMessageBuilder:builder];
|
||||
|
||||
// Loki: Set display name & profile picture (exclude the profile picture if this is a friend request
|
||||
// to prevent unsolicited content from being sent)
|
||||
id<ProfileManagerProtocol> profileManager = SSKEnvironment.shared.profileManager;
|
||||
NSString *displayName;
|
||||
NSString *masterHexEncodedPublicKey = [NSUserDefaults.standardUserDefaults stringForKey:@"masterDeviceHexEncodedPublicKey"];
|
||||
if (masterHexEncodedPublicKey != nil) {
|
||||
displayName = [profileManager profileNameForRecipientWithID:masterHexEncodedPublicKey];
|
||||
NSString *masterPublicKey = [NSUserDefaults.standardUserDefaults stringForKey:@"masterDeviceHexEncodedPublicKey"];
|
||||
if (masterPublicKey != nil) {
|
||||
displayName = [profileManager profileNameForRecipientWithID:masterPublicKey];
|
||||
} else {
|
||||
displayName = profileManager.localProfileName;
|
||||
}
|
||||
NSString *profilePictureURL = profileManager.profilePictureURL;
|
||||
SSKProtoDataMessageLokiProfileBuilder *profileBuilder = [SSKProtoDataMessageLokiProfile builder];
|
||||
[profileBuilder setDisplayName:displayName];
|
||||
if (![self isKindOfClass:LKFriendRequestMessage.class]) {
|
||||
[profileBuilder setProfilePicture:profilePictureURL ?: @""];
|
||||
}
|
||||
[profileBuilder setProfilePicture:profilePictureURL ?: @""];
|
||||
SSKProtoDataMessageLokiProfile *profile = [profileBuilder buildAndReturnError:nil];
|
||||
[builder setProfile:profile];
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
|
|||
}
|
||||
|
||||
_primaryStorage = primaryStorage;
|
||||
_sessionResetImplementation = [[LKSessionResetImplementation alloc] initWithStorage:primaryStorage];
|
||||
_sessionResetImplementation = [LKSessionResetImplementation new];
|
||||
_dbConnection = primaryStorage.newDatabaseConnection;
|
||||
|
||||
OWSSingletonAssert();
|
||||
|
|
|
@ -271,7 +271,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[self checkForUnknownLinkedDevice:envelope transaction:transaction];
|
||||
|
||||
switch (envelope.type) {
|
||||
case SSKProtoEnvelopeTypeFallbackMessage:
|
||||
case SSKProtoEnvelopeTypeFriendRequest:
|
||||
case SSKProtoEnvelopeTypeCiphertext:
|
||||
case SSKProtoEnvelopeTypePrekeyBundle:
|
||||
case SSKProtoEnvelopeTypeClosedGroupCiphertext:
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#import "DataSource.h"
|
||||
#import "TSContactThread.h"
|
||||
#import "LKFriendRequestMessage.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -45,8 +45,6 @@
|
|||
#import "TSSocketManager.h"
|
||||
#import "TSThread.h"
|
||||
#import "TSContactThread.h"
|
||||
#import "LKFriendRequestMessage.h"
|
||||
#import "LKSessionRestoreMessage.h"
|
||||
#import "LKDeviceLinkMessage.h"
|
||||
#import "LKUnlinkDeviceMessage.h"
|
||||
#import <SessionAxolotlKit/AxolotlExceptions.h>
|
||||
|
@ -1571,7 +1569,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
|||
}
|
||||
|
||||
OWSMessageServiceParams *messageParams =
|
||||
[[OWSMessageServiceParams alloc] initWithType:TSFriendRequestMessageType
|
||||
[[OWSMessageServiceParams alloc] initWithType:TSFallbackMessageType
|
||||
recipientId:recipientId
|
||||
device:[deviceId intValue]
|
||||
content:serializedMessage
|
||||
|
@ -1616,7 +1614,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
|||
TSWhisperMessageType messageType;
|
||||
if (messageSend.isUDSend) {
|
||||
NSError *error;
|
||||
LKSessionResetImplementation *sessionResetImplementation = [[LKSessionResetImplementation alloc] initWithStorage:self.primaryStorage];
|
||||
LKSessionResetImplementation *sessionResetImplementation = [LKSessionResetImplementation new];
|
||||
|
||||
SMKSecretSessionCipher *_Nullable secretCipher =
|
||||
[[SMKSecretSessionCipher alloc] initWithSessionResetImplementation:sessionResetImplementation
|
||||
|
|
|
@ -216,7 +216,6 @@ void VerifyRegistrationsForPrimaryStorage(OWSStorage *storage)
|
|||
[SSKJobRecordFinder asyncRegisterDatabaseExtensionObjCWithStorage:self];
|
||||
|
||||
// Loki
|
||||
[LKExpiringFriendRequestFinder asyncRegisterDatabaseExtensions:self];
|
||||
[LKDeviceLinkIndex asyncRegisterDatabaseExtensions:self];
|
||||
|
||||
[self.database
|
||||
|
|
Loading…
Reference in New Issue