diff --git a/Session/Conversations/ConversationVC.swift b/Session/Conversations/ConversationVC.swift index 2d8914cbb..77259ea89 100644 --- a/Session/Conversations/ConversationVC.swift +++ b/Session/Conversations/ConversationVC.swift @@ -1443,10 +1443,7 @@ final class ConversationVC: BaseVC, LibSessionRespondingViewController, Conversa ) { let currentDisappearingMessagesConfiguration: DisappearingMessagesConfiguration? = disappearingMessagesConfiguration ?? self.viewModel.threadData.disappearingMessagesConfiguration // Do not show the banner until the new disappearing messages is enabled - guard - Features.useNewDisappearingMessagesConfig && - currentDisappearingMessagesConfiguration?.isEnabled == true - else { + guard currentDisappearingMessagesConfiguration?.isEnabled == true else { self.outdatedClientBanner.isHidden = true self.emptyStateLabelTopConstraint?.constant = Values.largeSpacing return diff --git a/Session/Conversations/Settings/ThreadDisappearingMessagesSettingsViewModel.swift b/Session/Conversations/Settings/ThreadDisappearingMessagesSettingsViewModel.swift index 29c61b2e5..b9cc7dc77 100644 --- a/Session/Conversations/Settings/ThreadDisappearingMessagesSettingsViewModel.swift +++ b/Session/Conversations/Settings/ThreadDisappearingMessagesSettingsViewModel.swift @@ -87,10 +87,6 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga let title: String = "DISAPPEARING_MESSAGES".localized() lazy var subtitle: String? = { - guard Features.useNewDisappearingMessagesConfig else { - return (isNoteToSelf ? nil : "DISAPPERING_MESSAGES_SUBTITLE_LEGACY".localized()) - } - if threadVariant == .contact && !isNoteToSelf { return "DISAPPERING_MESSAGES_SUBTITLE_CONTACTS".localized() } @@ -149,34 +145,6 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga self?.currentSelection.send(updatedConfig) } ), - (Features.useNewDisappearingMessagesConfig ? nil : - SessionCell.Info( - id: "DISAPPEARING_MESSAGES_TYPE_LEGACY_TITLE".localized(), - title: "DISAPPEARING_MESSAGES_TYPE_LEGACY_TITLE".localized(), - subtitle: "DISAPPEARING_MESSAGES_TYPE_LEGACY_DESCRIPTION".localized(), - rightAccessory: .radio( - isSelected: { - (self?.currentSelection.value.isEnabled == true) && - !Features.useNewDisappearingMessagesConfig - } - ), - onTap: { - let updatedConfig: DisappearingMessagesConfiguration = { - if (config.isEnabled == true && config.type == .disappearAfterRead) { - return config - } - return currentSelection - .with( - isEnabled: true, - durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.legacy.seconds, - type: .disappearAfterRead // Default for 1-1 - ) - }() - self?.shouldShowConfirmButton.send(updatedConfig != config) - self?.currentSelection.send(updatedConfig) - } - ) - ), SessionCell.Info( id: "DISAPPERING_MESSAGES_TYPE_AFTER_READ_TITLE".localized(), title: "DISAPPERING_MESSAGES_TYPE_AFTER_READ_TITLE".localized(), @@ -184,17 +152,10 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga rightAccessory: .radio( isSelected: { (self?.currentSelection.value.isEnabled == true) && - (self?.currentSelection.value.type == .disappearAfterRead) && - Features.useNewDisappearingMessagesConfig + (self?.currentSelection.value.type == .disappearAfterRead) } ), - styling: SessionCell.StyleInfo( - tintColor: (Features.useNewDisappearingMessagesConfig ? - .textPrimary : - .disabled - ) - ), - isEnabled: Features.useNewDisappearingMessagesConfig, + styling: SessionCell.StyleInfo(tintColor: .textPrimary), accessibility: Accessibility( identifier: "Disappear after read option", label: "Disappear after read option" @@ -222,17 +183,10 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga rightAccessory: .radio( isSelected: { (self?.currentSelection.value.isEnabled == true) && - (self?.currentSelection.value.type == .disappearAfterSend) && - Features.useNewDisappearingMessagesConfig + (self?.currentSelection.value.type == .disappearAfterSend) } ), - styling: SessionCell.StyleInfo( - tintColor: (Features.useNewDisappearingMessagesConfig ? - .textPrimary : - .disabled - ) - ), - isEnabled: Features.useNewDisappearingMessagesConfig, + styling: SessionCell.StyleInfo(tintColor: .textPrimary), accessibility: Accessibility( identifier: "Disappear after send option", label: "Disappear after send option" @@ -257,17 +211,12 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga ), (currentSelection.isEnabled == false ? nil : SectionModel( - model: { - guard Features.useNewDisappearingMessagesConfig else { return .timerLegacy } - return currentSelection.type == .disappearAfterSend ? - .timerDisappearAfterSend : - .timerDisappearAfterRead - }(), + model: (currentSelection.type == .disappearAfterSend ? + .timerDisappearAfterSend : + .timerDisappearAfterRead + ), elements: DisappearingMessagesConfiguration - .validDurationsSeconds({ - guard Features.useNewDisappearingMessagesConfig else { return .disappearAfterSend } - return currentSelection.type ?? .disappearAfterSend - }()) + .validDurationsSeconds(currentSelection.type ?? .disappearAfterSend) .map { duration in let title: String = duration.formatted(format: .long) @@ -285,10 +234,7 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga label: "Time option" ), onTap: { - let updatedConfig: DisappearingMessagesConfiguration = currentSelection - .with( - durationSeconds: duration - ) + let updatedConfig: DisappearingMessagesConfiguration = currentSelection.with(durationSeconds: duration) self?.shouldShowConfirmButton.send(updatedConfig != config) self?.currentSelection.send(updatedConfig) } @@ -300,163 +246,70 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga case (.legacyGroup, _), (.group, _), (_, true): return [ - (Features.useNewDisappearingMessagesConfig ? nil : - SectionModel( - model: .type, - elements: [ - SessionCell.Info( - id: "DISAPPEARING_MESSAGES_OFF".localized(), - title: "DISAPPEARING_MESSAGES_OFF".localized(), - rightAccessory: .radio( - isSelected: { (self?.currentSelection.value.isEnabled == false) } - ), - isEnabled: ( - isNoteToSelf || - currentUserIsClosedGroupMember == true - ), - accessibility: Accessibility( - identifier: "Disable disappearing messages (Off option)", - label: "Disable disappearing messages (Off option)" - ), - onTap: { - let updatedConfig: DisappearingMessagesConfiguration = currentSelection - .with( - isEnabled: false, - durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.off.seconds - ) - self?.shouldShowConfirmButton.send(updatedConfig != config) - self?.currentSelection.send(updatedConfig) - } + SectionModel( + model: (isNoteToSelf ? .noteToSelf : .group), + elements: [ + SessionCell.Info( + id: "DISAPPEARING_MESSAGES_OFF".localized(), + title: "DISAPPEARING_MESSAGES_OFF".localized(), + rightAccessory: .radio( + isSelected: { (self?.currentSelection.value.isEnabled == false) } ), - SessionCell.Info( - id: "DISAPPEARING_MESSAGES_TYPE_LEGACY_TITLE".localized(), - title: "DISAPPEARING_MESSAGES_TYPE_LEGACY_TITLE".localized(), - subtitle: "DISAPPEARING_MESSAGES_TYPE_LEGACY_DESCRIPTION".localized(), - rightAccessory: .radio( - isSelected: { - (self?.currentSelection.value.isEnabled == true) && - !Features.useNewDisappearingMessagesConfig - } - ), - isEnabled: ( - isNoteToSelf || - currentUserIsClosedGroupMember == true - ), - onTap: { - let updatedConfig: DisappearingMessagesConfiguration = { - if (config.isEnabled == true && config.type == .disappearAfterSend) { - return config - } - return currentSelection - .with( - isEnabled: true, - durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.legacy.seconds, - type: .disappearAfterSend // Default for closed group & note to self - ) - }() - self?.shouldShowConfirmButton.send(updatedConfig != config) - self?.currentSelection.send(updatedConfig) - } + isEnabled: ( + isNoteToSelf || + currentUserIsClosedGroupAdmin == true ), - SessionCell.Info( - id: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized(), - title: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized(), - subtitle: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_DESCRIPTION".localized(), - rightAccessory: .radio(isSelected: { false }), - styling: SessionCell.StyleInfo(tintColor: .disabled), - isEnabled: false - ) - ] - ) - ), - (!Features.useNewDisappearingMessagesConfig && currentSelection.isEnabled == false ? nil : - SectionModel( - model: { - guard Features.useNewDisappearingMessagesConfig else { - return (currentSelection.type == .disappearAfterSend ? - .timerDisappearAfterSend : - .timerDisappearAfterRead - ) + accessibility: Accessibility( + identifier: "Disable disappearing messages (Off option)", + label: "Disable disappearing messages (Off option)" + ), + onTap: { + let updatedConfig: DisappearingMessagesConfiguration = currentSelection + .with( + isEnabled: false, + durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.off.seconds + ) + self?.shouldShowConfirmButton.send(updatedConfig != config) + self?.currentSelection.send(updatedConfig) } + ) + ] + .compactMap { $0 } + .appending( + contentsOf: DisappearingMessagesConfiguration + .validDurationsSeconds(.disappearAfterSend) + .map { duration in + let title: String = duration.formatted(format: .long) - return (isNoteToSelf ? .noteToSelf : .group) - }(), - elements: [ - (!Features.useNewDisappearingMessagesConfig ? nil : - SessionCell.Info( - id: "DISAPPEARING_MESSAGES_OFF".localized(), - title: "DISAPPEARING_MESSAGES_OFF".localized(), + return SessionCell.Info( + id: title, + title: title, rightAccessory: .radio( - isSelected: { (self?.currentSelection.value.isEnabled == false) } - ), - isEnabled: ( - isNoteToSelf || - currentUserIsClosedGroupAdmin == true + isSelected: { + (self?.currentSelection.value.isEnabled == true) && + (self?.currentSelection.value.durationSeconds == duration) + } ), + isEnabled: (isNoteToSelf || currentUserIsClosedGroupAdmin == true), accessibility: Accessibility( - identifier: "Disable disappearing messages (Off option)", - label: "Disable disappearing messages (Off option)" + identifier: "Time option", + label: "Time option" ), onTap: { + // If the new disappearing messages config feature flag isn't + // enabled then the 'isEnabled' and 'type' values are set via + // the first section so pass `nil` values to keep the existing + // setting let updatedConfig: DisappearingMessagesConfiguration = currentSelection .with( - isEnabled: false, - durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.off.seconds + durationSeconds: duration, + type: .disappearAfterSend ) self?.shouldShowConfirmButton.send(updatedConfig != config) self?.currentSelection.send(updatedConfig) } ) - ) - ] - .compactMap { $0 } - .appending( - contentsOf: DisappearingMessagesConfiguration - .validDurationsSeconds(.disappearAfterSend) - .map { duration in - let title: String = duration.formatted(format: .long) - - return SessionCell.Info( - id: title, - title: title, - rightAccessory: .radio( - isSelected: { - (self?.currentSelection.value.isEnabled == true) && - (self?.currentSelection.value.durationSeconds == duration) - } - ), - isEnabled: ( - isNoteToSelf || - (currentUserIsClosedGroupMember == true && !Features.useNewDisappearingMessagesConfig) || - currentUserIsClosedGroupAdmin == true - ), - accessibility: Accessibility( - identifier: "Time option", - label: "Time option" - ), - onTap: { - // If the new disappearing messages config feature flag isn't - // enabled then the 'isEnabled' and 'type' values are set via - // the first section so pass `nil` values to keep the existing - // setting - let updatedConfig: DisappearingMessagesConfiguration = currentSelection - .with( - isEnabled: (Features.useNewDisappearingMessagesConfig ? - true : - nil - ), - durationSeconds: duration, - type: (Features.useNewDisappearingMessagesConfig ? - .disappearAfterSend : - nil - ) - ) - self?.shouldShowConfirmButton.send(updatedConfig != config) - self?.currentSelection.send(updatedConfig) - } - ) - } - ) + } ) ) ].compactMap { $0 } @@ -487,15 +340,10 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga serverHash: nil, serverExpirationTimestamp: nil ) - - let duration: UInt32? = { - guard !Features.useNewDisappearingMessagesConfig else { return nil } - return UInt32(floor(updatedConfig.isEnabled ? updatedConfig.durationSeconds : 0)) - }() let expirationTimerUpdateMessage: ExpirationTimerUpdate = ExpirationTimerUpdate( syncTarget: nil, - duration: duration + duration: nil ) .with(sentTimestamp: UInt64(currentTimestampMs)) .with(updatedConfig) diff --git a/Session/Conversations/Settings/ThreadSettingsViewModel.swift b/Session/Conversations/Settings/ThreadSettingsViewModel.swift index d8be4b9f0..ad08b0521 100644 --- a/Session/Conversations/Settings/ThreadSettingsViewModel.swift +++ b/Session/Conversations/Settings/ThreadSettingsViewModel.swift @@ -452,12 +452,6 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi guard current.disappearingMessagesConfig.isEnabled else { return "DISAPPEARING_MESSAGES_SUBTITLE_OFF".localized() } - guard Features.useNewDisappearingMessagesConfig else { - return String( - format: "DISAPPEARING_MESSAGES_SUBTITLE_DISAPPEAR_AFTER_LEGACY".localized(), - current.disappearingMessagesConfig.durationString - ) - } return String( format: (current.disappearingMessagesConfig.type == .disappearAfterRead ? diff --git a/Session/Conversations/Views & Modals/ConversationTitleView.swift b/Session/Conversations/Views & Modals/ConversationTitleView.swift index 806114752..068dd6fce 100644 --- a/Session/Conversations/Views & Modals/ConversationTitleView.swift +++ b/Session/Conversations/Views & Modals/ConversationTitleView.swift @@ -228,26 +228,15 @@ final class ConversationTitleView: UIView { height: Values.miniFontSize ) - let disappearingMessageSettingLabelString: NSAttributedString = { - guard Features.useNewDisappearingMessagesConfig else { - return NSAttributedString(attachment: imageAttachment) - .appending(string: " ") - .appending(string: String( - format: "DISAPPERING_MESSAGES_SUMMARY_LEGACY".localized(), - floor(config.durationSeconds).formatted(format: .short) - )) - } - - return NSAttributedString(attachment: imageAttachment) - .appending(string: " ") - .appending(string: String( - format: (config.type == .disappearAfterRead ? - "DISAPPERING_MESSAGES_SUMMARY_READ".localized() : - "DISAPPERING_MESSAGES_SUMMARY_SEND".localized() - ), - floor(config.durationSeconds).formatted(format: .short) - )) - }() + let disappearingMessageSettingLabelString: NSAttributedString = NSAttributedString(attachment: imageAttachment) + .appending(string: " ") + .appending(string: String( + format: (config.type == .disappearAfterRead ? + "DISAPPERING_MESSAGES_SUMMARY_READ".localized() : + "DISAPPERING_MESSAGES_SUMMARY_SEND".localized() + ), + floor(config.durationSeconds).formatted(format: .short) + )) labelInfos.append( SessionLabelCarouselView.LabelInfo( diff --git a/SessionMessagingKit/Database/Models/DisappearingMessageConfiguration.swift b/SessionMessagingKit/Database/Models/DisappearingMessageConfiguration.swift index 24361408f..be24cd43c 100644 --- a/SessionMessagingKit/Database/Models/DisappearingMessageConfiguration.swift +++ b/SessionMessagingKit/Database/Models/DisappearingMessageConfiguration.swift @@ -133,8 +133,6 @@ public extension DisappearingMessagesConfiguration { public let type: DisappearingMessageType? var previewText: String { - guard Features.useNewDisappearingMessagesConfig && self.threadVariant != nil else { return legacyPreviewText } - guard let senderName: String = senderName else { guard isEnabled, durationSeconds > 0 else { return "YOU_DISAPPEARING_MESSAGES_INFO_DISABLE".localized() @@ -158,28 +156,6 @@ public extension DisappearingMessagesConfiguration { (type == .disappearAfterRead ? "DISAPPEARING_MESSAGE_STATE_READ".localized() : "DISAPPEARING_MESSAGE_STATE_SENT".localized()) ) } - - private var legacyPreviewText: String { - guard let senderName: String = senderName else { - // Changed by this device or via synced transcript - guard isEnabled, durationSeconds > 0 else { return "YOU_DISABLED_DISAPPEARING_MESSAGES_CONFIGURATION".localized() } - - return String( - format: "YOU_UPDATED_DISAPPEARING_MESSAGES_CONFIGURATION".localized(), - floor(durationSeconds).formatted(format: .long) - ) - } - - guard isEnabled, durationSeconds > 0 else { - return String(format: "OTHER_DISABLED_DISAPPEARING_MESSAGES_CONFIGURATION".localized(), senderName) - } - - return String( - format: "OTHER_UPDATED_DISAPPEARING_MESSAGES_CONFIGURATION".localized(), - senderName, - floor(durationSeconds).formatted(format: .long) - ) - } } var durationString: String { @@ -267,22 +243,20 @@ public extension DisappearingMessagesConfiguration { serverExpirationTimestamp: TimeInterval?, using dependencies: Dependencies = Dependencies() ) throws -> Int64? { - if Features.useNewDisappearingMessagesConfig { - switch threadVariant { - case .contact: - _ = try Interaction - .filter(Interaction.Columns.threadId == threadId) - .filter(Interaction.Columns.variant == Interaction.Variant.infoDisappearingMessagesUpdate) - .filter(Interaction.Columns.authorId == authorId) - .deleteAll(db) - case .legacyGroup: - _ = try Interaction - .filter(Interaction.Columns.threadId == threadId) - .filter(Interaction.Columns.variant == Interaction.Variant.infoDisappearingMessagesUpdate) - .deleteAll(db) - default: - break - } + switch threadVariant { + case .contact: + _ = try Interaction + .filter(Interaction.Columns.threadId == threadId) + .filter(Interaction.Columns.variant == Interaction.Variant.infoDisappearingMessagesUpdate) + .filter(Interaction.Columns.authorId == authorId) + .deleteAll(db) + case .legacyGroup: + _ = try Interaction + .filter(Interaction.Columns.threadId == threadId) + .filter(Interaction.Columns.variant == Interaction.Variant.infoDisappearingMessagesUpdate) + .deleteAll(db) + default: + break } let currentUserPublicKey: String = getUserHexEncodedPublicKey(db, using: dependencies) diff --git a/SessionMessagingKit/LibSession/Config Handling/LibSession+Contacts.swift b/SessionMessagingKit/LibSession/Config Handling/LibSession+Contacts.swift index 0998c57dc..d5a6515f5 100644 --- a/SessionMessagingKit/LibSession/Config Handling/LibSession+Contacts.swift +++ b/SessionMessagingKit/LibSession/Config Handling/LibSession+Contacts.swift @@ -179,9 +179,7 @@ internal extension LibSession { .fetchOne(db, id: sessionId) .defaulting(to: DisappearingMessagesConfiguration.defaultWith(sessionId)) - let isValid: Bool = Features.useNewDisappearingMessagesConfig ? data.config.isValidV2Config() : true - - if isValid && data.config != localConfig { + if data.config.isValidV2Config() && data.config != localConfig { try data.config .saved(db) .clearUnrelatedControlMessages( diff --git a/SessionMessagingKit/Messages/Control Messages/ExpirationTimerUpdate.swift b/SessionMessagingKit/Messages/Control Messages/ExpirationTimerUpdate.swift index f959909ac..ef78d81eb 100644 --- a/SessionMessagingKit/Messages/Control Messages/ExpirationTimerUpdate.swift +++ b/SessionMessagingKit/Messages/Control Messages/ExpirationTimerUpdate.swift @@ -27,14 +27,6 @@ public final class ExpirationTimerUpdate: ControlMessage { self.syncTarget = syncTarget self.duration = duration } - - // MARK: - Validation - - public override var isValid: Bool { - guard super.isValid else { return false } - - return (duration != nil || Features.useNewDisappearingMessagesConfig) - } // MARK: - Codable diff --git a/SessionMessagingKit/Messages/Message.swift b/SessionMessagingKit/Messages/Message.swift index 55d25d5c7..e1ea05797 100644 --- a/SessionMessagingKit/Messages/Message.swift +++ b/SessionMessagingKit/Messages/Message.swift @@ -630,7 +630,8 @@ public extension Message { message: Message, destination: Message.Destination ) -> UInt64 { - guard Features.useNewDisappearingMessagesConfig else { return message.ttl } + // Not disappearing messages + guard let expiresInSeconds = message.expiresInSeconds else { return message.ttl } switch (destination, message) { // Disappear after sent messages with exceptions diff --git a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+ExpirationTimers.swift b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+ExpirationTimers.swift index 216ba8c08..3be0818ad 100644 --- a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+ExpirationTimers.swift +++ b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+ExpirationTimers.swift @@ -6,132 +6,6 @@ import SessionUIKit import SessionUtilitiesKit extension MessageReceiver { - // TODO: Remove this when disappearing messages V2 is up and running - internal static func handleExpirationTimerUpdate( - _ db: Database, - threadId: String, - threadVariant: SessionThread.Variant, - message: ExpirationTimerUpdate - ) throws { - guard !Features.useNewDisappearingMessagesConfig else { return } - guard - // Only process these for contact and legacy groups (new groups handle it separately) - (threadVariant == .contact || threadVariant == .legacyGroup), - let sender: String = message.sender - else { throw MessageReceiverError.invalidMessage } - - // Generate an updated configuration - // - // Note: Messages which had been sent during the previous configuration will still - // use it's settings (so if you enable, send a message and then disable disappearing - // message then the message you had sent will still disappear) - let maybeDefaultType: DisappearingMessagesConfiguration.DisappearingMessageType? = { - switch (threadVariant, threadId == getUserHexEncodedPublicKey(db)) { - case (.contact, false): return .disappearAfterRead - case (.legacyGroup, _), (.group, _), (_, true): return .disappearAfterSend - case (.community, _): return nil // Shouldn't happen - } - }() - - guard let defaultType: DisappearingMessagesConfiguration.DisappearingMessageType = maybeDefaultType else { return } - - let defaultDuration: DisappearingMessagesConfiguration.DefaultDuration = { - switch defaultType { - case .unknown: return .unknown - case .disappearAfterRead: return .disappearAfterRead - case .disappearAfterSend: return .disappearAfterSend - } - }() - - let localConfig: DisappearingMessagesConfiguration = try DisappearingMessagesConfiguration - .filter(id: threadId) - .fetchOne(db) - .defaulting(to: DisappearingMessagesConfiguration.defaultWith(threadId)) - - let updatedConfig: DisappearingMessagesConfiguration = localConfig.with( - // If there is no duration then we should disable the expiration timer - isEnabled: ((message.duration ?? 0) > 0), - durationSeconds: ( - message.duration.map { TimeInterval($0) } ?? - defaultDuration.seconds - ), - type: defaultType - ) - - let timestampMs: Int64 = Int64(message.sentTimestamp ?? 0) // Default to `0` if not set - - // Only actually make the change if LibSession says we can (we always want to insert the info - // message though) - let canPerformChange: Bool = LibSession.canPerformChange( - db, - threadId: threadId, - targetConfig: { - switch threadVariant { - case .contact: - let currentUserPublicKey: String = getUserHexEncodedPublicKey(db) - - return (threadId == currentUserPublicKey ? .userProfile : .contacts) - - default: return .userGroups - } - }(), - changeTimestampMs: timestampMs - ) - - // Only update libSession if we can perform the change - if canPerformChange { - // Contacts & legacy closed groups need to update the LibSession - switch threadVariant { - case .contact: - try LibSession - .update( - db, - sessionId: threadId, - disappearingMessagesConfig: updatedConfig - ) - - case .legacyGroup: - try LibSession - .update( - db, - groupPublicKey: threadId, - disappearingConfig: updatedConfig - ) - - default: break - } - } - - // Only save the updated config if we can perform the change - if canPerformChange { - // Finally save the changes to the DisappearingMessagesConfiguration (If it's a duplicate - // then the interaction unique constraint will prevent the code from getting here) - try updatedConfig.save(db) - } - - // Add an info message for the user - let currentUserPublicKey: String = getUserHexEncodedPublicKey(db) - _ = try Interaction( - serverHash: nil, // Intentionally null so sync messages are seen as duplicates - threadId: threadId, - threadVariant: threadVariant, - authorId: sender, - variant: .infoDisappearingMessagesUpdate, - body: updatedConfig.messageInfoString( - threadVariant: threadVariant, - senderName: (sender != currentUserPublicKey ? Profile.displayName(db, id: sender) : nil) - ), - timestampMs: timestampMs, - wasRead: LibSession.timestampAlreadyRead( - threadId: threadId, - threadVariant: threadVariant, - timestampMs: (timestampMs * 1000), - userPublicKey: currentUserPublicKey, - openGroup: nil - ) - ).inserted(db) - } - internal static func handleExpirationTimerUpdate( _ db: Database, threadId: String, @@ -144,8 +18,7 @@ extension MessageReceiver { guard threadVariant != .community, let sender: String = message.sender, - let timestampMs: UInt64 = message.sentTimestamp, - Features.useNewDisappearingMessagesConfig + let timestampMs: UInt64 = message.sentTimestamp else { return } let localConfig: DisappearingMessagesConfiguration = try DisappearingMessagesConfiguration @@ -227,8 +100,6 @@ extension MessageReceiver { Contact.Columns.lastKnownClientVersion.set(to: version) ) - guard Features.useNewDisappearingMessagesConfig else { return } - if contactId == getUserHexEncodedPublicKey(db) { switch version { case .legacyDisappearingMessages: diff --git a/SessionMessagingKit/Sending & Receiving/MessageReceiver.swift b/SessionMessagingKit/Sending & Receiving/MessageReceiver.swift index cc30cf899..39a68e754 100644 --- a/SessionMessagingKit/Sending & Receiving/MessageReceiver.swift +++ b/SessionMessagingKit/Sending & Receiving/MessageReceiver.swift @@ -283,13 +283,6 @@ public enum MessageReceiver { ) case let message as ExpirationTimerUpdate: - try MessageReceiver.handleExpirationTimerUpdate( - db, - threadId: threadId, - threadVariant: threadVariant, - message: message - ) - try MessageReceiver.handleExpirationTimerUpdate( db, threadId: threadId, diff --git a/SessionUtilitiesKit/General/Features.swift b/SessionUtilitiesKit/General/Features.swift index 611fda892..d3175a8d6 100644 --- a/SessionUtilitiesKit/General/Features.swift +++ b/SessionUtilitiesKit/General/Features.swift @@ -4,5 +4,4 @@ import Foundation public final class Features { public static let useTestnet: Bool = false - public static let useNewDisappearingMessagesConfig: Bool = Date().timeIntervalSince1970 > 1710284400 }