From 15aaa8332db3e854ad87b895fcbc6a9917d837fb Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 18 Dec 2024 16:59:20 +1100 Subject: [PATCH 1/2] Fixed an issue where shared messages and community invites wouldn't disappear --- .../Settings/ThreadSettingsViewModel.swift | 15 ++++++++------- Session/Notifications/AppNotifications.swift | 11 +++++++++-- SessionShareExtension/ThreadPickerVC.swift | 9 ++++++++- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Session/Conversations/Settings/ThreadSettingsViewModel.swift b/Session/Conversations/Settings/ThreadSettingsViewModel.swift index 49ce12702..73ce37bdd 100644 --- a/Session/Conversations/Settings/ThreadSettingsViewModel.swift +++ b/Session/Conversations/Settings/ThreadSettingsViewModel.swift @@ -792,18 +792,19 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi ) .save(db) + let sentTimestampMs: Int64 = SnodeAPI.currentOffsetTimestampMs() + let destinationDisappearingMessagesConfiguration: DisappearingMessagesConfiguration? = try? DisappearingMessagesConfiguration + .filter(id: userId) + .filter(DisappearingMessagesConfiguration.Columns.isEnabled == true) + .fetchOne(db) let interaction: Interaction = try Interaction( threadId: thread.id, threadVariant: thread.variant, authorId: currentUserSessionId, variant: .standardOutgoing, - timestampMs: SnodeAPI.currentOffsetTimestampMs(), - expiresInSeconds: try? DisappearingMessagesConfiguration - .select(.durationSeconds) - .filter(id: userId) - .filter(DisappearingMessagesConfiguration.Columns.isEnabled == true) - .asRequest(of: TimeInterval.self) - .fetchOne(db), + timestampMs: sentTimestampMs, + expiresInSeconds: destinationDisappearingMessagesConfiguration?.durationSeconds, + expiresStartedAtMs: (destinationDisappearingMessagesConfiguration?.type == .disappearAfterSend ? Double(sentTimestampMs) : nil), linkPreviewUrl: communityUrl ) .inserted(db) diff --git a/Session/Notifications/AppNotifications.swift b/Session/Notifications/AppNotifications.swift index 1e60c809e..1402d38e9 100644 --- a/Session/Notifications/AppNotifications.swift +++ b/Session/Notifications/AppNotifications.swift @@ -512,14 +512,21 @@ class NotificationActionHandler { return Storage.shared .writePublisher { db in + let sentTimestampMs: Int64 = SnodeAPI.currentOffsetTimestampMs() + let destinationDisappearingMessagesConfiguration: DisappearingMessagesConfiguration? = try? DisappearingMessagesConfiguration + .filter(id: threadId) + .filter(DisappearingMessagesConfiguration.Columns.isEnabled == true) + .fetchOne(db) let interaction: Interaction = try Interaction( threadId: threadId, threadVariant: thread.variant, authorId: getUserHexEncodedPublicKey(db), variant: .standardOutgoing, body: replyText, - timestampMs: SnodeAPI.currentOffsetTimestampMs(), - hasMention: Interaction.isUserMentioned(db, threadId: threadId, body: replyText) + timestampMs: sentTimestampMs, + hasMention: Interaction.isUserMentioned(db, threadId: threadId, body: replyText), + expiresInSeconds: destinationDisappearingMessagesConfiguration?.durationSeconds, + expiresStartedAtMs: (destinationDisappearingMessagesConfiguration?.type == .disappearAfterSend ? Double(sentTimestampMs) : nil) ).inserted(db) try Interaction.markAsRead( diff --git a/SessionShareExtension/ThreadPickerVC.swift b/SessionShareExtension/ThreadPickerVC.swift index 8c9e9add1..18e686e68 100644 --- a/SessionShareExtension/ThreadPickerVC.swift +++ b/SessionShareExtension/ThreadPickerVC.swift @@ -280,14 +280,21 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView } // Create the interaction + let sentTimestampMs: Int64 = SnodeAPI.currentOffsetTimestampMs() + let destinationDisappearingMessagesConfiguration: DisappearingMessagesConfiguration? = try? DisappearingMessagesConfiguration + .filter(id: threadId) + .filter(DisappearingMessagesConfiguration.Columns.isEnabled == true) + .fetchOne(db) let interaction: Interaction = try Interaction( threadId: threadId, threadVariant: threadVariant, authorId: getUserHexEncodedPublicKey(db), variant: .standardOutgoing, body: body, - timestampMs: SnodeAPI.currentOffsetTimestampMs(), + timestampMs: sentTimestampMs, hasMention: Interaction.isUserMentioned(db, threadId: threadId, body: body), + expiresInSeconds: destinationDisappearingMessagesConfiguration?.durationSeconds, + expiresStartedAtMs: (destinationDisappearingMessagesConfiguration?.type == .disappearAfterSend ? Double(sentTimestampMs) : nil), linkPreviewUrl: (isSharingUrl ? attachments.first?.linkPreviewDraft?.urlString : nil) ).inserted(db) From ba1664f71fc8073f9338a4233029cb16f5b43986 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 18 Dec 2024 16:59:43 +1100 Subject: [PATCH 2/2] Updated version number --- Session.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 1e0ac6e22..427f6b665 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -7677,7 +7677,7 @@ CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 516; + CURRENT_PROJECT_VERSION = 517; ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -7756,7 +7756,7 @@ CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "iPhone Distribution"; - CURRENT_PROJECT_VERSION = 516; + CURRENT_PROJECT_VERSION = 517; ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_NO_COMMON_BLOCKS = YES;