pull/941/head
ryanzhao 2 years ago
parent 387b5f953b
commit d4d7f6c72c

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

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

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

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

Loading…
Cancel
Save