use local disappearing messages setting for call messages and data extraction notifications

pull/731/head
Ryan ZHAO 7 months ago
parent 39341742ea
commit 04d734ef87

@ -241,6 +241,7 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
expiresInSeconds: message.expiresInSeconds, expiresInSeconds: message.expiresInSeconds,
expiresStartedAtMs: message.expiresStartedAtMs expiresStartedAtMs: message.expiresStartedAtMs
) )
.withDisappearingMessagesConfiguration(config: disappearingMessagesConfiguration)
.inserted(db) .inserted(db)
self.callInteractionId = interaction?.id self.callInteractionId = interaction?.id

@ -485,10 +485,10 @@ public extension Interaction {
return self return self
} }
func withDisappearingMessagesConfiguration(config: DisappearingMessagesConfiguration) -> Interaction { func withDisappearingMessagesConfiguration(config: DisappearingMessagesConfiguration?) -> Interaction {
return self.with( return self.with(
expiresInSeconds: config.durationSeconds, expiresInSeconds: config?.durationSeconds,
expiresStartedAtMs: (config.type == .disappearAfterSend ? Double(self.timestampMs) : nil) expiresStartedAtMs: (config?.type == .disappearAfterSend ? Double(self.timestampMs) : nil)
) )
} }
} }

@ -303,9 +303,9 @@ extension MessageReceiver {
timestampMs: (timestampMs * 1000), timestampMs: (timestampMs * 1000),
userPublicKey: currentUserPublicKey, userPublicKey: currentUserPublicKey,
openGroup: nil openGroup: nil
), )
expiresInSeconds: message.expiresInSeconds, )
expiresStartedAtMs: message.expiresStartedAtMs .withDisappearingMessagesConfiguration(db) // Should follow local setting
).inserted(db) .inserted(db)
} }
} }

@ -39,9 +39,9 @@ extension MessageReceiver {
timestampMs: (timestampMs * 1000), timestampMs: (timestampMs * 1000),
userPublicKey: getUserHexEncodedPublicKey(db), userPublicKey: getUserHexEncodedPublicKey(db),
openGroup: nil openGroup: nil
), )
expiresInSeconds: message.expiresInSeconds, )
expiresStartedAtMs: message.expiresStartedAtMs .withDisappearingMessagesConfiguration(db) // Should follow local setting
).inserted(db) .inserted(db)
} }
} }

@ -134,10 +134,19 @@ extension MessageReceiver {
public static func updateContactDisappearingMessagesVersionIfNeeded( public static func updateContactDisappearingMessagesVersionIfNeeded(
_ db: Database, _ db: Database,
messageVariant: Message.Variant?,
contactId: String?, contactId: String?,
version: FeatureVersion? version: FeatureVersion?
) { ) {
guard let contactId: String = contactId, let version: FeatureVersion = version else { return } guard
let messageVariant: Message.Variant = messageVariant,
let contactId: String = contactId,
let version: FeatureVersion = version
else {
return
}
guard [ .visibleMessage, .expirationTimerUpdate ].contains(messageVariant) else { return }
_ = try? Contact _ = try? Contact
.filter(id: contactId) .filter(id: contactId)

@ -210,6 +210,7 @@ public enum MessageReceiver {
MessageReceiver.updateContactDisappearingMessagesVersionIfNeeded( MessageReceiver.updateContactDisappearingMessagesVersionIfNeeded(
db, db,
messageVariant: .init(from: message),
contactId: message.sender, contactId: message.sender,
version: ((!proto.hasExpirationType && !proto.hasExpirationTimer) ? version: ((!proto.hasExpirationType && !proto.hasExpirationTimer) ?
.legacyDisappearingMessages : .legacyDisappearingMessages :

Loading…
Cancel
Save