Merge pull request #369 from RyanRory/PN-fix-step-1

Fix PNs Part 1
This commit is contained in:
Niels Andriesse 2020-10-27 10:13:53 +11:00 committed by GitHub
commit e005fbf282
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,6 +50,8 @@ class BackgroundPollJob private constructor(parameters: Parameters) : BaseJob(pa
Log.d("Loki", "Performing background poll.") Log.d("Loki", "Performing background poll.")
val userPublicKey = TextSecurePreferences.getLocalNumber(context) val userPublicKey = TextSecurePreferences.getLocalNumber(context)
val promises = mutableListOf<Promise<Unit, Exception>>() val promises = mutableListOf<Promise<Unit, Exception>>()
if (!TextSecurePreferences.isUsingFCM(context)) {
Log.d("Loki", "Not using FCM, poll for contacts and closed groups.")
val promise = SnodeAPI.shared.getMessages(userPublicKey).map { envelopes -> val promise = SnodeAPI.shared.getMessages(userPublicKey).map { envelopes ->
envelopes.forEach { envelopes.forEach {
PushContentReceiveJob(context).processEnvelope(SignalServiceEnvelope(it), false) PushContentReceiveJob(context).processEnvelope(SignalServiceEnvelope(it), false)
@ -57,6 +59,7 @@ class BackgroundPollJob private constructor(parameters: Parameters) : BaseJob(pa
} }
promises.add(promise) promises.add(promise)
promises.addAll(ClosedGroupPoller.shared.pollOnce()) promises.addAll(ClosedGroupPoller.shared.pollOnce())
}
val openGroups = DatabaseFactory.getLokiThreadDatabase(context).getAllPublicChats().map { it.value } val openGroups = DatabaseFactory.getLokiThreadDatabase(context).getAllPublicChats().map { it.value }
for (openGroup in openGroups) { for (openGroup in openGroups) {
val poller = PublicChatPoller(context, openGroup) val poller = PublicChatPoller(context, openGroup)