Skip to content

Commit

Permalink
Make sure timeline item content isn't logged.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Jan 16, 2023
1 parent b355838 commit 199f192
Show file tree
Hide file tree
Showing 19 changed files with 206 additions and 72 deletions.
166 changes: 101 additions & 65 deletions ElementX.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// Copyright 2023 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import MatrixRustSDK

// MARK: Redact message content from logs

extension EmoteMessageContent: CustomStringConvertible {
public var description: String {
String(describing: Self.self)
}
}

extension FileMessageContent: CustomStringConvertible {
public var description: String {
String(describing: Self.self)
}
}

extension ImageMessageContent: CustomStringConvertible {
public var description: String {
String(describing: Self.self)
}
}

extension NoticeMessageContent: CustomStringConvertible {
public var description: String {
String(describing: Self.self)
}
}

extension TextMessageContent: CustomStringConvertible {
public var description: String {
String(describing: Self.self)
}
}

extension VideoMessageContent: CustomStringConvertible {
public var description: String {
String(describing: Self.self)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import Foundation
import MatrixRustSDK

/// A protocol that contains the base `m.room.message` event content properties.
protocol MessageContentProtocol: RoomMessageEventContentProtocol {
/// The `CustomStringConvertible` conformance is to redact specific properties from the logs.
protocol MessageContentProtocol: RoomMessageEventContentProtocol, CustomStringConvertible {
var body: String { get }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
//

import Foundation
import UIKit

struct EmoteRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hashable {
Expand All @@ -32,3 +31,11 @@ struct EmoteRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hash

var properties = RoomTimelineItemProperties()
}

// MARK: - Redact content from logs

extension EmoteRoomTimelineItem: CustomStringConvertible {
var description: String {
"\(String(describing: Self.self)): id: \(id), timestamp: \(timestamp), isOutgoing: \(isOutgoing), properties: \(properties)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
//

import Foundation
import UIKit

struct FileRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hashable {
Expand All @@ -35,3 +34,11 @@ struct FileRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hasha

var properties = RoomTimelineItemProperties()
}

// MARK: - Redact content from logs

extension FileRoomTimelineItem: CustomStringConvertible {
var description: String {
"\(String(describing: Self.self)): id: \(id), timestamp: \(timestamp), isOutgoing: \(isOutgoing), properties: \(properties)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
//

import Foundation
import UIKit

struct ImageRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hashable {
Expand All @@ -40,3 +39,11 @@ struct ImageRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hash

var properties = RoomTimelineItemProperties()
}

// MARK: - Redact content from logs

extension ImageRoomTimelineItem: CustomStringConvertible {
var description: String {
"\(String(describing: Self.self)): id: \(id), timestamp: \(timestamp), isOutgoing: \(isOutgoing), properties: \(properties)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
//

import Foundation
import UIKit

struct NoticeRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hashable {
Expand All @@ -32,3 +31,11 @@ struct NoticeRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Has

var properties = RoomTimelineItemProperties()
}

// MARK: - Redact content from logs

extension NoticeRoomTimelineItem: CustomStringConvertible {
var description: String {
"\(String(describing: Self.self)): id: \(id), timestamp: \(timestamp), isOutgoing: \(isOutgoing), properties: \(properties)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
//

import Foundation
import UIKit

struct TextRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hashable {
Expand All @@ -32,3 +31,11 @@ struct TextRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hasha

var properties = RoomTimelineItemProperties()
}

// MARK: - Redact content from logs

extension TextRoomTimelineItem: CustomStringConvertible {
var description: String {
"\(String(describing: Self.self)): id: \(id), timestamp: \(timestamp), isOutgoing: \(isOutgoing), properties: \(properties)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
//

import Foundation
import UIKit

struct VideoRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hashable {
Expand Down Expand Up @@ -42,3 +41,11 @@ struct VideoRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hash

var properties = RoomTimelineItemProperties()
}

// MARK: - Redact content from logs

extension VideoRoomTimelineItem: CustomStringConvertible {
var description: String {
"\(String(describing: Self.self)): id: \(id), timestamp: \(timestamp), isOutgoing: \(isOutgoing), properties: \(properties)"
}
}

0 comments on commit 199f192

Please sign in to comment.