ios: only show "entity" notifications if the are enabled in the conversation (#2899)

This commit is contained in:
Evgeny Poberezkin 2023-08-11 16:55:00 +01:00 committed by GitHub
parent 1bc880877d
commit 42324b515d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -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)
}
}

View File

@ -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 {