TM-SGNL-iOS/SignalServiceKit/MessageBackup/MessageBackupManagerMock.swift
TeleMessage developers dde0620daf initial commit
2025-05-03 12:28:28 -07:00

92 lines
2.9 KiB
Swift

//
// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
import Foundation
public import LibSignalClient
#if TESTABLE_BUILD
open class MessageBackupManagerMock: MessageBackupManager {
public func downloadEncryptedBackup(
localIdentifiers: LocalIdentifiers,
auth: ChatServiceAuth
) async throws -> URL {
return URL(string: "file://")!
}
public func uploadEncryptedBackup(
metadata: Upload.EncryptedBackupUploadMetadata,
localIdentifiers: LocalIdentifiers,
auth: ChatServiceAuth
) async throws -> Upload.Result<Upload.EncryptedBackupUploadMetadata> {
return Upload.Result(
cdnKey: "cdnKey",
cdnNumber: 1,
localUploadMetadata: .init(
fileUrl: URL(string: "file://")!,
digest: Data(),
encryptedDataLength: 0,
plaintextDataLength: 0),
beginTimestamp: 0,
finishTimestamp: Date().ows_millisecondsSince1970
)
}
public func exportEncryptedBackup(
localIdentifiers: LocalIdentifiers,
backupKey: BackupKey,
backupPurpose: MessageBackupPurpose,
progress: OWSProgressSink?
) async throws -> Upload.EncryptedBackupUploadMetadata {
let source = await progress?.addSource(withLabel: "", unitCount: 1)
source?.incrementCompletedUnitCount(by: 1)
return Upload.EncryptedBackupUploadMetadata(
fileUrl: URL(string: "file://")!,
digest: Data(),
encryptedDataLength: 0,
plaintextDataLength: 0
)
}
public func exportPlaintextBackup(
localIdentifiers: LocalIdentifiers,
backupPurpose: MessageBackupPurpose,
progress: OWSProgressSink?
) async throws -> URL {
let source = await progress?.addSource(withLabel: "", unitCount: 1)
source?.incrementCompletedUnitCount(by: 1)
return URL(string: "file://")!
}
public func hasRestoredFromBackup(tx: DBReadTransaction) -> Bool {
false
}
public func importEncryptedBackup(
fileUrl: URL,
localIdentifiers: LocalIdentifiers,
backupKey: BackupKey,
progress: OWSProgressSink?
) async throws {
let source = await progress?.addSource(withLabel: "", unitCount: 1)
source?.incrementCompletedUnitCount(by: 1)
}
public func importPlaintextBackup(
fileUrl: URL,
localIdentifiers: LocalIdentifiers,
progress: OWSProgressSink?
) async throws {
let source = await progress?.addSource(withLabel: "", unitCount: 1)
source?.incrementCompletedUnitCount(by: 1)
}
public func validateEncryptedBackup(
fileUrl: URL,
localIdentifiers: LocalIdentifiers,
backupKey: BackupKey,
backupPurpose: MessageBackupPurpose
) async throws {}
}
#endif