Settings to enable and disable sending public RRs (#2384)

This commit is contained in:
Mauro
2024-01-25 15:47:33 +01:00
committed by GitHub
parent 29c8049559
commit e755be4cda
14 changed files with 84 additions and 38 deletions
@@ -57,7 +57,7 @@ class MockRoomTimelineController: RoomTimelineControllerProtocol {
func sendReadReceipt(for itemID: TimelineItemIdentifier) async -> Result<Void, RoomTimelineControllerError> {
guard let roomProxy, let eventID = itemID.eventID else { return .failure(.generic) }
switch await roomProxy.timeline.sendReadReceipt(for: eventID) {
switch await roomProxy.timeline.sendReadReceipt(for: eventID, type: .read) {
case .success:
return .success(())
case .failure:
@@ -93,7 +93,8 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
let eventID = itemID.eventID
else { return .success(()) }
switch await roomProxy.timeline.sendReadReceipt(for: eventID) {
switch await roomProxy.timeline.sendReadReceipt(for: eventID,
type: appSettings.sendReadReceiptsEnabled ? .read : .readPrivate) {
case .success:
return .success(())
case .failure:
@@ -453,7 +453,7 @@ final class TimelineProxy: TimelineProxyProtocol {
}
}
func sendReadReceipt(for eventID: String) async -> Result<Void, TimelineProxyError> {
func sendReadReceipt(for eventID: String, type: ReceiptType) async -> Result<Void, TimelineProxyError> {
MXLog.info("Sending read receipt for eventID: \(eventID)")
sendMessageBackgroundTask = await backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true)
@@ -463,7 +463,7 @@ final class TimelineProxy: TimelineProxyProtocol {
return await Task.dispatch(on: lowPriorityDispatchQueue) {
do {
try self.timeline.sendReadReceipt(receiptType: .read, eventId: eventID)
try self.timeline.sendReadReceipt(receiptType: type, eventId: eventID)
MXLog.info("Finished sending read receipt for eventID: \(eventID)")
return .success(())
} catch {
@@ -102,7 +102,7 @@ protocol TimelineProxyProtocol {
progressSubject: CurrentValueSubject<Double, Never>?,
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError>
func sendReadReceipt(for eventID: String) async -> Result<Void, TimelineProxyError>
func sendReadReceipt(for eventID: String, type: ReceiptType) async -> Result<Void, TimelineProxyError>
func sendMessageEventContent(_ messageContent: RoomMessageEventContentWithoutRelation) async -> Result<Void, TimelineProxyError>