Fixed the broken legacy group push notifications & CI tweaks

Fixed the broken legacy group push notifications
Reset and close the simulators before/after the tests are run on the CI
pull/941/head
Morgan Pretty 1 year ago
parent 37d3d5b829
commit 3bb11aeac1

@ -81,6 +81,13 @@ local update_cocoapods_cache = {
clone_submodules,
load_cocoapods_cache,
install_cocoapods,
{
name: 'Reset Simulators',
commands: [
'xcrun simctl shutdown all',
'xcrun simctl erase all'
],
},
{
name: 'Run Unit Tests',
commands: [
@ -88,6 +95,10 @@ local update_cocoapods_cache = {
'NSUnbufferedIO=YES set -o pipefail && xcodebuild test -workspace Session.xcworkspace -scheme Session -derivedDataPath ./build/derivedData -destination "platform=iOS Simulator,name=iPhone 14" -destination "platform=iOS Simulator,name=iPhone 14 Pro Max" -parallel-testing-enabled YES -test-timeouts-enabled YES -maximum-test-execution-time-allowance 2 -collect-test-diagnostics never 2>&1 | ./Pods/xcbeautify/xcbeautify --is-ci --report junit --report-path ./build/reports --junit-report-filename junit2.xml'
],
},
{
name: 'Sutdown Simulators',
commands: [ 'xcrun simctl shutdown all' ],
},
update_cocoapods_cache
],
},

@ -1 +1 @@
Subproject commit aa6d67b3f48d0ddb98fcf678e9aab0803ba388af
Subproject commit 73c22f2ce5ca0b8fb8b94a2eb6acf0bea8084b2f

@ -359,7 +359,7 @@ public extension Message {
_ db: Database,
rawMessage: SnodeReceivedMessage,
publicKey: String,
using dependencies: Dependencies = Dependencies()
using dependencies: Dependencies
) throws -> ProcessedMessage {
do {
let processedMessage: ProcessedMessage = try processRawReceivedMessage(
@ -423,7 +423,7 @@ public extension Message {
_ db: Database,
data: Data,
metadata: PushNotificationAPI.NotificationMetadata,
using dependencies: Dependencies = Dependencies()
using dependencies: Dependencies
) throws -> ProcessedMessage? {
let processedMessage: ProcessedMessage? = try processRawReceivedMessage(
db,
@ -475,7 +475,7 @@ public extension Message {
data: Data,
isOutgoing: Bool,
otherBlindedPublicKey: String,
using dependencies: Dependencies = Dependencies()
using dependencies: Dependencies
) throws -> ProcessedMessage? {
return try processRawReceivedMessage(
db,
@ -496,7 +496,7 @@ public extension Message {
openGroupId: String,
message: OpenGroupAPI.Message,
associatedPendingChanges: [OpenGroupAPI.PendingChange],
using dependencies: Dependencies = Dependencies()
using dependencies: Dependencies
) -> [Reaction] {
guard let reactions: [String: OpenGroupAPI.Message.Reaction] = message.reactions else { return [] }

@ -14,7 +14,7 @@ public enum MessageReceiver {
_ db: Database,
data: Data,
origin: Message.Origin,
using dependencies: Dependencies = Dependencies()
using dependencies: Dependencies
) throws -> ProcessedMessage {
let userSessionId: SessionId = getUserSessionId(db, using: dependencies)
var plaintext: Data

@ -41,19 +41,9 @@ extension PushNotificationAPI {
}
}
// MARK: - Decodable
extension PushNotificationAPI.NotificationMetadata {
static var invalid: PushNotificationAPI.NotificationMetadata {
PushNotificationAPI.NotificationMetadata(
accountId: "",
hash: "",
namespace: .unknown,
createdTimestampMs: 0,
expirationTimestampMs: 0,
dataLength: 0,
dataTooLong: false
)
}
public init(from decoder: Decoder) throws {
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
@ -72,3 +62,33 @@ extension PushNotificationAPI.NotificationMetadata {
)
}
}
// MARK: - Convenience
extension PushNotificationAPI.NotificationMetadata {
static var invalid: PushNotificationAPI.NotificationMetadata {
PushNotificationAPI.NotificationMetadata(
accountId: "",
hash: "",
namespace: .unknown,
createdTimestampMs: 0,
expirationTimestampMs: 0,
dataLength: 0,
dataTooLong: false
)
}
static func legacyGroupMessage(envelope: SNProtoEnvelope) throws -> PushNotificationAPI.NotificationMetadata {
guard let publicKey: String = envelope.source else { throw MessageReceiverError.invalidMessage }
return PushNotificationAPI.NotificationMetadata(
accountId: publicKey,
hash: "",
namespace: .legacyClosedGroup,
createdTimestampMs: 0,
expirationTimestampMs: 0,
dataLength: 0,
dataTooLong: false
)
}
}

@ -458,10 +458,11 @@ public enum PushNotificationAPI {
// We only support legacy notifications for legacy group conversations
guard
let envelope: SNProtoEnvelope = try? MessageWrapper.unwrap(data: data),
envelope.type == .closedGroupMessage
envelope.type == .closedGroupMessage,
let metadata: NotificationMetadata = try? .legacyGroupMessage(envelope: envelope)
else { return (data, .invalid, .legacyForceSilent) }
return (data, .invalid, .legacySuccess)
return (data, metadata, .legacySuccess)
}
guard let base64EncodedEncString: String = notificationContent.userInfo["enc_payload"] as? String else {

@ -277,7 +277,8 @@ public class Poller: PollerType {
return try Message.processRawReceivedMessage(
db,
rawMessage: message,
publicKey: publicKey
publicKey: publicKey,
using: dependencies
)
}
catch {

@ -17,10 +17,10 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
private var request: UNNotificationRequest?
private var openGroupPollCancellable: AnyCancellable?
public static let isFromRemoteKey = "remote"
public static let threadIdKey = "Signal.AppNotificationsUserInfoKey.threadId"
public static let threadVariantRaw = "Signal.AppNotificationsUserInfoKey.threadVariantRaw"
public static let threadNotificationCounter = "Session.AppNotificationsUserInfoKey.threadNotificationCounter"
public static let isFromRemoteKey = "remote" // stringlint:disable
public static let threadIdKey = "Signal.AppNotificationsUserInfoKey.threadId" // stringlint:disable
public static let threadVariantRaw = "Signal.AppNotificationsUserInfoKey.threadVariantRaw" // stringlint:disable
public static let threadNotificationCounter = "Session.AppNotificationsUserInfoKey.threadNotificationCounter" // stringlint:disable
private static let callPreOfferLargeNotificationSupressionDuration: TimeInterval = 30
// MARK: Did receive a remote push notification request
@ -103,7 +103,7 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
// is added to notification center
dependencies[singleton: .storage].write { db in
do {
guard let processedMessage: ProcessedMessage = try Message.processRawReceivedMessageAsNotification(db, data: data, metadata: metadata) else {
guard let processedMessage: ProcessedMessage = try Message.processRawReceivedMessageAsNotification(db, data: data, metadata: metadata, using: dependencies) else {
self.handleFailure(for: notificationContent, error: .messageProcessing)
return
}

Loading…
Cancel
Save