fix unsend requests

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

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

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

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

Loading…
Cancel
Save