mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Report Content (#587)
* ui for reporting content has been implemented * implementation done, will only work withe a mx rust sdk that supports report content * fix * code improvements * code improvement * fix typo Co-authored-by: Stefan Ceriu <stefanc@matrix.org> * removing unneeded task * code improvement * changelog --------- Co-authored-by: Stefan Ceriu <stefanc@matrix.org>
This commit is contained in:
@@ -74,6 +74,10 @@ struct MockRoomProxy: RoomProxyProtocol {
|
||||
.failure(.failedRedactingEvent)
|
||||
}
|
||||
|
||||
func reportContent(_ eventID: String, reason: String?) async -> Result<Void, RoomProxyError> {
|
||||
.failure(.failedReportingContent)
|
||||
}
|
||||
|
||||
func members() async -> Result<[RoomMemberProxy], RoomProxyError> {
|
||||
if let members {
|
||||
return .success(members)
|
||||
|
||||
@@ -253,6 +253,22 @@ class RoomProxy: RoomProxyProtocol {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func reportContent(_ eventID: String, reason: String?) async -> Result<Void, RoomProxyError> {
|
||||
sendMessageBackgroundTask = backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true)
|
||||
defer {
|
||||
sendMessageBackgroundTask?.stop()
|
||||
}
|
||||
|
||||
return await Task.dispatch(on: userInitiatedDispatchQueue) {
|
||||
do {
|
||||
try self.room.reportContent(eventId: eventID, score: nil, reason: reason)
|
||||
return .success(())
|
||||
} catch {
|
||||
return .failure(.failedReportingContent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func members() async -> Result<[RoomMemberProxy], RoomProxyError> {
|
||||
await Task.dispatch(on: .global()) {
|
||||
|
||||
@@ -28,6 +28,7 @@ enum RoomProxyError: Error {
|
||||
case failedSendingReaction
|
||||
case failedEditingMessage
|
||||
case failedRedactingEvent
|
||||
case failedReportingContent
|
||||
case failedAddingTimelineListener
|
||||
case failedRetrievingMembers
|
||||
}
|
||||
@@ -71,6 +72,8 @@ protocol RoomProxyProtocol {
|
||||
|
||||
func redact(_ eventID: String) async -> Result<Void, RoomProxyError>
|
||||
|
||||
func reportContent(_ eventID: String, reason: String?) async -> Result<Void, RoomProxyError>
|
||||
|
||||
func members() async -> Result<[RoomMemberProxy], RoomProxyError>
|
||||
|
||||
func retryDecryption(for sessionID: String) async
|
||||
|
||||
@@ -64,6 +64,8 @@ class MockRoomTimelineController: RoomTimelineControllerProtocol {
|
||||
func editMessage(_ newMessage: String, original itemID: String) async { }
|
||||
|
||||
func redact(_ itemID: String) async { }
|
||||
|
||||
func reportContent(_ itemID: String, reason: String?) async { }
|
||||
|
||||
func debugDescription(for itemID: String) -> String {
|
||||
"Mock debug description"
|
||||
|
||||
@@ -187,6 +187,16 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
MXLog.error("Failed redacting message with error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
func reportContent(_ itemID: String, reason: String?) async {
|
||||
MXLog.info("Send report content in \(roomID)")
|
||||
switch await roomProxy.reportContent(itemID, reason: reason) {
|
||||
case .success:
|
||||
MXLog.info("Finished reporting content")
|
||||
case .failure(let error):
|
||||
MXLog.error("Failed reporting content with error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
// Handle this parallel to the timeline items so we're not forced
|
||||
// to bundle the Rust side objects within them
|
||||
|
||||
+2
@@ -59,6 +59,8 @@ protocol RoomTimelineControllerProtocol {
|
||||
func sendReaction(_ reaction: String, to itemID: String) async
|
||||
|
||||
func redact(_ itemID: String) async
|
||||
|
||||
func reportContent(_ itemID: String, reason: String?) async
|
||||
|
||||
func debugDescription(for itemID: String) -> String
|
||||
|
||||
|
||||
Reference in New Issue
Block a user