mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 11:05:25 +00:00
fix: removing debug logs, adding failure error handling logs for expiry message updater, properly using the message thread ID created for the expiring messages. Process the non-thread messages properly with await in BatchMessageReceiveJob
This commit is contained in:
parent
216070fa5d
commit
f7b4fe216f
@ -96,7 +96,6 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
// TODO: maybe add time here from formation / creation message
|
||||
override fun threadCreated(address: Address, threadId: Long) {
|
||||
if (!getRecipientApproved(address)) return // don't store unapproved / message requests
|
||||
Log.d("Loki-DBG", "creating thread for $address\nExecution context:\n${Thread.currentThread().stackTrace.joinToString("\n")}")
|
||||
|
||||
val volatile = configFactory.convoVolatile ?: return
|
||||
if (address.isGroup) {
|
||||
@ -135,7 +134,6 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
}
|
||||
|
||||
override fun threadDeleted(address: Address, threadId: Long) {
|
||||
Log.d("Loki-DBG", "deleting thread for $address\nExecution context:\n${Thread.currentThread().stackTrace.joinToString("\n")}")
|
||||
|
||||
val volatile = configFactory.convoVolatile ?: return
|
||||
if (address.isGroup) {
|
||||
@ -1100,7 +1098,6 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
setPinned(conversationThreadId, contact.priority == ConfigBase.PRIORITY_PINNED)
|
||||
}
|
||||
}
|
||||
Log.d("Loki-DBG", "Updated contact $contact")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,6 @@ public class ThreadDatabase extends Database {
|
||||
|
||||
ContentValues contentValues = new ContentValues(1);
|
||||
contentValues.put(READ, 1);
|
||||
Log.d("Loki-DBG", "setRead "+threadId+" @ "+lastReadTime);
|
||||
contentValues.put(LAST_SEEN, lastReadTime);
|
||||
|
||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||
@ -336,7 +335,6 @@ public class ThreadDatabase extends Database {
|
||||
contentValues.put(UNREAD_MENTION_COUNT, 0);
|
||||
|
||||
if (lastSeen) {
|
||||
Log.d("Loki-DBG", "setRead "+threadId+" @ current time");
|
||||
contentValues.put(LAST_SEEN, SnodeAPI.getNowWithOffset());
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class ExpiringMessageManager implements SSKEnvironment.MessageExpirationM
|
||||
|
||||
try {
|
||||
OutgoingExpirationUpdateMessage timerUpdateMessage = new OutgoingExpirationUpdateMessage(recipient, sentTimestamp, duration * 1000L, groupId);
|
||||
mmsDatabase.insertSecureDecryptedMessageOutbox(timerUpdateMessage, -1, sentTimestamp, true);
|
||||
mmsDatabase.insertSecureDecryptedMessageOutbox(timerUpdateMessage, message.getThreadID(), sentTimestamp, true);
|
||||
|
||||
if (groupId != null) {
|
||||
// we need the group ID as recipient for setExpireMessages below
|
||||
@ -163,7 +163,7 @@ public class ExpiringMessageManager implements SSKEnvironment.MessageExpirationM
|
||||
MessagingModuleConfiguration.getShared().getStorage().setExpirationTimer(recipient.getAddress().serialize(), duration);
|
||||
|
||||
} catch (MmsException | IOException ioe) {
|
||||
Log.e("Loki", "Failed to insert expiration update message.");
|
||||
Log.e("Loki", "Failed to insert expiration update message.", ioe);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ import java.util.Timer
|
||||
|
||||
object ConfigurationMessageUtilities {
|
||||
|
||||
val debouncer = WindowDebouncer(3000, Timer())
|
||||
private val debouncer = WindowDebouncer(3000, Timer())
|
||||
|
||||
private fun scheduleConfigSync(userPublicKey: String) {
|
||||
debouncer.publish {
|
||||
@ -41,11 +41,9 @@ object ConfigurationMessageUtilities {
|
||||
val currentStorageJob = storage.getConfigSyncJob(ourDestination)
|
||||
if (currentStorageJob != null) {
|
||||
(currentStorageJob as ConfigurationSyncJob).shouldRunAgain.set(true)
|
||||
Log.d("Loki-DBG", "Not scheduling another one")
|
||||
return@publish
|
||||
}
|
||||
val newConfigSync = ConfigurationSyncJob(ourDestination)
|
||||
Log.d("Loki", "Scheduling new ConfigurationSyncJob")
|
||||
JobQueue.shared.add(newConfigSync)
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,6 @@ class BatchMessageReceiveJob(
|
||||
val messageIds = linkedMapOf<Long, Pair<Boolean, Boolean>>()
|
||||
val myLastSeen = storage.getLastSeen(threadId)
|
||||
var newLastSeen = if (myLastSeen == -1L) 0 else myLastSeen
|
||||
Log.d("Loki-DBG", "myLastSeen = $newLastSeen")
|
||||
messages.forEach { (parameters, message, proto) ->
|
||||
try {
|
||||
when (message) {
|
||||
@ -226,11 +225,9 @@ class BatchMessageReceiveJob(
|
||||
// last seen will be the current last seen if not changed (re-computes the read counts for thread record)
|
||||
// might have been updated from a different thread at this point
|
||||
val currentLastSeen = storage.getLastSeen(threadId).let { if (it == -1L) 0 else it }
|
||||
Log.d("Loki-DBG", "currentLastSeen = $currentLastSeen")
|
||||
if (currentLastSeen > newLastSeen) {
|
||||
newLastSeen = currentLastSeen
|
||||
}
|
||||
Log.d("Loki-DBG", "newLastSeen = $newLastSeen")
|
||||
storage.markConversationAsRead(threadId, newLastSeen)
|
||||
storage.updateThread(threadId, true)
|
||||
SSKEnvironment.shared.notificationManager.updateNotification(context, threadId)
|
||||
@ -243,7 +240,7 @@ class BatchMessageReceiveJob(
|
||||
}
|
||||
// await all thread processing
|
||||
deferredThreadMap.awaitAll()
|
||||
processMessages(NO_THREAD_MAPPING, noThreadMessages)
|
||||
processMessages(NO_THREAD_MAPPING, noThreadMessages).await()
|
||||
}
|
||||
if (failures.isEmpty()) {
|
||||
handleSuccess(dispatcherName)
|
||||
|
Loading…
Reference in New Issue
Block a user