mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
feat: add removing of the sent/received messages
This commit is contained in:
parent
50d3b52617
commit
704723ed80
@ -379,9 +379,9 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
|||||||
SessionMetaProtocol.addTimestamp(timestamp)
|
SessionMetaProtocol.addTimestamp(timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// override fun removeReceivedMessageTimestamps(timestamps: Set<Long>) {
|
override fun removeReceivedMessageTimestamps(timestamps: Set<Long>) {
|
||||||
// TODO("Not yet implemented")
|
SessionMetaProtocol.removeTimestamps(timestamps)
|
||||||
// }
|
}
|
||||||
|
|
||||||
override fun getMessageIdInDatabase(timestamp: Long, author: String): Long? {
|
override fun getMessageIdInDatabase(timestamp: Long, author: String): Long? {
|
||||||
val database = DatabaseFactory.getMmsSmsDatabase(context)
|
val database = DatabaseFactory.getMmsSmsDatabase(context)
|
||||||
|
@ -49,6 +49,7 @@ import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord;
|
|||||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
||||||
import org.thoughtcrime.securesms.database.model.ThreadRecord;
|
import org.thoughtcrime.securesms.database.model.ThreadRecord;
|
||||||
|
import org.thoughtcrime.securesms.loki.protocol.SessionMetaProtocol;
|
||||||
import org.thoughtcrime.securesms.mms.Slide;
|
import org.thoughtcrime.securesms.mms.Slide;
|
||||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||||
|
|
||||||
@ -410,6 +411,7 @@ public class ThreadDatabase extends Database {
|
|||||||
deleteThread(threadId);
|
deleteThread(threadId);
|
||||||
notifyConversationListeners(threadId);
|
notifyConversationListeners(threadId);
|
||||||
notifyConversationListListeners();
|
notifyConversationListListeners();
|
||||||
|
SessionMetaProtocol.clearReceivedMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasThread(long threadId) {
|
public boolean hasThread(long threadId) {
|
||||||
|
@ -24,6 +24,15 @@ object SessionMetaProtocol {
|
|||||||
timestamps.add(timestamp)
|
timestamps.add(timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun clearReceivedMessages() {
|
||||||
|
timestamps.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removeTimestamps(timestamps: Set<Long>) {
|
||||||
|
this.timestamps.removeAll(timestamps)
|
||||||
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun shouldIgnoreMessage(timestamp: Long): Boolean {
|
fun shouldIgnoreMessage(timestamp: Long): Boolean {
|
||||||
val shouldIgnoreMessage = timestamps.contains(timestamp)
|
val shouldIgnoreMessage = timestamps.contains(timestamp)
|
||||||
|
@ -95,7 +95,7 @@ interface StorageProtocol {
|
|||||||
fun isMessageDuplicated(timestamp: Long, sender: String): Boolean
|
fun isMessageDuplicated(timestamp: Long, sender: String): Boolean
|
||||||
fun getReceivedMessageTimestamps(): Set<Long>
|
fun getReceivedMessageTimestamps(): Set<Long>
|
||||||
fun addReceivedMessageTimestamp(timestamp: Long)
|
fun addReceivedMessageTimestamp(timestamp: Long)
|
||||||
// fun removeReceivedMessageTimestamps(timestamps: Set<Long>)
|
fun removeReceivedMessageTimestamps(timestamps: Set<Long>)
|
||||||
// Returns the IDs of the saved attachments.
|
// Returns the IDs of the saved attachments.
|
||||||
fun persistAttachments(messageId: Long, attachments: List<Attachment>): List<Long>
|
fun persistAttachments(messageId: Long, attachments: List<Attachment>): List<Long>
|
||||||
fun getAttachmentsForMessage(messageId: Long): List<DatabaseAttachment>
|
fun getAttachmentsForMessage(messageId: Long): List<DatabaseAttachment>
|
||||||
|
@ -287,7 +287,7 @@ object MessageSender {
|
|||||||
val userPublicKey = storage.getUserPublicKey()!!
|
val userPublicKey = storage.getUserPublicKey()!!
|
||||||
val messageId = storage.getMessageIdInDatabase(message.sentTimestamp!!, message.sender?:userPublicKey) ?: return
|
val messageId = storage.getMessageIdInDatabase(message.sentTimestamp!!, message.sender?:userPublicKey) ?: return
|
||||||
// Ignore future self-sends
|
// Ignore future self-sends
|
||||||
// storage.addReceivedMessageTimestamp(message.sentTimestamp!!)
|
storage.addReceivedMessageTimestamp(message.sentTimestamp!!)
|
||||||
// Track the open group server message ID
|
// Track the open group server message ID
|
||||||
if (message.openGroupServerMessageID != null && destination is Destination.OpenGroupV2) {
|
if (message.openGroupServerMessageID != null && destination is Destination.OpenGroupV2) {
|
||||||
val encoded = GroupUtil.getEncodedOpenGroupID("${destination.server}.${destination.room}".toByteArray())
|
val encoded = GroupUtil.getEncodedOpenGroupID("${destination.server}.${destination.room}".toByteArray())
|
||||||
|
Loading…
Reference in New Issue
Block a user