From d4d7f6c72c130bc03260c0d4a82a1285217c90a5 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Mon, 14 Nov 2022 13:35:59 +1100 Subject: [PATCH] clean --- .../ClosedGroupControlMessage.swift | 2 +- .../Control Messages/TypingIndicator.swift | 2 +- SessionMessagingKit/Messages/Message.swift | 9 ++------ .../Visible Messages/VisibleMessage.swift | 21 +++---------------- 4 files changed, 7 insertions(+), 27 deletions(-) diff --git a/SessionMessagingKit/Messages/Control Messages/ClosedGroupControlMessage.swift b/SessionMessagingKit/Messages/Control Messages/ClosedGroupControlMessage.swift index 26e9d2588..c22b19d88 100644 --- a/SessionMessagingKit/Messages/Control Messages/ClosedGroupControlMessage.swift +++ b/SessionMessagingKit/Messages/Control Messages/ClosedGroupControlMessage.swift @@ -13,7 +13,7 @@ public final class ClosedGroupControlMessage: ControlMessage { public var kind: Kind? - public override var defaultTtl: UInt64 { + public override var ttl: UInt64 { switch kind { case .encryptionKeyPair: return 14 * 24 * 60 * 60 * 1000 default: return 14 * 24 * 60 * 60 * 1000 diff --git a/SessionMessagingKit/Messages/Control Messages/TypingIndicator.swift b/SessionMessagingKit/Messages/Control Messages/TypingIndicator.swift index ca7f5e965..9d34dd18e 100644 --- a/SessionMessagingKit/Messages/Control Messages/TypingIndicator.swift +++ b/SessionMessagingKit/Messages/Control Messages/TypingIndicator.swift @@ -11,7 +11,7 @@ public final class TypingIndicator: ControlMessage { public var kind: Kind? - public override var defaultTtl: UInt64 { 20 * 1000 } + public override var ttl: UInt64 { 20 * 1000 } // MARK: - Kind diff --git a/SessionMessagingKit/Messages/Message.swift b/SessionMessagingKit/Messages/Message.swift index ab6111217..c42eb56f1 100644 --- a/SessionMessagingKit/Messages/Message.swift +++ b/SessionMessagingKit/Messages/Message.swift @@ -16,10 +16,7 @@ public class Message: Codable { public var groupPublicKey: String? public var openGroupServerMessageId: UInt64? public var serverHash: String? - - public var specifiedTtl: UInt64? - public var ttl: UInt64 { specifiedTtl ?? defaultTtl } - public var defaultTtl: UInt64 { 14 * 24 * 60 * 60 * 1000 } + public var ttl: UInt64 { 14 * 24 * 60 * 60 * 1000 } public var isSelfSendValid: Bool { false } public var shouldBeRetryable: Bool { false } @@ -43,8 +40,7 @@ public class Message: Codable { sender: String? = nil, groupPublicKey: String? = nil, openGroupServerMessageId: UInt64? = nil, - serverHash: String? = nil, - specifiedTtl: UInt64? = nil + serverHash: String? = nil ) { self.id = id self.threadId = threadId @@ -55,7 +51,6 @@ public class Message: Codable { self.groupPublicKey = groupPublicKey self.openGroupServerMessageId = openGroupServerMessageId self.serverHash = serverHash - self.specifiedTtl = specifiedTtl } // MARK: - Proto Conversion diff --git a/SessionMessagingKit/Messages/Visible Messages/VisibleMessage.swift b/SessionMessagingKit/Messages/Visible Messages/VisibleMessage.swift index bd436359a..4ceed772f 100644 --- a/SessionMessagingKit/Messages/Visible Messages/VisibleMessage.swift +++ b/SessionMessagingKit/Messages/Visible Messages/VisibleMessage.swift @@ -54,8 +54,7 @@ public final class VisibleMessage: Message { linkPreview: VMLinkPreview? = nil, profile: VMProfile? = nil, openGroupInvitation: VMOpenGroupInvitation? = nil, - reaction: VMReaction? = nil, - specifiedTtl: UInt64? = nil + reaction: VMReaction? = nil ) { self.syncTarget = syncTarget self.text = text @@ -69,8 +68,7 @@ public final class VisibleMessage: Message { super.init( sentTimestamp: sentTimestamp, recipient: recipient, - groupPublicKey: groupPublicKey, - specifiedTtl: specifiedTtl + groupPublicKey: groupPublicKey ) } @@ -237,18 +235,6 @@ public extension VisibleMessage { static func from(_ db: Database, interaction: Interaction) -> VisibleMessage { let linkPreview: LinkPreview? = try? interaction.linkPreview.fetchOne(db) - let specifiedTtl: UInt64? = { - guard - let disappearingMessagesConfiguration = try? DisappearingMessagesConfiguration.fetchOne(db, id: interaction.threadId), - disappearingMessagesConfiguration.isEnabled, - disappearingMessagesConfiguration.type == .disappearAfterSend - else { - return nil - } - - return UInt64(disappearingMessagesConfiguration.durationSeconds) * 1000 - }() - return VisibleMessage( sentTimestamp: UInt64(interaction.timestampMs), recipient: (try? interaction.recipientStates.fetchOne(db))?.recipientId, @@ -278,8 +264,7 @@ public extension VisibleMessage { linkPreview: linkPreview ) }, - reaction: nil, // Reactions are custom messages sent separately - specifiedTtl: specifiedTtl + reaction: nil // Reactions are custom messages sent separately ) } }