diff --git a/DcNotificationService/NotificationService.swift b/DcNotificationService/NotificationService.swift index b02015643..6f4d18dec 100644 --- a/DcNotificationService/NotificationService.swift +++ b/DcNotificationService/NotificationService.swift @@ -54,22 +54,24 @@ class NotificationService: UNNotificationServiceExtension { if event.id == DC_EVENT_INCOMING_MSG { let dcContext = dcAccounts.get(id: event.accountId) let chat = dcContext.getChat(chatId: event.data1Int) - if !dcContext.isMuted() && !chat.isMuted { + if !dcContext.isMuted() { let msg = dcContext.getMessage(id: event.data2Int) - let sender = msg.getSenderName(dcContext.getContact(id: msg.fromContactId)) - if chat.isGroup { - bestAttemptContent.title = chat.name - bestAttemptContent.body = "\(sender): " + (msg.summary(chars: 80) ?? "") - } else { - bestAttemptContent.title = sender - bestAttemptContent.body = msg.summary(chars: 80) ?? "" - } - bestAttemptContent.userInfo["account_id"] = dcContext.id - bestAttemptContent.userInfo["chat_id"] = chat.id - bestAttemptContent.userInfo["message_id"] = msg.id + if !chat.isMuted || (chat.isGroup && msg.isReplyToSelf && dcContext.isMentionsEnabled) { + let sender = msg.getSenderName(dcContext.getContact(id: msg.fromContactId)) + if chat.isGroup { + bestAttemptContent.title = chat.name + bestAttemptContent.body = "\(sender): " + (msg.summary(chars: 80) ?? "") + } else { + bestAttemptContent.title = sender + bestAttemptContent.body = msg.summary(chars: 80) ?? "" + } + bestAttemptContent.userInfo["account_id"] = dcContext.id + bestAttemptContent.userInfo["chat_id"] = chat.id + bestAttemptContent.userInfo["message_id"] = msg.id - uniqueChats["\(dcContext.id)-\(chat.id)"] = bestAttemptContent.title - messageCount += 1 + uniqueChats["\(dcContext.id)-\(chat.id)"] = bestAttemptContent.title + messageCount += 1 + } } } else if event.id == DC_EVENT_INCOMING_REACTION { let dcContext = dcAccounts.get(id: event.accountId) diff --git a/deltachat-ios/DC/DcMsg.swift b/deltachat-ios/DC/DcMsg.swift index 1ab0bc125..99460180e 100644 --- a/deltachat-ios/DC/DcMsg.swift +++ b/deltachat-ios/DC/DcMsg.swift @@ -111,6 +111,14 @@ public class DcMsg { } } + public var isReplyToSelf: Bool { + if let quoteMessage { + return quoteMessage.isFromCurrentSender + } else { + return false + } + } + public var parent: DcMsg? { guard let msgpointer = dc_msg_get_parent(messagePointer) else { return nil } return DcMsg(pointer: msgpointer) diff --git a/deltachat-ios/Helper/NotificationManager.swift b/deltachat-ios/Helper/NotificationManager.swift index b73376319..86f582cdd 100644 --- a/deltachat-ios/Helper/NotificationManager.swift +++ b/deltachat-ios/Helper/NotificationManager.swift @@ -100,9 +100,9 @@ public class NotificationManager { !eventContext.isMuted() { let chat = eventContext.getChat(chatId: chatId) + let msg = eventContext.getMessage(id: messageId) - if !chat.isMuted { - let msg = eventContext.getMessage(id: messageId) + if !chat.isMuted || (chat.isGroup && msg.isReplyToSelf && eventContext.isMentionsEnabled) { let fromContact = eventContext.getContact(id: msg.fromContactId) let sender = msg.getSenderName(fromContact) let content = UNMutableNotificationContent()