Expire data extraction messages

This commit is contained in:
charles 2022-12-22 11:07:57 +11:00
parent 03c95f1ba7
commit 7c6e4679fe
2 changed files with 18 additions and 8 deletions

View File

@ -750,13 +750,18 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
val recipient = Recipient.from(context, address, false)
if (recipient.isBlocked) return
val threadId = DatabaseComponent.get(context).threadDatabase().getOrCreateThreadIdFor(recipient)
val expirationConfig = getExpirationConfiguration(threadId)
val expiresInMillis = (expirationConfig?.durationSeconds ?: 0) * 100L
val expireStartedAt = if (expirationConfig?.expirationType == ExpirationType.DELETE_AFTER_SEND) {
sentTimestamp
} else 0
val mediaMessage = IncomingMediaMessage(
address,
sentTimestamp,
-1,
0,
0,
expiresInMillis,
expireStartedAt,
false,
false,
false,
@ -770,6 +775,7 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
)
database.insertSecureDecryptedMessageInbox(mediaMessage, -1, runIncrement = true, runThreadUpdate = true)
SSKEnvironment.shared.messageExpirationManager.startAnyExpiration(sentTimestamp, senderPublicKey, expireStartedAt)
}
override fun insertMessageRequestResponse(response: MessageRequestResponse) {
@ -825,13 +831,17 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
}
recipientDb.setApproved(sender, true)
recipientDb.setApprovedMe(sender, true)
val expirationConfig = getExpirationConfiguration(threadId)
val expiresInMillis = (expirationConfig?.durationSeconds ?: 0) * 100L
val expireStartedAt = if (expirationConfig?.expirationType == ExpirationType.DELETE_AFTER_SEND) {
response.sentTimestamp!!
} else 0
val message = IncomingMediaMessage(
sender.address,
response.sentTimestamp!!,
-1,
0,
0,
expiresInMillis,
expireStartedAt,
false,
false,
true,

View File

@ -95,7 +95,7 @@ public class ExpiringMessageManager implements SSKEnvironment.MessageExpirationM
String senderPublicKey = message.getSender();
Long sentTimestamp = message.getSentTimestamp();
String groupId = message.getGroupPublicKey();
int duration = message.getDuration();
long expiresInMillis = message.getDuration() * 1000L;
Optional<SignalServiceGroup> groupInfo = Optional.absent();
Address address = Address.fromSerialized(senderPublicKey);
@ -114,7 +114,7 @@ public class ExpiringMessageManager implements SSKEnvironment.MessageExpirationM
}
IncomingMediaMessage mediaMessage = new IncomingMediaMessage(address, sentTimestamp, -1,
duration * 1000L, expireStartedAt, true,
expiresInMillis, expireStartedAt, true,
false,
false,
Optional.absent(),