mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
Disappear after read info refactor
This commit is contained in:
parent
f600e4d343
commit
03766d57ee
@ -668,7 +668,6 @@ class MmsDatabase(context: Context, databaseHelper: SQLCipherOpenHelper) : Messa
|
||||
contentValues.put(SUBSCRIPTION_ID, retrieved.subscriptionId)
|
||||
contentValues.put(EXPIRES_IN, retrieved.expiresIn)
|
||||
contentValues.put(EXPIRE_STARTED, retrieved.expireStartedAt)
|
||||
contentValues.put(READ, if (retrieved.isExpirationUpdate) 1 else 0)
|
||||
contentValues.put(UNIDENTIFIED, retrieved.isUnidentified)
|
||||
contentValues.put(MESSAGE_REQUEST_RESPONSE, retrieved.isMessageRequestResponse)
|
||||
if (!contentValues.containsKey(DATE_SENT)) {
|
||||
|
@ -332,12 +332,10 @@ public class SmsDatabase extends MessagingDatabase {
|
||||
cursor = database.query(TABLE_NAME, new String[] {ID, ADDRESS, DATE_SENT, TYPE, EXPIRES_IN, EXPIRE_STARTED}, where, arguments, null, null, null);
|
||||
|
||||
while (cursor != null && cursor.moveToNext()) {
|
||||
if (Types.isSecureType(cursor.getLong(3))) {
|
||||
SyncMessageId syncMessageId = new SyncMessageId(Address.fromSerialized(cursor.getString(1)), cursor.getLong(2));
|
||||
ExpirationInfo expirationInfo = new ExpirationInfo(cursor.getLong(0), cursor.getLong(4), cursor.getLong(5), false);
|
||||
SyncMessageId syncMessageId = new SyncMessageId(Address.fromSerialized(cursor.getString(1)), cursor.getLong(2));
|
||||
ExpirationInfo expirationInfo = new ExpirationInfo(cursor.getLong(0), cursor.getLong(4), cursor.getLong(5), false);
|
||||
|
||||
results.add(new MarkedMessageInfo(syncMessageId, expirationInfo));
|
||||
}
|
||||
results.add(new MarkedMessageInfo(syncMessageId, expirationInfo));
|
||||
}
|
||||
|
||||
ContentValues contentValues = new ContentValues();
|
||||
|
@ -160,9 +160,7 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
}
|
||||
val expirationConfig = getExpirationConfiguration(message.threadID ?: -1)
|
||||
val expiresInMillis = (expirationConfig?.durationSeconds ?: 0) * 1000L
|
||||
val expireStartedAt = if (expirationConfig?.expirationType == ExpirationType.DELETE_AFTER_SEND) {
|
||||
message.sentTimestamp!!
|
||||
} else 0
|
||||
val expireStartedAt = if (expirationConfig?.expirationType == ExpirationType.DELETE_AFTER_SEND) message.sentTimestamp!! else 0
|
||||
if (message.isMediaMessage() || attachments.isNotEmpty()) {
|
||||
val quote: Optional<QuoteModel> = if (quotes != null) Optional.of(quotes) else Optional.absent()
|
||||
val linkPreviews: Optional<List<LinkPreview>> = if (linkPreview.isEmpty()) Optional.absent() else Optional.of(linkPreview.mapNotNull { it!! })
|
||||
@ -212,7 +210,9 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
DatabaseComponent.get(context).lokiMessageDatabase().setMessageServerHash(id, serverHash)
|
||||
}
|
||||
}
|
||||
SSKEnvironment.shared.messageExpirationManager.startAnyExpiration(message.sentTimestamp!!, message.sender!!, expireStartedAt)
|
||||
if (expirationConfig?.expirationType == ExpirationType.DELETE_AFTER_SEND) {
|
||||
SSKEnvironment.shared.messageExpirationManager.startAnyExpiration(message.sentTimestamp!!, message.sender!!, expireStartedAt)
|
||||
}
|
||||
return messageID
|
||||
}
|
||||
|
||||
@ -483,15 +483,15 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
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 expireStartedAt = if (expirationConfig?.expirationType == ExpirationType.DELETE_AFTER_SEND) sentTimestamp else 0
|
||||
val m = IncomingTextMessage(fromSerialized(senderPublicKey), 1, sentTimestamp, "", Optional.of(group), expiresInMillis, expireStartedAt, true)
|
||||
val updateData = UpdateMessageData.buildGroupUpdate(type, name, members)?.toJSON()
|
||||
val infoMessage = IncomingGroupMessage(m, groupID, updateData, true)
|
||||
val smsDB = DatabaseComponent.get(context).smsDatabase()
|
||||
smsDB.insertMessageInbox(infoMessage, true, true)
|
||||
SSKEnvironment.shared.messageExpirationManager.startAnyExpiration(sentTimestamp, senderPublicKey, expireStartedAt)
|
||||
if (expirationConfig?.expirationType == ExpirationType.DELETE_AFTER_SEND) {
|
||||
SSKEnvironment.shared.messageExpirationManager.startAnyExpiration(sentTimestamp, senderPublicKey, expireStartedAt)
|
||||
}
|
||||
}
|
||||
|
||||
override fun insertOutgoingInfoMessage(context: Context, groupID: String, type: SignalServiceGroup.Type, name: String, members: Collection<String>, admins: Collection<String>, threadID: Long, sentTimestamp: Long) {
|
||||
@ -500,9 +500,7 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
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 expireStartedAt = if (expirationConfig?.expirationType == ExpirationType.DELETE_AFTER_SEND) sentTimestamp else 0
|
||||
val updateData = UpdateMessageData.buildGroupUpdate(type, name, members)?.toJSON() ?: ""
|
||||
val infoMessage = OutgoingGroupMediaMessage(recipient, updateData, groupID, null, sentTimestamp, expiresInMillis, expireStartedAt, true, null, listOf(), listOf())
|
||||
val mmsDB = DatabaseComponent.get(context).mmsDatabase()
|
||||
@ -510,7 +508,9 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
if (mmsSmsDB.getMessageFor(sentTimestamp, userPublicKey) != null) return
|
||||
val infoMessageID = mmsDB.insertMessageOutbox(infoMessage, threadID, false, null, runThreadUpdate = true)
|
||||
mmsDB.markAsSent(infoMessageID, true)
|
||||
SSKEnvironment.shared.messageExpirationManager.startAnyExpiration(sentTimestamp, userPublicKey!!, expireStartedAt)
|
||||
if (expirationConfig?.expirationType == ExpirationType.DELETE_AFTER_SEND) {
|
||||
SSKEnvironment.shared.messageExpirationManager.startAnyExpiration(sentTimestamp, userPublicKey!!, expireStartedAt)
|
||||
}
|
||||
}
|
||||
|
||||
override fun isClosedGroup(publicKey: String): Boolean {
|
||||
@ -753,9 +753,7 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
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 expireStartedAt = if (expirationConfig?.expirationType == ExpirationType.DELETE_AFTER_SEND) sentTimestamp else 0
|
||||
val mediaMessage = IncomingMediaMessage(
|
||||
address,
|
||||
sentTimestamp,
|
||||
@ -775,7 +773,9 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
)
|
||||
|
||||
database.insertSecureDecryptedMessageInbox(mediaMessage, -1, runIncrement = true, runThreadUpdate = true)
|
||||
SSKEnvironment.shared.messageExpirationManager.startAnyExpiration(sentTimestamp, senderPublicKey, expireStartedAt)
|
||||
if (expirationConfig?.expirationType == ExpirationType.DELETE_AFTER_SEND) {
|
||||
SSKEnvironment.shared.messageExpirationManager.startAnyExpiration(sentTimestamp, senderPublicKey, expireStartedAt)
|
||||
}
|
||||
}
|
||||
|
||||
override fun insertMessageRequestResponse(response: MessageRequestResponse) {
|
||||
@ -872,12 +872,12 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
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 expireStartedAt = if (expirationConfig?.expirationType == ExpirationType.DELETE_AFTER_SEND) sentTimestamp else 0
|
||||
val callMessage = IncomingTextMessage.fromCallInfo(callMessageType, address, Optional.absent(), sentTimestamp, expiresInMillis, expireStartedAt)
|
||||
database.insertCallMessage(callMessage)
|
||||
SSKEnvironment.shared.messageExpirationManager.startAnyExpiration(sentTimestamp, senderPublicKey, expireStartedAt)
|
||||
if (expirationConfig?.expirationType == ExpirationType.DELETE_AFTER_SEND) {
|
||||
SSKEnvironment.shared.messageExpirationManager.startAnyExpiration(sentTimestamp, senderPublicKey, expireStartedAt)
|
||||
}
|
||||
}
|
||||
|
||||
override fun conversationHasOutgoing(userPublicKey: String): Boolean {
|
||||
|
@ -71,8 +71,8 @@ public class ExpiringMessageManager implements SSKEnvironment.MessageExpirationM
|
||||
public void setExpirationTimer(@NotNull ExpirationTimerUpdate message, int expiryType) {
|
||||
String userPublicKey = TextSecurePreferences.getLocalNumber(context);
|
||||
String senderPublicKey = message.getSender();
|
||||
long expireStartedAt = ExpirationType.DELETE_AFTER_SEND_VALUE != expiryType
|
||||
? 0 : message.getSentTimestamp();
|
||||
long expireStartedAt = expiryType == ExpirationType.DELETE_AFTER_SEND_VALUE
|
||||
? message.getSentTimestamp() : 0;
|
||||
|
||||
// Notify the user
|
||||
if (senderPublicKey == null || userPublicKey.equals(senderPublicKey)) {
|
||||
@ -81,7 +81,7 @@ public class ExpiringMessageManager implements SSKEnvironment.MessageExpirationM
|
||||
} else {
|
||||
insertIncomingExpirationTimerMessage(message, expireStartedAt);
|
||||
}
|
||||
if (message.getSentTimestamp() != null && senderPublicKey != null) {
|
||||
if (expiryType == ExpirationType.DELETE_AFTER_SEND_VALUE && message.getSentTimestamp() != null && senderPublicKey != null) {
|
||||
startAnyExpiration(message.getSentTimestamp(), senderPublicKey, expireStartedAt);
|
||||
}
|
||||
if (message.getId() != null) {
|
||||
|
@ -380,7 +380,7 @@ object MessageSender {
|
||||
storage.markAsSent(message.sentTimestamp!!, userPublicKey)
|
||||
storage.markUnidentified(message.sentTimestamp!!, userPublicKey)
|
||||
// Start the disappearing messages timer if needed
|
||||
if (message is VisibleMessage && !isSyncMessage) {
|
||||
if (!isSyncMessage) {
|
||||
SSKEnvironment.shared.messageExpirationManager.startAnyExpiration(message.sentTimestamp!!, userPublicKey, System.currentTimeMillis())
|
||||
}
|
||||
} ?: run {
|
||||
|
Loading…
x
Reference in New Issue
Block a user