mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Refactor FeatureFlags.
This commit is contained in:
@@ -220,7 +220,7 @@ object DataMessageProcessor {
|
||||
|
||||
if (insertResult != null && insertResult.threadWasNewlyCreated && !threadRecipient.isGroup && !threadRecipient.isSelf && !senderRecipient.isSystemContact) {
|
||||
val timeSinceLastSync = System.currentTimeMillis() - SignalStore.misc().lastCdsForegroundSyncTime
|
||||
if (timeSinceLastSync > FeatureFlags.cdsForegroundSyncInterval() || timeSinceLastSync < 0) {
|
||||
if (timeSinceLastSync > FeatureFlags.cdsForegroundSyncInterval || timeSinceLastSync < 0) {
|
||||
log(envelope.timestamp!!, "New 1:1 chat. Scheduling a CDS sync to see if they match someone in our contacts.")
|
||||
AppDependencies.jobManager.add(DirectoryRefreshJob(false))
|
||||
SignalStore.misc().lastCdsForegroundSyncTime = System.currentTimeMillis()
|
||||
|
||||
@@ -561,7 +561,7 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
}
|
||||
|
||||
private fun handleRetryReceipt(envelope: Envelope, metadata: EnvelopeMetadata, decryptionErrorMessage: DecryptionErrorMessage, senderRecipient: Recipient) {
|
||||
if (!FeatureFlags.retryReceipts()) {
|
||||
if (!FeatureFlags.retryReceipts) {
|
||||
warn(envelope.timestamp!!, "[RetryReceipt] Feature flag disabled, skipping retry receipt.")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ object MessageDecryptor {
|
||||
if (validationResult is EnvelopeContentValidator.Result.Invalid) {
|
||||
Log.w(TAG, "${logPrefix(envelope, cipherResult)} Invalid content! ${validationResult.reason}", validationResult.throwable)
|
||||
|
||||
if (FeatureFlags.internalUser()) {
|
||||
if (FeatureFlags.internalUser) {
|
||||
postInvalidMessageNotification(context, validationResult.reason)
|
||||
}
|
||||
|
||||
@@ -213,11 +213,11 @@ object MessageDecryptor {
|
||||
check(e is ProtocolException)
|
||||
Log.w(TAG, "${logPrefix(envelope, e)} Decryption error!", e, true)
|
||||
|
||||
if (FeatureFlags.internalUser()) {
|
||||
if (FeatureFlags.internalUser) {
|
||||
postDecryptionErrorNotification(context)
|
||||
}
|
||||
|
||||
if (FeatureFlags.retryReceipts()) {
|
||||
if (FeatureFlags.retryReceipts) {
|
||||
buildResultForDecryptionError(context, envelope, serverDeliveredTimestamp, followUpOperations, e)
|
||||
} else {
|
||||
Log.w(TAG, "${logPrefix(envelope, e)} Retry receipts disabled! Enqueuing a session reset job, which will also insert an error message.", e, true)
|
||||
@@ -296,7 +296,7 @@ object MessageDecryptor {
|
||||
|
||||
val errorCount: DecryptionErrorCount = decryptionErrorCounts.getOrPut(sender.id) { DecryptionErrorCount(count = 0, lastReceivedTime = 0) }
|
||||
val timeSinceLastError = receivedTimestamp - errorCount.lastReceivedTime
|
||||
if (timeSinceLastError > FeatureFlags.retryReceiptMaxCountResetAge() && errorCount.count > 0) {
|
||||
if (timeSinceLastError > FeatureFlags.retryReceiptMaxCountResetAge && errorCount.count > 0) {
|
||||
Log.i(TAG, "${logPrefix(envelope, senderServiceId)} Resetting decryption error count for ${sender.id} because it has been $timeSinceLastError ms since the last error.", true)
|
||||
errorCount.count = 0
|
||||
}
|
||||
@@ -304,8 +304,8 @@ object MessageDecryptor {
|
||||
errorCount.count++
|
||||
errorCount.lastReceivedTime = receivedTimestamp
|
||||
|
||||
if (errorCount.count > FeatureFlags.retryReceiptMaxCount()) {
|
||||
Log.w(TAG, "${logPrefix(envelope, senderServiceId)} This is error number ${errorCount.count} from ${sender.id}, which is greater than the maximum of ${FeatureFlags.retryReceiptMaxCount()}. Ignoring.", true)
|
||||
if (errorCount.count > FeatureFlags.retryReceiptMaxCount) {
|
||||
Log.w(TAG, "${logPrefix(envelope, senderServiceId)} This is error number ${errorCount.count} from ${sender.id}, which is greater than the maximum of ${FeatureFlags.retryReceiptMaxCount}. Ignoring.", true)
|
||||
|
||||
if (contentHint == ContentHint.IMPLICIT) {
|
||||
Log.w(TAG, "${logPrefix(envelope, senderServiceId)} The content hint is $contentHint, so no error message is needed.", true)
|
||||
|
||||
@@ -171,7 +171,7 @@ object SignalServiceProtoUtil {
|
||||
}
|
||||
|
||||
fun List<AttachmentPointer>.toPointersWithinLimit(): List<Attachment> {
|
||||
return mapNotNull { it.toPointer() }.take(FeatureFlags.maxAttachmentCount())
|
||||
return mapNotNull { it.toPointer() }.take(FeatureFlags.maxAttachmentCount)
|
||||
}
|
||||
|
||||
fun AttachmentPointer.toPointer(stickerLocator: StickerLocator? = null): Attachment? {
|
||||
|
||||
@@ -90,7 +90,7 @@ object StoryMessageProcessor {
|
||||
}
|
||||
|
||||
if (insertResult != null) {
|
||||
Stories.enqueueNextStoriesForDownload(threadRecipient.id, false, FeatureFlags.storiesAutoDownloadMaximum())
|
||||
Stories.enqueueNextStoriesForDownload(threadRecipient.id, false, FeatureFlags.storiesAutoDownloadMaximum)
|
||||
AppDependencies.expireStoriesManager.scheduleIfNecessary()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1368,7 +1368,7 @@ object SyncMessageProcessor {
|
||||
|
||||
@Throws(BadGroupIdException::class)
|
||||
private fun handleSynchronizeGroupOrAdHocCallEvent(callEvent: SyncMessage.CallEvent, envelopeTimestamp: Long) {
|
||||
if (!FeatureFlags.adHocCalling() && callEvent.type == SyncMessage.CallEvent.Type.AD_HOC_CALL) {
|
||||
if (!FeatureFlags.adHocCalling && callEvent.type == SyncMessage.CallEvent.Type.AD_HOC_CALL) {
|
||||
log(envelopeTimestamp, "Ad-Hoc calling is not currently supported by this client, ignoring.")
|
||||
return
|
||||
}
|
||||
@@ -1475,7 +1475,7 @@ object SyncMessageProcessor {
|
||||
}
|
||||
|
||||
private fun handleSynchronizeDeleteForMe(context: Context, deleteForMe: SyncMessage.DeleteForMe, envelopeTimestamp: Long, earlyMessageCacheEntry: EarlyMessageCacheEntry?) {
|
||||
if (!FeatureFlags.deleteSyncEnabled()) {
|
||||
if (!FeatureFlags.deleteSyncEnabled) {
|
||||
warn(envelopeTimestamp, "Delete for me sync message dropped as support not enabled")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user