-
Notifications
You must be signed in to change notification settings - Fork 19
feat: adapt Websocket for consumable notifications - WPB-17225 #2918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
netbe
wants to merge
48
commits into
develop
Choose a base branch
from
feat/adopt-websocket-WPB-17225
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
2ee88e2
chore: add new developer flag
netbe 60fb341
feat: register new capability
netbe fb0986f
chore: save new capability
netbe c457e64
chore: prepare next ticket
netbe 26bc4e7
format code and add information
netbe fa322db
fix capabilities new sync
netbe 32f39b0
format code
netbe b1752a8
fix compile issue
netbe f22b3d5
Merge branch 'develop' into feat/update-capabilities-WPB-17092
netbe 6062091
cleanup
netbe c9683cc
wip
netbe d1bd1ba
wip
netbe 2bd37ab
remove dead code
netbe 461a79e
disable extra info in console's logs
netbe 7e5fc5e
format code
netbe 219d2b3
wip
netbe 11295e2
Merge branch 'develop' into feat/adopt-websocket-WPB-17225
netbe a2b17f9
fix
netbe 1f8d192
Throw error on missing-notifications event
netbe 67a8bf8
add tests
netbe e795b9c
wip
netbe 5a033ef
format
netbe 36a56d6
Merge branch 'develop' into feat/adopt-websocket-WPB-17225
netbe 24784d9
wip
netbe 325ac91
write test
netbe ec994f9
skips notifications/last
netbe 0e032cd
revert bella
netbe d6964a0
fix notificationsMissed event
netbe 967dca2
separate the two protocols
netbe 510f2c1
try uptodate trigger
netbe e59bdba
wip
netbe 0ad30ab
avoid to open websocket is v2
netbe fbb3545
try liveSyncProtocol
netbe 6459b31
Merge branch 'develop' into feat/adopt-websocket-WPB-17225
netbe 76a1056
test
netbe b02fdc1
Merge remote-tracking branch 'origin/develop' into feat/adopt-websock…
netbe 1d2d862
make some changes
netbe d9fc81a
merge develop
netbe 4736d9f
add log info
netbe 0415b73
add log for networkService
netbe 095fa9f
add more info log
netbe 477ae3f
debug sending message
netbe d31cb47
wip
netbe 683cb9a
fix
netbe 2d06761
Merge remote-tracking branch 'origin/develop' into feat/adopt-websock…
netbe e9344fe
wip
netbe c621d53
Merge remote-tracking branch 'origin/develop' into feat/adopt-websock…
netbe 99842aa
wip
netbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
WireAPI/Sources/WireAPI/APIs/PushChannelAPI/NewPushChannelAPI.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// Wire | ||
// Copyright (C) 2025 Wire Swiss GmbH | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see http://www.gnu.org/licenses/. | ||
// | ||
|
||
// sourcery: AutoMockable | ||
/// An API access object for endpoints concerning the push channel. | ||
public protocol NewPushChannelAPI { | ||
|
||
/// Create a new push channel. | ||
/// | ||
/// - Parameter clientID: The id of the self client. | ||
/// - Returns: A push channel. | ||
|
||
func createPushChannel(clientID: String) async throws -> AnyNewPushChannel | ||
|
||
} | ||
|
||
// Workaround for automockable compiler error. | ||
public typealias AnyNewPushChannel = any NewPushChannelProtocol |
40 changes: 40 additions & 0 deletions
40
WireAPI/Sources/WireAPI/APIs/PushChannelAPI/NewPushChannelAPIBuilder.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// Wire | ||
// Copyright (C) 2025 Wire Swiss GmbH | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see http://www.gnu.org/licenses/. | ||
// | ||
import Foundation | ||
|
||
public struct NewPushChannelAPIBuilder { | ||
|
||
private let pushChannelService: PushChannelService | ||
|
||
/// Create a new builder. | ||
/// | ||
/// - Parameter pushChannelService: A push channel service to execute requests. | ||
/// | ||
public init(pushChannelService: PushChannelService) { | ||
self.pushChannelService = pushChannelService | ||
} | ||
|
||
/// Make a `PushChannelAPI`. | ||
/// | ||
/// - Returns: A `PushChannelAPI`. | ||
|
||
public func makeAPI(for apiVersion: APIVersion) -> any NewPushChannelAPI { | ||
NewPushChannelAPIImpl(pushChannelService: pushChannelService, apiVersion: apiVersion) | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
WireAPI/Sources/WireAPI/APIs/PushChannelAPI/NewPushChannelAPIImpl.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// Wire | ||
// Copyright (C) 2025 Wire Swiss GmbH | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see http://www.gnu.org/licenses/. | ||
// | ||
|
||
|
||
final class NewPushChannelAPIImpl: NewPushChannelAPI, VersionedAPI { | ||
|
||
let pushChannelService: any PushChannelServiceProtocol | ||
let apiVersion: APIVersion | ||
|
||
init(pushChannelService: any PushChannelServiceProtocol, apiVersion: APIVersion) { | ||
self.pushChannelService = pushChannelService | ||
self.apiVersion = apiVersion | ||
} | ||
|
||
func createPushChannel(clientID: String) async throws -> any NewPushChannelProtocol { | ||
let path = "\(pathPrefix)/events" | ||
|
||
let request = try URLRequestBuilder(path: path) | ||
.withMethod(.get) | ||
.withQueryItem(name: "client", value: clientID) | ||
.build() | ||
|
||
return try await pushChannelService.createNewPushChannel(request) | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
WireAPI/Sources/WireAPI/APIs/UpdateEventsAPI/Responses/UpdateEventEnvelopeV8.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// Wire | ||
// Copyright (C) 2025 Wire Swiss GmbH | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see http://www.gnu.org/licenses/. | ||
// | ||
|
||
import Foundation | ||
|
||
struct UpdateEventEnvelopeV8: Decodable { | ||
enum CodingKeys: String, CodingKey { | ||
case id | ||
case payload | ||
} | ||
|
||
let id: UUID | ||
let payload: [UpdateEventDecodingProxy] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,22 +60,6 @@ public final class Assembly { | |
return service | ||
}() | ||
|
||
private lazy var pushChannelService: some PushChannelServiceProtocol = PushChannelService( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused code |
||
networkService: pushChannelNetworkService, | ||
authenticationManager: authenticationManager | ||
) | ||
|
||
private lazy var pushChannelNetworkService: NetworkService = { | ||
let service = NetworkService( | ||
baseURL: backendEnvironment.webSocketURL, | ||
serverTrustValidator: serverTrustValidator | ||
) | ||
let config = urlSessionConfigurationFactory.makeWebSocketSessionConfiguration() | ||
let session = URLSession(configuration: config, delegate: service, delegateQueue: nil) | ||
service.configure(with: session) | ||
return service | ||
}() | ||
|
||
public lazy var authenticationManager: some AuthenticationManagerProtocol = AuthenticationManager( | ||
clientID: clientID, | ||
cookieStorage: cookieStorage, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
WireAPI/Sources/WireAPI/Network/PushChannel/AcknowledgmentType.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// Wire | ||
// Copyright (C) 2025 Wire Swiss GmbH | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see http://www.gnu.org/licenses/. | ||
// | ||
import Foundation | ||
|
||
enum AcknowledgmentType: String, Encodable { | ||
case fullSync = "ack_full_sync" | ||
case ack | ||
} |
38 changes: 38 additions & 0 deletions
38
WireAPI/Sources/WireAPI/Network/PushChannel/EventAcknowledgmentNotification.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// Wire | ||
// Copyright (C) 2025 Wire Swiss GmbH | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see http://www.gnu.org/licenses/. | ||
// | ||
import Foundation | ||
|
||
struct EventAcknowledgmentNotification: Encodable { | ||
|
||
struct AcknowledgmentData: Encodable { | ||
enum CodingKeys: String, CodingKey { | ||
case deliveryTag = "delivery_tag" | ||
case multiple | ||
} | ||
|
||
var deliveryTag: UInt64 | ||
var multiple: Bool | ||
} | ||
|
||
let type: AcknowledgmentType = .ack | ||
var data: AcknowledgmentData | ||
|
||
init(deliveryTag: UInt64, multiple: Bool) { | ||
self.data = .init(deliveryTag: deliveryTag, multiple: multiple) | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
WireAPI/Sources/WireAPI/Network/PushChannel/FullSyncAcknowledgmentNotification.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// Wire | ||
// Copyright (C) 2025 Wire Swiss GmbH | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see http://www.gnu.org/licenses/. | ||
// | ||
import Foundation | ||
|
||
struct FullSyncAcknowledgmentNotification: Encodable { | ||
let type: AcknowledgmentType = .fullSync | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for old enveloppes there is no acknowledgement so no deliveryTag needed