mirror of https://github.com/oxen-io/session-ios
Handle screenshot notifications
parent
08015f570f
commit
9d6d68d33e
@ -1,35 +1,29 @@
|
|||||||
|
|
||||||
@objc(SNDataExtractionNotificationInfoMessage)
|
@objc(SNDataExtractionNotificationInfoMessage)
|
||||||
final class DataExtractionNotificationInfoMessage : TSInfoMessage {
|
final class DataExtractionNotificationInfoMessage : TSInfoMessage {
|
||||||
private let kind: DataExtractionNotification.Kind
|
|
||||||
|
|
||||||
init(kind: DataExtractionNotification.Kind, timestamp: UInt64, thread: TSThread) {
|
init(type: TSInfoMessageType, sentTimestamp: UInt64, thread: TSThread, referencedAttachmentTimestamp: UInt64?) {
|
||||||
self.kind = kind
|
super.init(timestamp: sentTimestamp, in: thread, messageType: type)
|
||||||
let infoMessageType: TSInfoMessageType
|
|
||||||
switch kind {
|
|
||||||
case .screenshot: infoMessageType = .screenshotNotification
|
|
||||||
case .mediaSaved: infoMessageType = .mediaSavedNotification
|
|
||||||
}
|
|
||||||
super.init(timestamp: timestamp, in: thread, messageType: infoMessageType)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
required init(coder: NSCoder) {
|
required init(coder: NSCoder) {
|
||||||
preconditionFailure("Not implemented.")
|
super.init(coder: coder)
|
||||||
}
|
}
|
||||||
|
|
||||||
required init(dictionary dictionaryValue: [String:Any]!) throws {
|
required init(dictionary dictionaryValue: [String:Any]!) throws {
|
||||||
preconditionFailure("Not implemented.")
|
try super.init(dictionary: dictionaryValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func previewText(with transaction: YapDatabaseReadTransaction) -> String {
|
override func previewText(with transaction: YapDatabaseReadTransaction) -> String {
|
||||||
guard let thread = thread as? TSContactThread else { return "" } // Should never occur
|
guard let thread = thread as? TSContactThread else { return "" } // Should never occur
|
||||||
let sessionID = thread.contactIdentifier()
|
let sessionID = thread.contactIdentifier()
|
||||||
let displayName = Storage.shared.getContact(with: sessionID)?.displayName(for: .regular) ?? sessionID
|
let displayName = Storage.shared.getContact(with: sessionID)?.displayName(for: .regular) ?? sessionID
|
||||||
switch kind {
|
switch messageType {
|
||||||
case .screenshot: return "\(displayName) took a screenshot."
|
case .screenshotNotification: return "\(displayName) took a screenshot."
|
||||||
case .mediaSaved:
|
case .mediaSavedNotification:
|
||||||
// TODO: Use the timestamp and tell the user * which * media was saved
|
// TODO: Use referencedAttachmentTimestamp to tell the user * which * media was saved
|
||||||
return "Media saved by \(displayName)."
|
return "Media saved by \(displayName)."
|
||||||
|
default: preconditionFailure()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue