diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/api/BackgroundPollWorker.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/api/BackgroundPollWorker.kt index c6cd6f6a4d..ffe7e230e0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/api/BackgroundPollWorker.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/api/BackgroundPollWorker.kt @@ -52,7 +52,7 @@ class BackgroundPollWorker(val context: Context, params: WorkerParameters) : Wor val dmsPromise = SnodeAPI.getMessages(userPublicKey).map { envelopes -> envelopes.map { envelope -> // FIXME: Using a job here seems like a bad idea... - MessageReceiveJob(envelope.toByteArray(), false).executeAsync() + MessageReceiveJob(envelope.toByteArray()).executeAsync() } } promises.addAll(dmsPromise.get()) @@ -61,12 +61,6 @@ class BackgroundPollWorker(val context: Context, params: WorkerParameters) : Wor promises.addAll(ClosedGroupPoller().pollOnce()) // Open Groups - val openGroups = DatabaseFactory.getLokiThreadDatabase(context).getAllPublicChats().values - for (openGroup in openGroups) { - val poller = OpenGroupPoller(openGroup) - promises.add(poller.pollForNewMessages()) - } - val v2OpenGroups = DatabaseFactory.getLokiThreadDatabase(context).getAllV2OpenGroups().values.groupBy(OpenGroupV2::server) v2OpenGroups.values.map { groups -> diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/api/PushNotificationService.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/api/PushNotificationService.kt index b5a7bd141e..74f6f25c88 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/api/PushNotificationService.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/api/PushNotificationService.kt @@ -28,7 +28,7 @@ class PushNotificationService : FirebaseMessagingService() { if (data != null) { try { val envelopeAsData = MessageWrapper.unwrap(data).toByteArray() - val job = MessageReceiveJob(envelopeAsData,true) + val job = MessageReceiveJob(envelopeAsData) JobQueue.shared.add(job) } catch (e: Exception) { Log.d("Loki", "Failed to unwrap data for message due to error: $e.") diff --git a/libsession/src/main/java/org/session/libsession/messaging/jobs/MessageReceiveJob.kt b/libsession/src/main/java/org/session/libsession/messaging/jobs/MessageReceiveJob.kt index 7910861d83..9a2692a97f 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/jobs/MessageReceiveJob.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/jobs/MessageReceiveJob.kt @@ -7,7 +7,7 @@ import org.session.libsession.messaging.sending_receiving.handle import org.session.libsession.messaging.utilities.Data import org.session.libsignal.utilities.Log -class MessageReceiveJob(val data: ByteArray, val isBackgroundPoll: Boolean, val openGroupMessageServerID: Long? = null, val openGroupID: String? = null) : Job { +class MessageReceiveJob(val data: ByteArray, val openGroupMessageServerID: Long? = null, val openGroupID: String? = null) : Job { override var delegate: JobDelegate? = null override var id: String? = null override var failureCount: Int = 0 @@ -69,7 +69,6 @@ class MessageReceiveJob(val data: ByteArray, val isBackgroundPoll: Boolean, val override fun serialize(): Data { val builder = Data.Builder().putByteArray(DATA_KEY, data) - .putBoolean(IS_BACKGROUND_POLL_KEY, isBackgroundPoll) openGroupMessageServerID?.let { builder.putLong(OPEN_GROUP_MESSAGE_SERVER_ID_KEY, it) } openGroupID?.let { builder.putString(OPEN_GROUP_ID_KEY, it) } return builder.build(); @@ -84,7 +83,6 @@ class MessageReceiveJob(val data: ByteArray, val isBackgroundPoll: Boolean, val override fun create(data: Data): MessageReceiveJob { return MessageReceiveJob( data.getByteArray(DATA_KEY), - data.getBoolean(IS_BACKGROUND_POLL_KEY), data.getLong(OPEN_GROUP_MESSAGE_SERVER_ID_KEY), data.getString(OPEN_GROUP_ID_KEY) ) diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/ClosedGroupPoller.kt b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/ClosedGroupPoller.kt index 385a273a16..08b386d95e 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/ClosedGroupPoller.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/ClosedGroupPoller.kt @@ -70,7 +70,7 @@ class ClosedGroupPoller { return@successBackground } messages.forEach { envelope -> - val job = MessageReceiveJob(envelope.toByteArray(), false) + val job = MessageReceiveJob(envelope.toByteArray()) JobQueue.shared.add(job) } } diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupPoller.kt b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupPoller.kt index c33056e9a6..d970a74c39 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupPoller.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupPoller.kt @@ -172,7 +172,7 @@ class OpenGroupPoller(private val openGroup: OpenGroup, private val executorServ builder.timestamp = message.timestamp builder.serverTimestamp = message.serverTimestamp val envelope = builder.build() - val job = MessageReceiveJob(envelope.toByteArray(), isBackgroundPoll, messageServerID, openGroup.id) + val job = MessageReceiveJob(envelope.toByteArray(), messageServerID, openGroup.id) Log.d("Loki", "Scheduling Job $job") if (isBackgroundPoll) { job.executeAsync().always { deferred.resolve(Unit) } diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupV2Poller.kt b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupV2Poller.kt index d101fa70ff..f0d03e2c29 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupV2Poller.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupV2Poller.kt @@ -99,7 +99,7 @@ class OpenGroupV2Poller(private val openGroups: List, private val e builder.content = message.toProto().toByteString() builder.timestamp = message.sentTimestamp val envelope = builder.build() - val job = MessageReceiveJob(envelope.toByteArray(), isBackgroundPoll, message.serverID, serverRoomId) + val job = MessageReceiveJob(envelope.toByteArray(), message.serverID, serverRoomId) Log.d("Loki", "Scheduling Job $job") if (isBackgroundPoll) { job.executeAsync() diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/Poller.kt b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/Poller.kt index a2471d1202..b64b96eb59 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/Poller.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/Poller.kt @@ -92,7 +92,7 @@ class Poller { } else { val messages = SnodeAPI.parseRawMessagesResponse(rawResponse, snode, userPublicKey) messages.forEach { envelope -> - val job = MessageReceiveJob(envelope.toByteArray(), false) + val job = MessageReceiveJob(envelope.toByteArray()) JobQueue.shared.add(job) } poll(snode, deferred)