Handle media saved notifications
This commit is contained in:
parent
9d6d68d33e
commit
b21163a421
|
@ -487,6 +487,7 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
|
|||
func save(_ viewItem: ConversationViewItem) {
|
||||
guard viewItem.canSaveMedia() else { return }
|
||||
viewItem.saveMediaAction()
|
||||
sendMediaSavedNotificationIfNeeded(with: viewItem.interaction.timestamp)
|
||||
}
|
||||
|
||||
func ban(_ viewItem: ConversationViewItem) {
|
||||
|
@ -654,7 +655,7 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
|
|||
audioSession.endAudioActivity(recordVoiceMessageActivity)
|
||||
}
|
||||
|
||||
// MARK: Screenshot Notifications
|
||||
// MARK: Data Extraction Notifications
|
||||
@objc func sendScreenshotNotificationIfNeeded() {
|
||||
guard thread is TSContactThread else { return }
|
||||
let message = DataExtractionNotification()
|
||||
|
@ -663,6 +664,15 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
|
|||
MessageSender.send(message, in: self.thread, using: transaction)
|
||||
}
|
||||
}
|
||||
|
||||
func sendMediaSavedNotificationIfNeeded(with timestamp: UInt64) {
|
||||
guard thread is TSContactThread else { return }
|
||||
let message = DataExtractionNotification()
|
||||
message.kind = .mediaSaved(timestamp: timestamp)
|
||||
Storage.write { transaction in
|
||||
MessageSender.send(message, in: self.thread, using: transaction)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Requesting Permission
|
||||
func requestCameraPermissionIfNeeded() -> Bool {
|
||||
|
|
|
@ -57,6 +57,7 @@ final class InfoMessageCell : MessageCell {
|
|||
} else {
|
||||
icon = nil
|
||||
}
|
||||
case .mediaSavedNotification: icon = UIImage(named: "ic_download")
|
||||
default: icon = nil
|
||||
}
|
||||
if let icon = icon {
|
||||
|
|
|
@ -111,8 +111,12 @@ extension MessageReceiver {
|
|||
let transaction = transaction as! YapDatabaseReadWriteTransaction
|
||||
guard message.groupPublicKey == nil,
|
||||
let thread = TSContactThread.getWithContactId(message.sender!, transaction: transaction) else { return }
|
||||
// TODO: Handle media saved type notifications
|
||||
let message = DataExtractionNotificationInfoMessage(type: .screenshotNotification, sentTimestamp: message.sentTimestamp!, thread: thread, referencedAttachmentTimestamp: nil)
|
||||
let type: TSInfoMessageType
|
||||
switch message.kind! {
|
||||
case .screenshot: type = .screenshotNotification
|
||||
case .mediaSaved: type = .mediaSavedNotification
|
||||
}
|
||||
let message = DataExtractionNotificationInfoMessage(type: type, sentTimestamp: message.sentTimestamp!, thread: thread, referencedAttachmentTimestamp: nil)
|
||||
message.save(with: transaction)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue