Only add one sustainer request message per release notes update.

fork-5.53.8
Cody Henthorne 2022-06-22 13:54:07 -04:00
rodzic 6a385c7a22
commit d39a4b14e7
1 zmienionych plików z 9 dodań i 4 usunięć

Wyświetl plik

@ -113,7 +113,7 @@ class RetrieveRemoteAnnouncementsJob private constructor(private val force: Bool
Log.i(TAG, "First check, saving code and skipping download")
values.highestVersionNoteReceived = BuildConfig.CANONICAL_VERSION_CODE
}
MessageDigest.isEqual(manifestMd5, values.previousManifestMd5) -> {
!force && MessageDigest.isEqual(manifestMd5, values.previousManifestMd5) -> {
Log.i(TAG, "Manifest has not changed since last fetch.")
}
else -> fetchManifest(manifestMd5)
@ -178,6 +178,7 @@ class RetrieveRemoteAnnouncementsJob private constructor(private val force: Bool
val threadId = SignalDatabase.threads.getOrCreateThreadIdFor(Recipient.resolved(values.releaseChannelRecipientId!!))
var highestVersion = values.highestVersionNoteReceived
var addedNewNotes = false
resolvedNotes
.filterNotNull()
@ -197,7 +198,7 @@ class RetrieveRemoteAnnouncementsJob private constructor(private val force: Bool
bodyRangeList.addButton(note.translation.callToActionText, note.releaseNote.ctaId, body.lastIndex, 0)
}
ThreadUtil.sleep(1)
ThreadUtil.sleep(5)
val insertResult: MessageDatabase.InsertResult? = ReleaseChannel.insertAnnouncement(
recipientId = values.releaseChannelRecipientId!!,
body = body,
@ -208,9 +209,8 @@ class RetrieveRemoteAnnouncementsJob private constructor(private val force: Bool
imageHeight = note.translation.imageHeight?.toIntOrNull() ?: 0
)
SignalDatabase.sms.insertBoostRequestMessage(values.releaseChannelRecipientId!!, threadId)
if (insertResult != null) {
addedNewNotes = true
SignalDatabase.attachments.getAttachmentsForMessage(insertResult.messageId)
.forEach { ApplicationDependencies.getJobManager().add(AttachmentDownloadJob(insertResult.messageId, it.attachmentId, false)) }
@ -221,6 +221,11 @@ class RetrieveRemoteAnnouncementsJob private constructor(private val force: Bool
}
}
if (addedNewNotes) {
ThreadUtil.sleep(5)
SignalDatabase.sms.insertBoostRequestMessage(values.releaseChannelRecipientId!!, threadId)
}
values.highestVersionNoteReceived = highestVersion
}