Skip to content

feat: port Wire Android services & use cases - WPB-16148 #2920

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

Merged
merged 43 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a71c332
feat: port most Android kalium models & interfaces
El-Fitz Apr 15, 2025
34e09e9
feat: implement persistency for conversations attributes, boilerplate…
El-Fitz Apr 17, 2025
ef217d8
feat: port & implement S3 client & upload manager
El-Fitz Apr 21, 2025
d61ba98
style: fix formatting
El-Fitz Apr 21, 2025
0af8aad
Comment out non-compiling code
samwyndham Apr 30, 2025
013ed95
Fix `MessageAttachmentDraftDataSource.add(conversationID:node:mimeTyp…
samwyndham Apr 30, 2025
a195a25
Comment out non-compiling code
samwyndham Apr 30, 2025
a8a9565
Fix compile issue
samwyndham Apr 30, 2025
67ff48a
Comment broken tests
samwyndham Apr 30, 2025
7052223
Make `Aws` uppercase
samwyndham Apr 30, 2025
588329b
Change `cellsApi` to `cellsAPI`
samwyndham Apr 30, 2025
60d1f2e
Change `Dao` to `DAO`
samwyndham Apr 30, 2025
2004156
Fix WireCellsCellsDataSource concurrency issues
samwyndham Apr 30, 2025
27ece32
Rename `Dto` to `DTO`
samwyndham Apr 30, 2025
7b4d9e1
Fix file naming
samwyndham Apr 30, 2025
5d4d55c
Remove TODO
samwyndham Apr 30, 2025
810e124
Delete stray commented code
samwyndham Apr 30, 2025
2cc64e2
Make `WireCellsMessageAttachmentDraftRepository.observe(conversationI…
samwyndham Apr 30, 2025
2c852ab
Implement `WireCellsAWSClientImplementation.getPreSignedUrl(objectKey:)`
samwyndham Apr 30, 2025
f5bea45
Report download progress
samwyndham Apr 30, 2025
6493154
Update cells SDK
samwyndham Apr 30, 2025
95b68f0
Create todo comment
samwyndham May 2, 2025
1bbb808
Merge branch 'develop' into feat/wire-cells-upgrade-service
samwyndham May 2, 2025
7804585
Store upload status as Int16
samwyndham May 2, 2025
a53ed76
Create `zmessaging2.126.0` model
samwyndham May 2, 2025
9140363
Update data model schema
samwyndham May 2, 2025
c9decb8
Fix compile errors
samwyndham May 2, 2025
f635115
Update file names ...Dao -> ...DAO
samwyndham May 2, 2025
4510e39
Don't use WireCellsAPI model directly in core data
samwyndham May 2, 2025
e9f79d1
Commit auto generated mocks
samwyndham May 2, 2025
5752bbd
Fix core data not finding `WireCellsMessageAttachmentDraftEntity` class
samwyndham May 2, 2025
5408260
Test creating a `WireCellsMessageAttachmentDraftEntity`
samwyndham May 2, 2025
797adab
Delete unused tests
samwyndham May 2, 2025
654a478
Lint & format
samwyndham May 2, 2025
adef6d1
Fix compile errors
samwyndham May 5, 2025
47b501a
Update Databases changelog
samwyndham May 5, 2025
9cbbe26
Fix DatabaseMigrationTests
samwyndham May 5, 2025
bda2386
Rename `Cell` types to `Node`
samwyndham May 7, 2025
9b8a4fb
Rename `Cell` types to `Node` in file names
samwyndham May 7, 2025
bd5f9f1
Rename `WireCellsNodesApiImpl` to `WireCellsNodesAPIImpl`
samwyndham May 7, 2025
11f060d
Merge branch 'develop' into feat/wire-cells-upgrade-service
samwyndham May 7, 2025
28dcf84
Merge branch 'develop' into feat/wire-cells-upgrade-service
samwyndham May 15, 2025
0361c26
Fix data model tests
samwyndham May 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WireCells/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/pydio/cells-sdk-swift.git", from: "0.1.1-alpha09"),
.package(url: "https://github.com/pydio/cells-sdk-swift.git", from: "0.1.1-alpha10"),
.package(url: "https://github.com/awslabs/aws-sdk-swift.git", from: "1.0.0"),
.package(name: "WireFoundation", path: "../WireFoundation"),
.package(name: "WireUI", path: "../WireUI"),
Expand Down
55 changes: 55 additions & 0 deletions WireCells/Sources/WireCellsAPI/AnyAsyncSequence.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// 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/.
//

// This is used to erase the type of an `AsyncSequence` to a generic one.
// This is useful because since iOS 18, `AsyncSequence` takes two associated types:
// `Element` and `Failure`.
// This means that if you target iOS 17 and earlier, you can't use `AsyncSequence`,
// as the second argument for `AsyncSequence` is only available in iOS 18 and later.
//
// see https://forums.swift.org/t/possible-to-return-an-asyncsequence-t-for-ios-17-when-building-against-ios-18/76107/2
public struct AnyAsyncSequence<Element, Failure: Error>: AsyncSequence {
public typealias AsyncIterator = AnyAsyncIterator<Element, Failure>

private let _makeAsyncIterator: () -> AsyncIterator

public init<S: AsyncSequence>(_ base: S) where S.Element == Element {
var baseIterator = base.makeAsyncIterator()
self._makeAsyncIterator = {
AnyAsyncIterator {
try? await baseIterator.next()
}
}
}

public func makeAsyncIterator() -> AsyncIterator {
_makeAsyncIterator()
}
}

public struct AnyAsyncIterator<Element, Failure: Error>: AsyncIteratorProtocol {
private let _next: () async throws(Failure) -> Element?

public init(_ next: @escaping () async -> Element?) {
self._next = next
}

public func next() async throws(Failure) -> Element? {
try await _next()
}
}
52 changes: 52 additions & 0 deletions WireCells/Sources/WireCellsAPI/Model/WireCellsAssetMetadata.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// 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/.
//

public import Foundation

public enum WireCellsAssetMetadata: Equatable, Hashable, Sendable {
case image(width: Int, height: Int)
case video(width: Int?, height: Int?, durationMs: Int64?)
case audio(durationMs: Int64?, normalizedLoudness: Data?)

public var width: Int? {
switch self {
case let .image(width, _), let .video(width?, _, _):
width
case .video, .audio:
nil
}
}

public var height: Int? {
switch self {
case let .image(_, height), let .video(_, height?, _):
height
case .video, .audio:
nil
}
}

public var durationMs: Int64? {
switch self {
case .image:
nil
case let .video(_, _, durationMs), let .audio(durationMs, _):
durationMs
}
}
}
60 changes: 60 additions & 0 deletions WireCells/Sources/WireCellsAPI/Model/WireCellsConversationID.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// 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/.
//

public import Foundation

public struct WireCellsConversationID: Codable, Equatable, Hashable, Identifiable, Sendable {

public let domain: String
public let uuid: UUID

public var id: String {
"\(uuid.uuidString)@\(domain)"
}

public var pydioQualifiedID: String {
"\(uuid.uuidString)@\(domain)"
}

package init(domain: String, uuid: UUID) {
self.domain = domain
self.uuid = uuid
}

public init?(string: String) {
// The CellsSDK provides the qualifiedID as a string in the format `uuid@domain`
let components = string.split(separator: "@")
guard components.count == 2, let uuid = UUID(uuidString: String(components[1])) else {
return nil
}
self.domain = String(components[0])
self.uuid = uuid
}
}

extension WireCellsConversationID: CustomStringConvertible {
public var description: String {
"\(uuid.uuidString)@\(domain)"
}
}

extension WireCellsConversationID: CustomDebugStringConvertible {
public var debugDescription: String {
"ConversationID(domain: \(domain), uuid: \(uuid.uuidString))"
}
}
31 changes: 31 additions & 0 deletions WireCells/Sources/WireCellsAPI/Model/WireCellsCredentials.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// 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/.
//

public import Foundation

public struct WireCellsCredentials: Equatable, Hashable, Sendable {
public let serverUrl: URL
public let accessToken: String
public let gatewaySecret: String

package init(serverUrl: URL, accessToken: String, gatewaySecret: String) {
self.serverUrl = serverUrl
self.accessToken = accessToken
self.gatewaySecret = gatewaySecret
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@
// along with this program. If not, see http://www.gnu.org/licenses/.
//

public import Foundation
import CellsSDK
import Foundation

public struct WireCellsFileUploadInfo: Identifiable, Sendable {
public let data: Data
/// Path that the file should be uploaded to
public let uploadPath: String
package struct WireCellsGetFilesResponseDTO: Equatable, Hashable, Sendable {
package let nodes: [WireCellsNodeDTO]

public var id: String { uploadPath }
package init(nodes: [WireCellsNodeDTO]) {
self.nodes = nodes
}
}

/// - Parameters:
/// - data: The file data
/// - uploadPath: Path that the file should be uploaded to
public init(data: Data, uploadPath: String) {
self.data = data
self.uploadPath = uploadPath
package extension RestNodeCollection {
func toDTO() -> WireCellsGetFilesResponseDTO {
WireCellsGetFilesResponseDTO(
// /!\ Will silently filter out nil values that could not be mapped to DTOs
nodes: nodes?.compactMap { $0.toDTO() } ?? []
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//
// 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/.
//

public import Foundation

public struct WireCellsMessageAttachmentDraftID: Equatable, Hashable, Identifiable, Sendable {
public let uuid: UUID
public let versionID: String

public var id: String {
"\(uuid.uuidString)/\(versionID)"
}

package init(uuid: UUID, versionID: String) {
self.uuid = uuid
self.versionID = versionID
}
}

extension WireCellsMessageAttachmentDraftID: CustomStringConvertible {
public var description: String {
"\(uuid.uuidString)/\(versionID)"
}
}

extension WireCellsMessageAttachmentDraftID: CustomDebugStringConvertible {
public var debugDescription: String {
"WireCellsMessageAttachmentDraftID(uuid: \(uuid), versionID: \(versionID))"
}
}

public struct WireCellsMessageAttachmentDraft: Sendable, Hashable, Identifiable {
public let id: WireCellsMessageAttachmentDraftID
public let fileName: String
public let remoteFilePath: String
public let localFilePath: String
public let fileSize: UInt64
public let uploadStatus: WireCellsAttachmentUploadStatus
public let mimeType: String
public let assetWidth: UInt64?
public let assetHeight: UInt64?
public let assetDuration: UInt64?

public init(
uuid: UUID,
versionID: String,
fileName: String,
remoteFilePath: String,
localFilePath: String,
fileSize: UInt64,
uploadStatus: WireCellsAttachmentUploadStatus,
mimeType: String,
assetWidth: UInt64?,
assetHeight: UInt64?,
assetDuration: UInt64?
) {
self.id = WireCellsMessageAttachmentDraftID(
uuid: uuid,
versionID: versionID
)
self.fileName = fileName
self.remoteFilePath = remoteFilePath
self.localFilePath = localFilePath
self.fileSize = fileSize
self.uploadStatus = uploadStatus
self.mimeType = mimeType
self.assetWidth = assetWidth
self.assetHeight = assetHeight
self.assetDuration = assetDuration
}
}

public enum WireCellsAttachmentUploadStatus: Sendable, Hashable {
case uploading
case uploaded
case failed
}
Loading
Loading