skip saving the session record if it is not in the main app
This commit is contained in:
parent
bf84df2b6d
commit
c8108575a7
|
@ -5,6 +5,7 @@ import SignalMessaging
|
|||
class NotificationService: UNNotificationServiceExtension {
|
||||
|
||||
static let threadIdKey = "Signal.AppNotificationsUserInfoKey.threadId"
|
||||
static let isFromRemoteKey = "remote"
|
||||
var areVersionMigrationsComplete = false
|
||||
var contentHandler: ((UNNotificationContent) -> Void)?
|
||||
var notificationContent: UNMutableNotificationContent?
|
||||
|
@ -25,8 +26,7 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
if (envelope != nil && envelopeData != nil) {
|
||||
decrypter.decryptEnvelope(envelope!, envelopeData: envelopeData!,
|
||||
successBlock: { result,transaction in
|
||||
if let envelope = try? SSKProtoEnvelope.parseData(result.envelopeData) {
|
||||
self.removeDecryptionChain(envelope: envelope, transaction: transaction)
|
||||
if (try? SSKProtoEnvelope.parseData(result.envelopeData)) != nil {
|
||||
self.handelDecryptionResult(result: result, notificationContent: notificationContent, transaction: transaction)
|
||||
} else {
|
||||
self.completeWithFailure(content: notificationContent)
|
||||
|
@ -41,11 +41,6 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
}
|
||||
}
|
||||
|
||||
func removeDecryptionChain(envelope: SSKProtoEnvelope, transaction: YapDatabaseReadWriteTransaction) {
|
||||
let sessionRecord = SSKEnvironment.shared.primaryStorage.loadSession(envelope.source!, deviceId: Int32(envelope.sourceDevice), protocolContext: transaction)
|
||||
let sessionState = sessionRecord.sessionState()
|
||||
}
|
||||
|
||||
func handelDecryptionResult(result: OWSMessageDecryptResult, notificationContent: UNMutableNotificationContent, transaction: YapDatabaseReadWriteTransaction) {
|
||||
let contentProto = try? SSKProtoContent.parseData(result.plaintextData!)
|
||||
var thread: TSThread
|
||||
|
@ -84,9 +79,11 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
thread = TSContactThread.getOrCreateThread(withContactId: result.source, transaction: transaction)
|
||||
displayName = contentProto?.dataMessage?.profile?.displayName ?? displayName
|
||||
}
|
||||
let userInfo: [String: Any] = [NotificationService.threadIdKey: thread.uniqueId!]
|
||||
let userInfo: [String: Any] = [NotificationService.threadIdKey: thread.uniqueId!,
|
||||
NotificationService.isFromRemoteKey: true]
|
||||
notificationContent.title = displayName
|
||||
notificationContent.userInfo = userInfo
|
||||
notificationContent.badge = 1
|
||||
if newNotificationBody.count < 1 {
|
||||
newNotificationBody = contentProto?.dataMessage?.body ?? ""
|
||||
}
|
||||
|
@ -205,6 +202,8 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
func completeWithFailure(content: UNMutableNotificationContent) {
|
||||
content.body = "You've got a new message."
|
||||
content.title = "Session"
|
||||
let userInfo: [String: Any] = [NotificationService.isFromRemoteKey: true]
|
||||
content.userInfo = userInfo
|
||||
contentHandler?(content)
|
||||
}
|
||||
|
||||
|
|
2
Pods
2
Pods
|
@ -1 +1 @@
|
|||
Subproject commit 7d2822b86d1ff3bf09eb6cab2f01a03e7e214081
|
||||
Subproject commit fede6eca060a60c0232bf7f1328462a27728d823
|
|
@ -4817,6 +4817,7 @@
|
|||
"-fobjc-arc-exceptions",
|
||||
"-Werror=protocol",
|
||||
);
|
||||
"OTHER_SWIFT_FLAGS[arch=*]" = "-D DEBUG";
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_VERSION = 4.0;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1140"
|
||||
wasCreatedForAppExtension = "YES"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7BC01A3A241F40AB00BC7C55"
|
||||
BuildableName = "LokiPushNotificationService.appex"
|
||||
BlueprintName = "LokiPushNotificationService"
|
||||
ReferencedContainer = "container:Signal.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D221A088169C9E5E00537ABF"
|
||||
BuildableName = "Session.app"
|
||||
BlueprintName = "Signal"
|
||||
ReferencedContainer = "container:Signal.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = ""
|
||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D221A088169C9E5E00537ABF"
|
||||
BuildableName = "Session.app"
|
||||
BlueprintName = "Signal"
|
||||
ReferencedContainer = "container:Signal.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "App Store Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
launchAutomaticallySubstyle = "2">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D221A088169C9E5E00537ABF"
|
||||
BuildableName = "Session.app"
|
||||
BlueprintName = "Signal"
|
||||
ReferencedContainer = "container:Signal.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "App Store Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
|
@ -4,5 +4,7 @@
|
|||
<dict>
|
||||
<key>BuildSystemType</key>
|
||||
<string>Original</string>
|
||||
<key>PreviewsEnabled</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -353,6 +353,7 @@ public class SystemContactsFetcher: NSObject {
|
|||
guard let contacts = fetchedContacts else {
|
||||
owsFailDebug("contacts was unexpectedly not set.")
|
||||
completion(nil)
|
||||
return
|
||||
}
|
||||
|
||||
Logger.info("fetched \(contacts.count) contacts.")
|
||||
|
|
|
@ -104,11 +104,6 @@ public class TypingIndicatorMessage: TSOutgoingMessage {
|
|||
public override func shouldBeSaved() -> Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@objc
|
||||
public override var ttl: UInt32 {
|
||||
return UInt32(5 * kMinuteInMs)
|
||||
}
|
||||
|
||||
@objc
|
||||
public override var debugDescription: String {
|
||||
|
|
|
@ -88,6 +88,9 @@ NSString *const kSessionStoreDBConnectionKey = @"kSessionStoreDBConnectionKey";
|
|||
OWSAssertDebug(contactIdentifier.length > 0);
|
||||
OWSAssertDebug(deviceId >= 0);
|
||||
OWSAssertDebug([protocolContext isKindOfClass:[YapDatabaseReadWriteTransaction class]]);
|
||||
if (!CurrentAppContext().isMainApp) {
|
||||
return;
|
||||
}
|
||||
|
||||
YapDatabaseReadWriteTransaction *transaction = protocolContext;
|
||||
|
||||
|
|
Loading…
Reference in New Issue