App now prevents redacting own messages if there is no permission (#2368)

This commit is contained in:
Mauro
2024-01-23 12:05:30 +01:00
committed by GitHub
parent 31286c75fc
commit 30a0561251
5 changed files with 42 additions and 2 deletions
@@ -52,6 +52,7 @@ class RoomScreenInteractionHandler {
private var voiceMessageRecorderObserver: AnyCancellable?
private var canCurrentUserRedactOthers = false
private var canCurrentUserRedactSelf = false
private var resumeVoiceMessagePlaybackAfterScrubbing = false
init(roomProxy: RoomProxyProtocol,
@@ -86,6 +87,12 @@ class RoomScreenInteractionHandler {
} else {
canCurrentUserRedactOthers = false
}
if case let .success(value) = await roomProxy.canUserRedactOwn(userID: roomProxy.ownUserID) {
canCurrentUserRedactSelf = value
} else {
canCurrentUserRedactSelf = false
}
guard let timelineItem = timelineController.timelineItems.firstUsingStableID(itemID),
let eventTimelineItem = timelineItem as? EventBasedTimelineItemProtocol else {
@@ -604,7 +611,7 @@ class RoomScreenInteractionHandler {
// MARK: - Private
private func canRedactItem(_ item: EventBasedTimelineItemProtocol) -> Bool {
item.isOutgoing || (canCurrentUserRedactOthers && !roomProxy.isDirect)
item.isOutgoing ? canCurrentUserRedactSelf : canCurrentUserRedactOthers && !roomProxy.isDirect
}
private func buildReplyInfo(for item: EventBasedTimelineItemProtocol) -> ReplyInfo {