Merge branch '1.11.19' into voice-calls-2

pull/560/head
Ryan Zhao 4 years ago
commit cff3f4c479

@ -158,9 +158,12 @@ public class NotificationPresenter: NSObject, NotificationsProtocol {
public func notifyUser(for incomingMessage: TSIncomingMessage, in thread: TSThread, transaction: YapDatabaseReadTransaction) { public func notifyUser(for incomingMessage: TSIncomingMessage, in thread: TSThread, transaction: YapDatabaseReadTransaction) {
guard !thread.isMuted else { guard !thread.isMuted else { return }
return guard let threadId = thread.uniqueId else { return }
}
let identifier: String = incomingMessage.notificationIdentifier ?? UUID().uuidString
let isBackgroudPoll = identifier == threadId
// While batch processing, some of the necessary changes have not been commited. // While batch processing, some of the necessary changes have not been commited.
let rawMessageText = incomingMessage.previewText(with: transaction) let rawMessageText = incomingMessage.previewText(with: transaction)
@ -195,9 +198,7 @@ public class NotificationPresenter: NSObject, NotificationsProtocol {
if groupName.count < 1 { if groupName.count < 1 {
groupName = MessageStrings.newGroupDefaultTitle groupName = MessageStrings.newGroupDefaultTitle
} }
notificationTitle = String(format: NotificationStrings.incomingGroupMessageTitleFormat, notificationTitle = isBackgroudPoll ? groupName : String(format: NotificationStrings.incomingGroupMessageTitleFormat, senderName, groupName)
senderName,
groupName)
default: default:
owsFailDebug("unexpected thread: \(thread)") owsFailDebug("unexpected thread: \(thread)")
return return
@ -216,11 +217,6 @@ public class NotificationPresenter: NSObject, NotificationsProtocol {
notificationBody = NotificationStrings.incomingMessageBody notificationBody = NotificationStrings.incomingMessageBody
} }
guard let threadId = thread.uniqueId else {
owsFailDebug("threadId was unexpectedly nil")
return
}
assert((notificationBody ?? notificationTitle) != nil) assert((notificationBody ?? notificationTitle) != nil)
// Don't reply from lockscreen if anyone in this conversation is // Don't reply from lockscreen if anyone in this conversation is
@ -230,8 +226,6 @@ public class NotificationPresenter: NSObject, NotificationsProtocol {
let userInfo = [ let userInfo = [
AppNotificationUserInfoKey.threadId: threadId AppNotificationUserInfoKey.threadId: threadId
] ]
let identifier: String = incomingMessage.notificationIdentifier ?? UUID().uuidString
DispatchQueue.main.async { DispatchQueue.main.async {
notificationBody = MentionUtilities.highlightMentions(in: notificationBody!, threadID: thread.uniqueId!) notificationBody = MentionUtilities.highlightMentions(in: notificationBody!, threadID: thread.uniqueId!)
@ -252,6 +246,8 @@ public class NotificationPresenter: NSObject, NotificationsProtocol {
notificationTitle = nil notificationTitle = nil
case .nameNoPreview, .namePreview: case .nameNoPreview, .namePreview:
notificationTitle = thread.name() notificationTitle = thread.name()
default:
notificationTitle = nil
} }
let notificationBody = NotificationStrings.failedToSendBody let notificationBody = NotificationStrings.failedToSendBody

Loading…
Cancel
Save