Create DeviceLinkingMessage
This commit is contained in:
parent
395d167f56
commit
0bb6721768
|
@ -576,7 +576,7 @@
|
||||||
B891105C2320872800F15FCC /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B891105B2320872800F15FCC /* GoogleService-Info.plist */; };
|
B891105C2320872800F15FCC /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B891105B2320872800F15FCC /* GoogleService-Info.plist */; };
|
||||||
B891105E2320872800F15FCC /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B891105B2320872800F15FCC /* GoogleService-Info.plist */; };
|
B891105E2320872800F15FCC /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B891105B2320872800F15FCC /* GoogleService-Info.plist */; };
|
||||||
B891105F2320872800F15FCC /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B891105B2320872800F15FCC /* GoogleService-Info.plist */; };
|
B891105F2320872800F15FCC /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B891105B2320872800F15FCC /* GoogleService-Info.plist */; };
|
||||||
B89841E322B7579F00B1BDC6 /* NewConversationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B89841E222B7579F00B1BDC6 /* NewConversationViewController.swift */; };
|
B89841E322B7579F00B1BDC6 /* NewConversationVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B89841E222B7579F00B1BDC6 /* NewConversationVC.swift */; };
|
||||||
B90418E6183E9DD40038554A /* DateUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = B90418E5183E9DD40038554A /* DateUtil.m */; };
|
B90418E6183E9DD40038554A /* DateUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = B90418E5183E9DD40038554A /* DateUtil.m */; };
|
||||||
B9EB5ABD1884C002007CBB57 /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9EB5ABC1884C002007CBB57 /* MessageUI.framework */; };
|
B9EB5ABD1884C002007CBB57 /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9EB5ABC1884C002007CBB57 /* MessageUI.framework */; };
|
||||||
BFF3FB9730634F37D25903F4 /* Pods_Signal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D17BB5C25D615AB49813100C /* Pods_Signal.framework */; };
|
BFF3FB9730634F37D25903F4 /* Pods_Signal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D17BB5C25D615AB49813100C /* Pods_Signal.framework */; };
|
||||||
|
@ -1382,7 +1382,7 @@
|
||||||
B885D5F3233491AB00EE0D8E /* DeviceLinkingModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceLinkingModal.swift; sourceTree = "<group>"; };
|
B885D5F3233491AB00EE0D8E /* DeviceLinkingModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceLinkingModal.swift; sourceTree = "<group>"; };
|
||||||
B885D5F52334A32100EE0D8E /* UIView+Constraint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Constraint.swift"; sourceTree = "<group>"; };
|
B885D5F52334A32100EE0D8E /* UIView+Constraint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Constraint.swift"; sourceTree = "<group>"; };
|
||||||
B891105B2320872800F15FCC /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
|
B891105B2320872800F15FCC /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
|
||||||
B89841E222B7579F00B1BDC6 /* NewConversationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewConversationViewController.swift; sourceTree = "<group>"; };
|
B89841E222B7579F00B1BDC6 /* NewConversationVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewConversationVC.swift; sourceTree = "<group>"; };
|
||||||
B90418E4183E9DD40038554A /* DateUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DateUtil.h; sourceTree = "<group>"; };
|
B90418E4183E9DD40038554A /* DateUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DateUtil.h; sourceTree = "<group>"; };
|
||||||
B90418E5183E9DD40038554A /* DateUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DateUtil.m; sourceTree = "<group>"; };
|
B90418E5183E9DD40038554A /* DateUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DateUtil.m; sourceTree = "<group>"; };
|
||||||
B97940251832BD2400BD66CB /* UIUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIUtil.h; sourceTree = "<group>"; };
|
B97940251832BD2400BD66CB /* UIUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIUtil.h; sourceTree = "<group>"; };
|
||||||
|
@ -2646,7 +2646,7 @@
|
||||||
B8162F0222891AD600D46544 /* FriendRequestView.swift */,
|
B8162F0222891AD600D46544 /* FriendRequestView.swift */,
|
||||||
B8162F0422892C5F00D46544 /* FriendRequestViewDelegate.swift */,
|
B8162F0422892C5F00D46544 /* FriendRequestViewDelegate.swift */,
|
||||||
24A830A12293CD0100F4CAC0 /* LokiP2PServer.swift */,
|
24A830A12293CD0100F4CAC0 /* LokiP2PServer.swift */,
|
||||||
B89841E222B7579F00B1BDC6 /* NewConversationViewController.swift */,
|
B89841E222B7579F00B1BDC6 /* NewConversationVC.swift */,
|
||||||
B8258491230FA5DA001B41CB /* ScanQRCodeViewController.h */,
|
B8258491230FA5DA001B41CB /* ScanQRCodeViewController.h */,
|
||||||
B8258492230FA5E9001B41CB /* ScanQRCodeViewController.m */,
|
B8258492230FA5E9001B41CB /* ScanQRCodeViewController.m */,
|
||||||
);
|
);
|
||||||
|
@ -3859,7 +3859,7 @@
|
||||||
45AE48511E0732D6004D96C2 /* TurnServerInfo.swift in Sources */,
|
45AE48511E0732D6004D96C2 /* TurnServerInfo.swift in Sources */,
|
||||||
34B3F8771E8DF1700035BE1A /* ContactsPicker.swift in Sources */,
|
34B3F8771E8DF1700035BE1A /* ContactsPicker.swift in Sources */,
|
||||||
45C0DC1B1E68FE9000E04C47 /* UIApplication+OWS.swift in Sources */,
|
45C0DC1B1E68FE9000E04C47 /* UIApplication+OWS.swift in Sources */,
|
||||||
B89841E322B7579F00B1BDC6 /* NewConversationViewController.swift in Sources */,
|
B89841E322B7579F00B1BDC6 /* NewConversationVC.swift in Sources */,
|
||||||
45FBC5C81DF8575700E9B410 /* CallKitCallManager.swift in Sources */,
|
45FBC5C81DF8575700E9B410 /* CallKitCallManager.swift in Sources */,
|
||||||
4539B5861F79348F007141FF /* PushRegistrationManager.swift in Sources */,
|
4539B5861F79348F007141FF /* PushRegistrationManager.swift in Sources */,
|
||||||
45FBC5D11DF8592E00E9B410 /* SignalCall.swift in Sources */,
|
45FBC5D11DF8592E00E9B410 /* SignalCall.swift in Sources */,
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
buildForAnalyzing = "YES">
|
buildForAnalyzing = "YES">
|
||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "BF1AA1A1F4180E0BF6CA9FD699844BF7"
|
BlueprintIdentifier = "51E5126436E74C817013DE9DE3C88131"
|
||||||
BuildableName = "SignalServiceKit.framework"
|
BuildableName = "SignalServiceKit.framework"
|
||||||
BlueprintName = "SignalServiceKit"
|
BlueprintName = "SignalServiceKit"
|
||||||
ReferencedContainer = "container:Pods/Pods.xcodeproj">
|
ReferencedContainer = "container:Pods/Pods.xcodeproj">
|
||||||
|
@ -41,6 +41,22 @@
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
shouldUseLaunchSchemeArgsEnv = "NO">
|
shouldUseLaunchSchemeArgsEnv = "NO">
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "D221A088169C9E5E00537ABF"
|
||||||
|
BuildableName = "Loki Messenger.app"
|
||||||
|
BlueprintName = "Signal"
|
||||||
|
ReferencedContainer = "container:Signal.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
<EnvironmentVariables>
|
||||||
|
<EnvironmentVariable
|
||||||
|
key = "runningTests_dontStartApp"
|
||||||
|
value = "YES"
|
||||||
|
isEnabled = "YES">
|
||||||
|
</EnvironmentVariable>
|
||||||
|
</EnvironmentVariables>
|
||||||
<Testables>
|
<Testables>
|
||||||
<TestableReference
|
<TestableReference
|
||||||
skipped = "NO">
|
skipped = "NO">
|
||||||
|
@ -113,24 +129,6 @@
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</TestableReference>
|
</TestableReference>
|
||||||
</Testables>
|
</Testables>
|
||||||
<MacroExpansion>
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "D221A088169C9E5E00537ABF"
|
|
||||||
BuildableName = "Loki Messenger.app"
|
|
||||||
BlueprintName = "Signal"
|
|
||||||
ReferencedContainer = "container:Signal.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</MacroExpansion>
|
|
||||||
<EnvironmentVariables>
|
|
||||||
<EnvironmentVariable
|
|
||||||
key = "runningTests_dontStartApp"
|
|
||||||
value = "YES"
|
|
||||||
isEnabled = "YES">
|
|
||||||
</EnvironmentVariable>
|
|
||||||
</EnvironmentVariables>
|
|
||||||
<AdditionalOptions>
|
|
||||||
</AdditionalOptions>
|
|
||||||
</TestAction>
|
</TestAction>
|
||||||
<LaunchAction
|
<LaunchAction
|
||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
|
@ -144,6 +142,7 @@
|
||||||
debugDocumentVersioning = "YES"
|
debugDocumentVersioning = "YES"
|
||||||
stopOnEveryThreadSanitizerIssue = "YES"
|
stopOnEveryThreadSanitizerIssue = "YES"
|
||||||
stopOnEveryUBSanitizerIssue = "YES"
|
stopOnEveryUBSanitizerIssue = "YES"
|
||||||
|
migratedStopOnEveryIssue = "YES"
|
||||||
debugServiceExtension = "internal"
|
debugServiceExtension = "internal"
|
||||||
allowLocationSimulation = "YES"
|
allowLocationSimulation = "YES"
|
||||||
showNonLocalizedStrings = "YES">
|
showNonLocalizedStrings = "YES">
|
||||||
|
@ -179,8 +178,6 @@
|
||||||
isEnabled = "YES">
|
isEnabled = "YES">
|
||||||
</EnvironmentVariable>
|
</EnvironmentVariable>
|
||||||
</EnvironmentVariables>
|
</EnvironmentVariables>
|
||||||
<AdditionalOptions>
|
|
||||||
</AdditionalOptions>
|
|
||||||
</LaunchAction>
|
</LaunchAction>
|
||||||
<ProfileAction
|
<ProfileAction
|
||||||
buildConfiguration = "App Store Release"
|
buildConfiguration = "App Store Release"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
@objc(LKNewConversationViewController)
|
@objc(LKNewConversationVC)
|
||||||
final class NewConversationViewController : OWSViewController, OWSQRScannerDelegate {
|
final class NewConversationVC : OWSViewController, OWSQRScannerDelegate {
|
||||||
|
|
||||||
// MARK: Components
|
// MARK: Components
|
||||||
private lazy var publicKeyTextField: UITextField = {
|
private lazy var publicKeyTextField: UITextField = {
|
|
@ -315,8 +315,8 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate {
|
||||||
}
|
}
|
||||||
case .link:
|
case .link:
|
||||||
seed = self.seed
|
seed = self.seed
|
||||||
let hexEncodedPublicKey = masterHexEncodedPublicKeyTextField.text!.trimmingCharacters(in: CharacterSet.whitespaces)
|
let masterHexEncodedPublicKey = masterHexEncodedPublicKeyTextField.text!.trimmingCharacters(in: CharacterSet.whitespaces)
|
||||||
if !ECKeyPair.isValidHexEncodedPublicKey(candidate: hexEncodedPublicKey) {
|
if !ECKeyPair.isValidHexEncodedPublicKey(candidate: masterHexEncodedPublicKey) {
|
||||||
errorLabel2Spacer.isHidden = false
|
errorLabel2Spacer.isHidden = false
|
||||||
return errorLabel2.text = NSLocalizedString("Invalid public key", comment: "")
|
return errorLabel2.text = NSLocalizedString("Invalid public key", comment: "")
|
||||||
}
|
}
|
||||||
|
@ -337,15 +337,18 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate {
|
||||||
case .link: Analytics.shared.track("Device Linked")
|
case .link: Analytics.shared.track("Device Linked")
|
||||||
}
|
}
|
||||||
if mode == .link {
|
if mode == .link {
|
||||||
|
let masterHexEncodedPublicKey = masterHexEncodedPublicKeyTextField.text!.trimmingCharacters(in: CharacterSet.whitespaces)
|
||||||
let deviceLinkingModal = DeviceLinkingModal(mode: .slave, delegate: self)
|
let deviceLinkingModal = DeviceLinkingModal(mode: .slave, delegate: self)
|
||||||
deviceLinkingModal.modalPresentationStyle = .overFullScreen
|
deviceLinkingModal.modalPresentationStyle = .overFullScreen
|
||||||
present(deviceLinkingModal, animated: true, completion: nil)
|
present(deviceLinkingModal, animated: true, completion: nil)
|
||||||
|
let thread = TSContactThread.getOrCreateThread(contactId: masterHexEncodedPublicKey)
|
||||||
|
ThreadUtil.enqueueDeviceLinkingMessage(in: thread)
|
||||||
} else {
|
} else {
|
||||||
onboardingController.pushDisplayNameVC(from: self)
|
onboardingController.pushDisplayNameVC(from: self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleDeviceLinked() {
|
func handleDeviceLinkingRequestAuthorized() {
|
||||||
TSAccountManager.sharedInstance().didRegister()
|
TSAccountManager.sharedInstance().didRegister()
|
||||||
UserDefaults.standard.set(true, forKey: "didUpdateForMainnet")
|
UserDefaults.standard.set(true, forKey: "didUpdateForMainnet")
|
||||||
onboardingController.verificationDidComplete(fromView: self)
|
onboardingController.verificationDidComplete(fromView: self)
|
||||||
|
|
|
@ -122,8 +122,8 @@ final class DeviceLinkingModal : Modal, DeviceLinkingSessionDelegate {
|
||||||
@objc private func authorizeDeviceLink() {
|
@objc private func authorizeDeviceLink() {
|
||||||
let deviceLink = self.deviceLink!
|
let deviceLink = self.deviceLink!
|
||||||
let session = DeviceLinkingSession.current!
|
let session = DeviceLinkingSession.current!
|
||||||
session.authorizeDeviceLink(deviceLink)
|
|
||||||
session.stopListeningForLinkingRequests()
|
session.stopListeningForLinkingRequests()
|
||||||
|
// TODO: Send device link authorized message
|
||||||
dismiss(animated: true, completion: nil)
|
dismiss(animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
@objc(LKDeviceLinkingModalDelegate)
|
@objc(LKDeviceLinkingModalDelegate)
|
||||||
protocol DeviceLinkingModalDelegate {
|
protocol DeviceLinkingModalDelegate {
|
||||||
|
|
||||||
func handleDeviceLinked()
|
/// Provides an opportunity for the slave device to update its UI after the master device has authorized the device linking request.
|
||||||
|
func handleDeviceLinkingRequestAuthorized()
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,7 @@
|
||||||
#import <SignalServiceKit/OWSDispatch.h>
|
#import <SignalServiceKit/OWSDispatch.h>
|
||||||
#import <SignalServiceKit/OWSEndSessionMessage.h>
|
#import <SignalServiceKit/OWSEndSessionMessage.h>
|
||||||
#import <SignalServiceKit/LKEphemeralMessage.h>
|
#import <SignalServiceKit/LKEphemeralMessage.h>
|
||||||
|
#import <SignalServiceKit/LKDeviceLinkingMessage.h>
|
||||||
#import <SignalServiceKit/OWSError.h>
|
#import <SignalServiceKit/OWSError.h>
|
||||||
#import <SignalServiceKit/OWSFileSystem.h>
|
#import <SignalServiceKit/OWSFileSystem.h>
|
||||||
#import <SignalServiceKit/LKFriendRequestMessage.h>
|
#import <SignalServiceKit/LKFriendRequestMessage.h>
|
||||||
|
|
|
@ -4348,7 +4348,7 @@ typedef enum : NSUInteger {
|
||||||
// Update the thread's friend request status
|
// Update the thread's friend request status
|
||||||
[self.thread saveFriendRequestStatus:LKThreadFriendRequestStatusFriends withTransaction:nil];
|
[self.thread saveFriendRequestStatus:LKThreadFriendRequestStatusFriends withTransaction:nil];
|
||||||
// Send a friend request accepted message
|
// Send a friend request accepted message
|
||||||
[ThreadUtil enqueueAcceptFriendRequestMessageInThread:self.thread];
|
[ThreadUtil enqueueFriendRequestAcceptanceMessageInThread:self.thread];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)declineFriendRequest:(TSIncomingMessage *)friendRequest
|
- (void)declineFriendRequest:(TSIncomingMessage *)friendRequest
|
||||||
|
|
|
@ -835,8 +835,8 @@ typedef NS_ENUM(NSInteger, HomeViewControllerSection) {
|
||||||
|
|
||||||
- (void)showNewConversationView
|
- (void)showNewConversationView
|
||||||
{
|
{
|
||||||
LKNewConversationViewController *viewController = [LKNewConversationViewController new];
|
LKNewConversationVC *newConversationVC = [LKNewConversationVC new];
|
||||||
OWSNavigationController *navigationController = [[OWSNavigationController alloc] initWithRootViewController:viewController];
|
OWSNavigationController *navigationController = [[OWSNavigationController alloc] initWithRootViewController:newConversationVC];
|
||||||
[self.navigationController presentViewController:navigationController animated:YES completion:nil];
|
[self.navigationController presentViewController:navigationController animated:YES completion:nil];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
import PromiseKit
|
import PromiseKit
|
||||||
|
import Contacts
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
public class OnboardingPermissionsViewController: OnboardingBaseViewController {
|
public class OnboardingPermissionsViewController: OnboardingBaseViewController {
|
||||||
|
|
|
@ -44,7 +44,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
#pragma mark - Durable Message Enqueue
|
#pragma mark - Durable Message Enqueue
|
||||||
|
|
||||||
+ (TSOutgoingMessage *)enqueueAcceptFriendRequestMessageInThread:(TSThread *)thread;
|
+ (TSOutgoingMessage *)enqueueFriendRequestAcceptanceMessageInThread:(TSThread *)thread;
|
||||||
|
+ (TSOutgoingMessage *)enqueueDeviceLinkingMessageInThread:(TSThread *)thread;
|
||||||
|
|
||||||
+ (TSOutgoingMessage *)enqueueMessageWithText:(NSString *)fullMessageText
|
+ (TSOutgoingMessage *)enqueueMessageWithText:(NSString *)fullMessageText
|
||||||
inThread:(TSThread *)thread
|
inThread:(TSThread *)thread
|
||||||
|
|
|
@ -85,13 +85,22 @@ typedef void (^BuildOutgoingMessageCompletionBlock)(TSOutgoingMessage *savedMess
|
||||||
|
|
||||||
#pragma mark - Durable Message Enqueue
|
#pragma mark - Durable Message Enqueue
|
||||||
|
|
||||||
+ (LKEphemeralMessage *)enqueueAcceptFriendRequestMessageInThread:(TSThread *)thread
|
+ (LKEphemeralMessage *)enqueueFriendRequestAcceptanceMessageInThread:(TSThread *)thread
|
||||||
{
|
{
|
||||||
LKEphemeralMessage *emptyMessage = [[LKEphemeralMessage alloc] initInThread:thread];
|
LKEphemeralMessage *message = [[LKEphemeralMessage alloc] initInThread:thread];
|
||||||
[self.dbConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
[self.dbConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||||
[self.messageSenderJobQueue addMessage:emptyMessage transaction:transaction];
|
[self.messageSenderJobQueue addMessage:message transaction:transaction];
|
||||||
}];
|
}];
|
||||||
return emptyMessage;
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (LKDeviceLinkingMessage *)enqueueDeviceLinkingMessageInThread:(TSThread *)thread
|
||||||
|
{
|
||||||
|
LKDeviceLinkingMessage *message = [[LKDeviceLinkingMessage alloc] initInThread:thread];
|
||||||
|
[self.dbConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||||
|
[self.messageSenderJobQueue addMessage:message transaction:transaction];
|
||||||
|
}];
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (TSOutgoingMessage *)enqueueMessageWithText:(NSString *)fullMessageText
|
+ (TSOutgoingMessage *)enqueueMessageWithText:(NSString *)fullMessageText
|
||||||
|
|
|
@ -36,10 +36,6 @@ public final class DeviceLinkingSession : NSObject {
|
||||||
isListeningForLinkingRequests = false
|
isListeningForLinkingRequests = false
|
||||||
}
|
}
|
||||||
|
|
||||||
public func authorizeDeviceLink(_ deviceLink: DeviceLink) {
|
|
||||||
// TODO: Send a device link authorized message
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: Private API
|
// MARK: Private API
|
||||||
private func isValidLinkingRequest(_ deviceLink: DeviceLink) -> Bool {
|
private func isValidLinkingRequest(_ deviceLink: DeviceLink) -> Bool {
|
||||||
// When requesting a device link, the slave device signs the master device's public key. When authorizing
|
// When requesting a device link, the slave device signs the master device's public key. When authorizing
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
#import "TSOutgoingMessage.h"
|
||||||
|
|
||||||
|
NS_SWIFT_NAME(DeviceLinkingMessage)
|
||||||
|
@interface LKDeviceLinkingMessage : TSOutgoingMessage
|
||||||
|
|
||||||
|
- (instancetype)initInThread:(TSThread *)thread;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,40 @@
|
||||||
|
#import "LKDeviceLinkingMessage.h"
|
||||||
|
#import "OWSIdentityManager.h"
|
||||||
|
#import "SignalRecipient.h"
|
||||||
|
#import <SignalCoreKit/NSData+OWS.h>
|
||||||
|
#import <SignalCoreKit/NSDate+OWS.h>
|
||||||
|
#import <SignalServiceKit/SignalServiceKit-Swift.h>
|
||||||
|
|
||||||
|
@implementation LKDeviceLinkingMessage
|
||||||
|
|
||||||
|
- (instancetype)initInThread:(nullable TSThread *)thread {
|
||||||
|
return [self initOutgoingMessageWithTimestamp:NSDate.ows_millisecondTimeStamp inThread:thread messageBody:@"" attachmentIds:[NSMutableArray<NSString *> new]
|
||||||
|
expiresInSeconds:0 expireStartedAt:0 isVoiceMessage:NO groupMetaMessage:TSGroupMetaMessageUnspecified quotedMessage:nil contactShare:nil linkPreview:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (SSKProtoContentBuilder *)contentBuilder:(SignalRecipient *)recipient {
|
||||||
|
SSKProtoContentBuilder *contentBuilder = [super contentBuilder:recipient];
|
||||||
|
// When authorizing a device link, the master device signs the slave device's public key. When requesting
|
||||||
|
// a device link, the slave device signs the master device's public key.
|
||||||
|
SSKProtoLokiDeviceLinkingMessageBuilder *deviceLinkingMessageBuilder = [SSKProtoLokiDeviceLinkingMessage builder];
|
||||||
|
NSString *masterHexEncodedPublicKey = recipient.recipientId;
|
||||||
|
NSData *masterPublicKey = [NSData dataFromHexString:masterHexEncodedPublicKey];
|
||||||
|
[deviceLinkingMessageBuilder setMasterHexEncodedPublicKey:masterHexEncodedPublicKey];
|
||||||
|
ECKeyPair *slaveKeyPair = OWSIdentityManager.sharedManager.identityKeyPair;
|
||||||
|
NSString *slaveHexEncodedPublicKey = slaveKeyPair.hexEncodedPublicKey;
|
||||||
|
[deviceLinkingMessageBuilder setSlaveHexEncodedPublicKey:slaveHexEncodedPublicKey];
|
||||||
|
NSData *slaveSignature = [Ed25519 sign:masterPublicKey withKeyPair:slaveKeyPair error:nil];
|
||||||
|
[deviceLinkingMessageBuilder setSlaveSignature:slaveSignature];
|
||||||
|
NSError *error;
|
||||||
|
SSKProtoLokiDeviceLinkingMessage *deviceLinkingMessage = [deviceLinkingMessageBuilder buildAndReturnError:&error];
|
||||||
|
if (error || deviceLinkingMessage == nil) {
|
||||||
|
OWSFailDebug(@"Failed to build device linking message for: %@ due to error: %@", masterHexEncodedPublicKey, error);
|
||||||
|
}
|
||||||
|
[contentBuilder setLokiDeviceLinkingMessage:deviceLinkingMessage];
|
||||||
|
return contentBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)shouldSyncTranscript { return NO; }
|
||||||
|
- (BOOL)shouldBeSaved { return NO; }
|
||||||
|
|
||||||
|
@end
|
|
@ -1103,12 +1103,12 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
|
||||||
|
|
||||||
[ProtoUtils addLocalProfileKeyIfNecessary:self.thread recipientId:recipientId dataMessageBuilder:builder];
|
[ProtoUtils addLocalProfileKeyIfNecessary:self.thread recipientId:recipientId dataMessageBuilder:builder];
|
||||||
|
|
||||||
|
// Loki: Set display name if needed
|
||||||
id<ProfileManagerProtocol> profileManager = SSKEnvironment.shared.profileManager;
|
id<ProfileManagerProtocol> profileManager = SSKEnvironment.shared.profileManager;
|
||||||
NSString *displayName = profileManager.localProfileName;
|
NSString *displayName = profileManager.localProfileName;
|
||||||
if (displayName != nil) {
|
if (displayName != nil) {
|
||||||
SSKProtoDataMessageLokiProfileBuilder *profileBuilder = [SSKProtoDataMessageLokiProfile builder];
|
SSKProtoDataMessageLokiProfileBuilder *profileBuilder = [SSKProtoDataMessageLokiProfile builder];
|
||||||
[profileBuilder setDisplayName:displayName];
|
[profileBuilder setDisplayName:displayName];
|
||||||
|
|
||||||
SSKProtoDataMessageLokiProfile *profile = [profileBuilder buildAndReturnError:nil];
|
SSKProtoDataMessageLokiProfile *profile = [profileBuilder buildAndReturnError:nil];
|
||||||
[builder setProfile:profile];
|
[builder setProfile:profile];
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#import "OWSDisappearingMessagesConfiguration.h"
|
#import "OWSDisappearingMessagesConfiguration.h"
|
||||||
#import "OWSDisappearingMessagesJob.h"
|
#import "OWSDisappearingMessagesJob.h"
|
||||||
#import "LKEphemeralMessage.h"
|
#import "LKEphemeralMessage.h"
|
||||||
|
#import "LKDeviceLinkingMessage.h"
|
||||||
#import "OWSIdentityManager.h"
|
#import "OWSIdentityManager.h"
|
||||||
#import "OWSIncomingMessageFinder.h"
|
#import "OWSIncomingMessageFinder.h"
|
||||||
#import "OWSIncomingSentMessageTranscript.h"
|
#import "OWSIncomingSentMessageTranscript.h"
|
||||||
|
@ -1546,7 +1547,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
if (existingFriendRequestMessage != nil && existingFriendRequestMessage.isFriendRequest) {
|
if (existingFriendRequestMessage != nil && existingFriendRequestMessage.isFriendRequest) {
|
||||||
[existingFriendRequestMessage saveFriendRequestStatus:LKMessageFriendRequestStatusAccepted withTransaction:transaction];
|
[existingFriendRequestMessage saveFriendRequestStatus:LKMessageFriendRequestStatusAccepted withTransaction:transaction];
|
||||||
}
|
}
|
||||||
// The two lines below are equivalent to calling [ThreadUtil enqueueAcceptFriendRequestMessageInThread:thread]
|
// The two lines below are equivalent to calling [ThreadUtil enqueueFriendRequestAcceptanceMessageInThread:thread]
|
||||||
LKEphemeralMessage *backgroundMessage = [[LKEphemeralMessage alloc] initInThread:thread];
|
LKEphemeralMessage *backgroundMessage = [[LKEphemeralMessage alloc] initInThread:thread];
|
||||||
[self.messageSenderJobQueue addMessage:backgroundMessage transaction:transaction];
|
[self.messageSenderJobQueue addMessage:backgroundMessage transaction:transaction];
|
||||||
} else if (!thread.isContactFriend) {
|
} else if (!thread.isContactFriend) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
//
|
//
|
||||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||||
//
|
//
|
||||||
|
import Contacts
|
||||||
|
|
||||||
@objc(OWSFakeContactsManager)
|
@objc(OWSFakeContactsManager)
|
||||||
public class FakeContactsManager: NSObject, ContactsManagerProtocol {
|
public class FakeContactsManager: NSObject, ContactsManagerProtocol {
|
||||||
|
|
Loading…
Reference in New Issue