2023-11-28 20:01:35 +01:00
|
|
|
//
|
2024-09-06 16:34:30 +03:00
|
|
|
// Copyright 2023, 2024 New Vector Ltd.
|
2023-11-28 20:01:35 +01:00
|
|
|
//
|
2025-01-06 11:27:37 +01:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
|
|
// Please see LICENSE files in the repository root for full details.
|
2023-11-28 20:01:35 +01:00
|
|
|
//
|
|
|
|
|
|
|
|
import Combine
|
|
|
|
import Foundation
|
|
|
|
import MatrixRustSDK
|
|
|
|
|
2024-12-11 15:40:31 +00:00
|
|
|
enum TimelineKind: Equatable {
|
2024-08-22 20:33:21 +02:00
|
|
|
case live
|
|
|
|
case detached
|
|
|
|
case pinned
|
2024-12-11 15:40:31 +00:00
|
|
|
|
2025-02-05 13:27:23 +00:00
|
|
|
enum MediaPresentation { case roomScreenLive, roomScreenDetached, pinnedEventsScreen, mediaFilesScreen }
|
2024-12-11 15:40:31 +00:00
|
|
|
case media(MediaPresentation)
|
2024-08-22 20:33:21 +02:00
|
|
|
}
|
|
|
|
|
2025-02-05 13:27:23 +00:00
|
|
|
enum TimelineFocus {
|
|
|
|
case live
|
|
|
|
case eventID(String)
|
|
|
|
case pinned
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TimelineAllowedMessageType {
|
|
|
|
case audio, file, image, video
|
|
|
|
}
|
|
|
|
|
2024-05-28 10:17:13 +03:00
|
|
|
enum TimelineProxyError: Error {
|
|
|
|
case sdkError(Error)
|
2023-11-28 20:01:35 +01:00
|
|
|
|
2024-05-28 10:17:13 +03:00
|
|
|
case failedRedacting
|
|
|
|
case failedPaginatingEndReached
|
2023-12-04 15:55:28 +02:00
|
|
|
}
|
|
|
|
|
2023-11-28 20:01:35 +01:00
|
|
|
// sourcery: AutoMockable
|
|
|
|
protocol TimelineProxyProtocol {
|
2025-02-03 14:14:01 +00:00
|
|
|
var timelineProvider: TimelineProviderProtocol { get }
|
2023-12-18 16:38:39 +01:00
|
|
|
|
2023-11-28 20:01:35 +01:00
|
|
|
func subscribeForUpdates() async
|
|
|
|
|
|
|
|
func fetchDetails(for eventID: String)
|
|
|
|
|
2024-05-28 10:17:13 +03:00
|
|
|
func messageEventContent(for timelineItemID: TimelineItemIdentifier) async -> RoomMessageEventContentWithoutRelation?
|
2023-11-28 20:01:35 +01:00
|
|
|
|
2024-12-18 11:10:56 +02:00
|
|
|
func retryDecryption(sessionIDs: [String]?) async
|
2023-11-28 20:01:35 +01:00
|
|
|
|
2024-04-25 18:32:33 +01:00
|
|
|
func paginateBackwards(requestSize: UInt16) async -> Result<Void, TimelineProxyError>
|
|
|
|
func paginateForwards(requestSize: UInt16) async -> Result<Void, TimelineProxyError>
|
2023-11-28 20:01:35 +01:00
|
|
|
|
2025-02-04 09:50:46 +00:00
|
|
|
func edit(_ eventOrTransactionID: TimelineItemIdentifier.EventOrTransactionID,
|
2024-11-21 18:18:27 +00:00
|
|
|
newContent: EditedContent) async -> Result<Void, TimelineProxyError>
|
2024-05-28 10:17:13 +03:00
|
|
|
|
2025-02-04 09:50:46 +00:00
|
|
|
func redact(_ eventOrTransactionID: TimelineItemIdentifier.EventOrTransactionID,
|
2024-05-28 10:17:13 +03:00
|
|
|
reason: String?) async -> Result<Void, TimelineProxyError>
|
|
|
|
|
2024-07-26 20:41:00 +02:00
|
|
|
func pin(eventID: String) async -> Result<Bool, TimelineProxyError>
|
|
|
|
|
|
|
|
func unpin(eventID: String) async -> Result<Bool, TimelineProxyError>
|
|
|
|
|
2024-05-28 10:17:13 +03:00
|
|
|
// MARK: - Sending
|
|
|
|
|
2023-11-28 20:01:35 +01:00
|
|
|
func sendAudio(url: URL,
|
|
|
|
audioInfo: AudioInfo,
|
2024-11-19 16:35:01 +00:00
|
|
|
caption: String?,
|
2023-11-28 20:01:35 +01:00
|
|
|
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError>
|
|
|
|
|
|
|
|
func sendFile(url: URL,
|
|
|
|
fileInfo: FileInfo,
|
2024-11-19 16:35:01 +00:00
|
|
|
caption: String?,
|
2023-11-28 20:01:35 +01:00
|
|
|
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError>
|
|
|
|
|
|
|
|
func sendImage(url: URL,
|
|
|
|
thumbnailURL: URL,
|
|
|
|
imageInfo: ImageInfo,
|
2024-11-19 16:35:01 +00:00
|
|
|
caption: String?,
|
2023-11-28 20:01:35 +01:00
|
|
|
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError>
|
|
|
|
|
|
|
|
func sendLocation(body: String,
|
|
|
|
geoURI: GeoURI,
|
|
|
|
description: String?,
|
|
|
|
zoomLevel: UInt8?,
|
|
|
|
assetType: AssetType?) async -> Result<Void, TimelineProxyError>
|
|
|
|
|
|
|
|
func sendVideo(url: URL,
|
|
|
|
thumbnailURL: URL,
|
|
|
|
videoInfo: VideoInfo,
|
2024-11-19 16:35:01 +00:00
|
|
|
caption: String?,
|
2023-11-28 20:01:35 +01:00
|
|
|
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError>
|
|
|
|
|
|
|
|
func sendVoiceMessage(url: URL,
|
|
|
|
audioInfo: AudioInfo,
|
|
|
|
waveform: [UInt16],
|
|
|
|
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError>
|
|
|
|
|
2024-01-25 15:47:33 +01:00
|
|
|
func sendReadReceipt(for eventID: String, type: ReceiptType) async -> Result<Void, TimelineProxyError>
|
2023-11-28 20:01:35 +01:00
|
|
|
|
|
|
|
func sendMessageEventContent(_ messageContent: RoomMessageEventContentWithoutRelation) async -> Result<Void, TimelineProxyError>
|
|
|
|
|
|
|
|
func sendMessage(_ message: String,
|
2024-01-12 12:58:36 +01:00
|
|
|
html: String?,
|
2024-10-16 14:07:54 +03:00
|
|
|
inReplyToEventID: String?,
|
2023-11-28 20:01:35 +01:00
|
|
|
intentionalMentions: IntentionalMentions) async -> Result<Void, TimelineProxyError>
|
|
|
|
|
2025-02-04 09:50:46 +00:00
|
|
|
func toggleReaction(_ reaction: String, to eventID: TimelineItemIdentifier.EventOrTransactionID) async -> Result<Void, TimelineProxyError>
|
2023-11-28 20:01:35 +01:00
|
|
|
|
|
|
|
func createPoll(question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, TimelineProxyError>
|
|
|
|
|
|
|
|
func editPoll(original eventID: String,
|
|
|
|
question: String,
|
|
|
|
answers: [String],
|
|
|
|
pollKind: Poll.Kind) async -> Result<Void, TimelineProxyError>
|
|
|
|
|
|
|
|
func endPoll(pollStartID: String, text: String) async -> Result<Void, TimelineProxyError>
|
|
|
|
|
|
|
|
func sendPollResponse(pollStartID: String, answers: [String]) async -> Result<Void, TimelineProxyError>
|
2024-06-13 14:19:38 +02:00
|
|
|
|
|
|
|
func getLoadedReplyDetails(eventID: String) async -> Result<InReplyToDetails, TimelineProxyError>
|
2024-07-22 13:15:57 +02:00
|
|
|
|
|
|
|
func buildMessageContentFor(_ message: String,
|
|
|
|
html: String?,
|
|
|
|
intentionalMentions: Mentions) -> RoomMessageEventContentWithoutRelation
|
2023-11-28 20:01:35 +01:00
|
|
|
}
|
2024-12-18 11:10:56 +02:00
|
|
|
|
|
|
|
extension TimelineProxyProtocol {
|
|
|
|
func retryDecryption() async {
|
|
|
|
await retryDecryption(sessionIDs: nil)
|
|
|
|
}
|
|
|
|
}
|