From 0a9856d49a0794e942024d30a682f58335335372 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Wed, 17 Aug 2022 16:41:01 +1000 Subject: [PATCH] tweak: fix reaction notifications --- Session.xcodeproj/project.pbxproj | 16 ++++++++-------- Session/Emoji/EmojiWithSkinTones.swift | 2 +- .../Database/Models/Interaction.swift | 2 +- .../MessageReceiver+VisibleMessages.swift | 17 ++++++++++++----- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 287f94a6b..8b7d37a4b 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -5782,7 +5782,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 348; + CURRENT_PROJECT_VERSION = 369; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -5807,7 +5807,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.13.0; + MARKETING_VERSION = 2.0.2; MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.ShareExtension"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -5855,7 +5855,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 348; + CURRENT_PROJECT_VERSION = 369; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -5885,7 +5885,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.13.0; + MARKETING_VERSION = 2.0.2; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.ShareExtension"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -5921,7 +5921,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 348; + CURRENT_PROJECT_VERSION = 369; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -5944,7 +5944,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.13.0; + MARKETING_VERSION = 2.0.2; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.NotificationServiceExtension"; @@ -5995,7 +5995,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 348; + CURRENT_PROJECT_VERSION = 369; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -6023,7 +6023,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.13.0; + MARKETING_VERSION = 2.0.2; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.NotificationServiceExtension"; diff --git a/Session/Emoji/EmojiWithSkinTones.swift b/Session/Emoji/EmojiWithSkinTones.swift index d8b7d1283..44fd4e8a3 100644 --- a/Session/Emoji/EmojiWithSkinTones.swift +++ b/Session/Emoji/EmojiWithSkinTones.swift @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Open Whisper Systems. All rights reserved. +// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved. import Foundation import GRDB diff --git a/SessionMessagingKit/Database/Models/Interaction.swift b/SessionMessagingKit/Database/Models/Interaction.swift index d94708b0d..ccd696ad9 100644 --- a/SessionMessagingKit/Database/Models/Interaction.swift +++ b/SessionMessagingKit/Database/Models/Interaction.swift @@ -582,7 +582,7 @@ public extension Interaction { func notificationIdentifier(isBackgroundPoll: Bool) -> String { // When the app is in the background we want the notifications to be grouped to prevent spam - guard isBackgroundPoll else { return threadId } + guard !isBackgroundPoll else { return threadId } return "\(threadId)-\(id ?? 0)" } diff --git a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+VisibleMessages.swift b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+VisibleMessages.swift index b028be09d..8183a21b2 100644 --- a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+VisibleMessages.swift +++ b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+VisibleMessages.swift @@ -89,7 +89,7 @@ extension MessageReceiver { }() // Handle emoji reacts first (otherwise it's essentially an invalid message) - if let interactionId: Int64 = try handleEmojiReactIfNeeded(db, message: message, associatedWithProto: proto, sender: sender, messageSentTimestamp: messageSentTimestamp, openGroupId: openGroupId, threadId: threadInfo.id) { + if let interactionId: Int64 = try handleEmojiReactIfNeeded(db, message: message, associatedWithProto: proto, sender: sender, messageSentTimestamp: messageSentTimestamp, openGroupId: openGroupId, thread: thread) { return interactionId } @@ -304,7 +304,7 @@ extension MessageReceiver { sender: String, messageSentTimestamp: TimeInterval, openGroupId: String?, - threadId: String + thread: SessionThread ) throws -> Int64? { guard let reaction: VisibleMessage.VMReaction = message.reaction, @@ -313,7 +313,7 @@ extension MessageReceiver { let maybeInteractionId: Int64? = try? Interaction .select(.id) - .filter(Interaction.Columns.threadId == threadId) + .filter(Interaction.Columns.threadId == thread.id) .filter(Interaction.Columns.timestampMs == reaction.timestamp) .filter(Interaction.Columns.authorId == reaction.publicKey) .filter(Interaction.Columns.variant != Interaction.Variant.standardIncomingDeleted) @@ -332,7 +332,7 @@ extension MessageReceiver { switch reaction.kind { case .react: - try Reaction( + let reaction = Reaction( interactionId: interactionId, serverHash: message.serverHash, timestampMs: Int64(messageSentTimestamp * 1000), @@ -340,7 +340,14 @@ extension MessageReceiver { emoji: reaction.emoji, count: 1, sortId: sortId - ).insert(db) + ) + try reaction.insert(db) + Environment.shared?.notificationsManager.wrappedValue? + .notifyUser( + db, + forReaction: reaction, + in: thread + ) case .remove: try Reaction