diff --git a/apps/ios/SimpleX NSE/NotificationService.swift b/apps/ios/SimpleX NSE/NotificationService.swift index 95050cae83..dc0af36981 100644 --- a/apps/ios/SimpleX NSE/NotificationService.swift +++ b/apps/ios/SimpleX NSE/NotificationService.swift @@ -127,7 +127,7 @@ class NotificationService: UNNotificationServiceExtension { logger.debug("NotificationService: receiveNtfMessages: apiGetNtfMessage \(String(describing: ntfMsgInfo), privacy: .public)") if let connEntity = ntfMsgInfo.connEntity { setBestAttemptNtf( - ntfMsgInfo.user.showNotifications + ntfMsgInfo.ntfsEnabled ? .nse(notification: createConnectionEventNtf(ntfMsgInfo.user, connEntity)) : .empty ) @@ -401,4 +401,8 @@ struct NtfMessages { var connEntity: ConnectionEntity? var msgTs: Date? var ntfMessages: [NtfMsgInfo] + + var ntfsEnabled: Bool { + user.showNotifications && (connEntity?.ntfsEnabled ?? false) + } } diff --git a/apps/ios/SimpleXChat/ChatTypes.swift b/apps/ios/SimpleXChat/ChatTypes.swift index 0e09d5ec8a..be8619395b 100644 --- a/apps/ios/SimpleXChat/ChatTypes.swift +++ b/apps/ios/SimpleXChat/ChatTypes.swift @@ -1466,6 +1466,8 @@ public struct SecurityCode: Decodable, Equatable { public struct UserContact: Decodable { public var userContactLinkId: Int64 +// public var connReqContact: String + public var groupId: Int64? public init(userContactLinkId: Int64) { self.userContactLinkId = userContactLinkId @@ -1927,6 +1929,16 @@ public enum ConnectionEntity: Decodable { return nil } } + + public var ntfsEnabled: Bool { + switch self { + case let .rcvDirectMsgConnection(contact): return contact?.chatSettings.enableNtfs ?? false + case let .rcvGroupMsgConnection(groupInfo, _): return groupInfo.chatSettings.enableNtfs + case .sndFileConnection: return false + case .rcvFileConnection: return false + case let .userContactConnection(userContact): return userContact.groupId == nil + } + } } public struct NtfMsgInfo: Decodable {