fix unsend requests

pull/731/head
Ryan ZHAO 6 months ago
parent 810a990735
commit ac30b3c797

@ -2087,6 +2087,8 @@ extension ConversationVC:
cellViewModel.authorId cellViewModel.authorId
) )
) )
unsendRequest.expiresInSeconds = cellViewModel.expiresInSeconds
unsendRequest.expiresStartedAtMs = cellViewModel.expiresStartedAtMs
// For incoming interactions or interactions with no serverHash just delete them locally // For incoming interactions or interactions with no serverHash just delete them locally
guard cellViewModel.variant == .standardOutgoing, let serverHash: String = serverHash else { guard cellViewModel.variant == .standardOutgoing, let serverHash: String = serverHash else {

@ -477,19 +477,20 @@ public extension Interaction {
) )
} }
func withDisappearingMessagesConfiguration( func withDisappearingMessagesConfiguration(_ db: Database) -> Interaction {
_ db: Database, if let config = try? DisappearingMessagesConfiguration.fetchOne(db, id: self.threadId) {
disappearingMessagesConfiguration: DisappearingMessagesConfiguration? = nil return self.withDisappearingMessagesConfiguration(config: config)
) -> Interaction {
if let config = disappearingMessagesConfiguration ?? (try? DisappearingMessagesConfiguration.fetchOne(db, id: self.threadId)) {
return self.with(
expiresInSeconds: config.durationSeconds,
expiresStartedAtMs: (config.type == .disappearAfterSend ? Double(self.timestampMs) : nil)
)
} }
return self return self
} }
func withDisappearingMessagesConfiguration(config: DisappearingMessagesConfiguration) -> Interaction {
return self.with(
expiresInSeconds: config.durationSeconds,
expiresStartedAtMs: (config.type == .disappearAfterSend ? Double(self.timestampMs) : nil)
)
}
} }
// MARK: - GRDB Interactions // MARK: - GRDB Interactions

@ -70,6 +70,8 @@ public final class UnsendRequest: ControlMessage {
let contentProto = SNProtoContent.builder() let contentProto = SNProtoContent.builder()
do { do {
contentProto.setUnsendRequest(try unsendRequestProto.build()) contentProto.setUnsendRequest(try unsendRequestProto.build())
// DisappearingMessagesConfiguration
setDisappearingMessagesConfigurationIfNeeded(on: contentProto)
return try contentProto.build() return try contentProto.build()
} catch { } catch {
SNLog("Couldn't construct unsend request proto from: \(self).") SNLog("Couldn't construct unsend request proto from: \(self).")

Loading…
Cancel
Save