SDK Bump to 1.0.80 and push notifications filtering (#1131)

* filtering nil notifications

* updated the sdk
This commit is contained in:
Mauro 2023-06-22 13:24:37 +02:00 committed by GitHub
parent 8b11a0a5ec
commit 8e8bb7a3e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 23 additions and 13 deletions

View File

@ -5004,7 +5004,7 @@
repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift";
requirement = {
kind = exactVersion;
version = "1.0.79-alpha";
version = "1.0.80-alpha";
};
};
96495DD8554E2F39D3954354 /* XCRemoteSwiftPackageReference "posthog-ios" */ = {

View File

@ -111,8 +111,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/matrix-org/matrix-rust-components-swift",
"state" : {
"revision" : "59c10bfd0b2dee9b5bf41b536ffac472d4fc49db",
"version" : "1.0.79-alpha"
"revision" : "d34b870ed9e954b446a8f6db6afa7fa9d8f6c06a",
"version" : "1.0.80-alpha"
}
},
{
@ -181,7 +181,7 @@
{
"identity" : "swift-snapshot-testing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing.git",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"state" : {
"revision" : "cef5b3f6f11781dd4591bdd1dd0a3d22bd609334",
"version" : "1.11.0"

View File

@ -249,10 +249,10 @@ class SDKClientMock: SDKClientProtocol {
}
public var getNotificationItemRoomIdEventIdReceivedArguments: (`roomId`: String, `eventId`: String)?
public var getNotificationItemRoomIdEventIdReceivedInvocations: [(`roomId`: String, `eventId`: String)] = []
public var getNotificationItemRoomIdEventIdReturnValue: NotificationItem!
public var getNotificationItemRoomIdEventIdClosure: ((String, String) throws -> NotificationItem)?
public var getNotificationItemRoomIdEventIdReturnValue: NotificationItem?
public var getNotificationItemRoomIdEventIdClosure: ((String, String) throws -> NotificationItem?)?
public func `getNotificationItem`(`roomId`: String, `eventId`: String) throws -> NotificationItem {
public func `getNotificationItem`(`roomId`: String, `eventId`: String) throws -> NotificationItem? {
if let error = getNotificationItemRoomIdEventIdThrowableError {
throw error
}

View File

@ -72,7 +72,10 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
do {
let userSession = try NSEUserSession(credentials: credentials)
let itemProxy = try await userSession.notificationItemProxy(roomID: roomId, eventID: eventId)
guard let itemProxy = try await userSession.notificationItemProxy(roomID: roomId, eventID: eventId) else {
MXLog.info("\(tag) no notification for this event")
return discard()
}
// After the first processing, update the modified content
modifiedContent = try await itemProxy.process(mediaProvider: nil)

View File

@ -32,11 +32,13 @@ final class NSEUserSession {
try client.restoreSession(session: credentials.restorationToken.session)
}
func notificationItemProxy(roomID: String, eventID: String) async throws -> NotificationItemProxyProtocol {
func notificationItemProxy(roomID: String, eventID: String) async throws -> NotificationItemProxyProtocol? {
let userID = try client.userId()
return await Task.dispatch(on: .global()) {
do {
let notification = try self.client.getNotificationItem(roomId: roomID, eventId: eventID)
guard let notification = try self.client.getNotificationItem(roomId: roomID, eventId: eventID) else {
return nil
}
return NotificationItemProxy(notificationItem: notification, receiverID: userID)
} catch {
MXLog.error("NSE: Could not get notification's content creating an empty notification instead, error: \(error)")

View File

@ -15,6 +15,8 @@
//
@testable import ElementX
import Combine
import Foundation
import XCTest
@ -39,7 +41,8 @@ class BugReportServiceTests: XCTestCase {
includeCrashLog: true,
githubLabels: [],
files: [])
let response = try await bugReportService.submitBugReport(bugReport, progressListener: nil).get()
let progressSubject = CurrentValueSubject<Double, Never>(0.0)
let response = try await bugReportService.submitBugReport(bugReport, progressListener: progressSubject).get()
XCTAssertFalse(response.reportUrl.isEmpty)
}
@ -64,7 +67,8 @@ class BugReportServiceTests: XCTestCase {
includeCrashLog: true,
githubLabels: [],
files: [])
let response = try await service.submitBugReport(bugReport, progressListener: nil).get()
let progressSubject = CurrentValueSubject<Double, Never>(0.0)
let response = try await service.submitBugReport(bugReport, progressListener: progressSubject).get()
XCTAssertEqual(response.reportUrl, "https://example.com/123")
}

1
changelog.d/1114.feature Normal file
View File

@ -0,0 +1 @@
Filtering out push notifications for encrypted rooms based on the room push context.

View File

@ -44,7 +44,7 @@ include:
packages:
MatrixRustSDK:
url: https://github.com/matrix-org/matrix-rust-components-swift
exactVersion: 1.0.79-alpha
exactVersion: 1.0.80-alpha
# path: ../matrix-rust-sdk
DesignKit:
path: DesignKit