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