kopia lustrzana https://github.com/ryukoposting/Signal-Android
Update sender key flag.
rodzic
784c373a0e
commit
2b5b664a8f
|
@ -150,7 +150,7 @@ class MessageSendLogDatabase constructor(context: Context?, databaseHelper: SQLC
|
|||
|
||||
/** @return The ID of the inserted entry, or -1 if none was inserted. Can be used with [addRecipientToExistingEntryIfPossible] */
|
||||
fun insertIfPossible(recipientId: RecipientId, sentTimestamp: Long, sendMessageResult: SendMessageResult, contentHint: ContentHint, messageId: MessageId): Long {
|
||||
if (!FeatureFlags.senderKey()) return -1
|
||||
if (!FeatureFlags.retryReceipts()) return -1
|
||||
|
||||
if (sendMessageResult.isSuccess && sendMessageResult.success.content.isPresent) {
|
||||
val recipientDevice = listOf(RecipientDevice(recipientId, sendMessageResult.success.devices))
|
||||
|
@ -162,7 +162,7 @@ class MessageSendLogDatabase constructor(context: Context?, databaseHelper: SQLC
|
|||
|
||||
/** @return The ID of the inserted entry, or -1 if none was inserted. Can be used with [addRecipientToExistingEntryIfPossible] */
|
||||
fun insertIfPossible(recipientId: RecipientId, sentTimestamp: Long, sendMessageResult: SendMessageResult, contentHint: ContentHint, messageIds: List<MessageId>): Long {
|
||||
if (!FeatureFlags.senderKey()) return -1
|
||||
if (!FeatureFlags.retryReceipts()) return -1
|
||||
|
||||
if (sendMessageResult.isSuccess && sendMessageResult.success.content.isPresent) {
|
||||
val recipientDevice = listOf(RecipientDevice(recipientId, sendMessageResult.success.devices))
|
||||
|
@ -174,7 +174,7 @@ class MessageSendLogDatabase constructor(context: Context?, databaseHelper: SQLC
|
|||
|
||||
/** @return The ID of the inserted entry, or -1 if none was inserted. Can be used with [addRecipientToExistingEntryIfPossible] */
|
||||
fun insertIfPossible(sentTimestamp: Long, possibleRecipients: List<Recipient>, results: List<SendMessageResult>, contentHint: ContentHint, messageId: MessageId): Long {
|
||||
if (!FeatureFlags.senderKey()) return -1
|
||||
if (!FeatureFlags.retryReceipts()) return -1
|
||||
|
||||
val accessList = RecipientAccessList(possibleRecipients)
|
||||
|
||||
|
@ -195,7 +195,7 @@ class MessageSendLogDatabase constructor(context: Context?, databaseHelper: SQLC
|
|||
}
|
||||
|
||||
fun addRecipientToExistingEntryIfPossible(payloadId: Long, recipientId: RecipientId, sendMessageResult: SendMessageResult) {
|
||||
if (!FeatureFlags.senderKey()) return
|
||||
if (!FeatureFlags.retryReceipts()) return
|
||||
|
||||
if (sendMessageResult.isSuccess && sendMessageResult.success.content.isPresent) {
|
||||
val db = databaseHelper.writableDatabase
|
||||
|
@ -262,7 +262,7 @@ class MessageSendLogDatabase constructor(context: Context?, databaseHelper: SQLC
|
|||
}
|
||||
|
||||
fun getLogEntry(recipientId: RecipientId, device: Int, dateSent: Long): MessageLogEntry? {
|
||||
if (!FeatureFlags.senderKey()) return null
|
||||
if (!FeatureFlags.retryReceipts()) return null
|
||||
|
||||
trimOldMessages(System.currentTimeMillis(), FeatureFlags.retryRespondMaxAge())
|
||||
|
||||
|
@ -302,7 +302,7 @@ class MessageSendLogDatabase constructor(context: Context?, databaseHelper: SQLC
|
|||
}
|
||||
|
||||
fun deleteAllRelatedToMessage(messageId: Long, mms: Boolean) {
|
||||
if (!FeatureFlags.senderKey()) return
|
||||
if (!FeatureFlags.retryReceipts()) return
|
||||
|
||||
val db = databaseHelper.writableDatabase
|
||||
val query = "${PayloadTable.ID} IN (SELECT ${MessageTable.PAYLOAD_ID} FROM ${MessageTable.TABLE_NAME} WHERE ${MessageTable.MESSAGE_ID} = ? AND ${MessageTable.IS_MMS} = ?)"
|
||||
|
@ -312,13 +312,13 @@ class MessageSendLogDatabase constructor(context: Context?, databaseHelper: SQLC
|
|||
}
|
||||
|
||||
fun deleteEntryForRecipient(dateSent: Long, recipientId: RecipientId, device: Int) {
|
||||
if (!FeatureFlags.senderKey()) return
|
||||
if (!FeatureFlags.retryReceipts()) return
|
||||
|
||||
deleteEntriesForRecipient(listOf(dateSent), recipientId, device)
|
||||
}
|
||||
|
||||
fun deleteEntriesForRecipient(dateSent: List<Long>, recipientId: RecipientId, device: Int) {
|
||||
if (!FeatureFlags.senderKey()) return
|
||||
if (!FeatureFlags.retryReceipts()) return
|
||||
|
||||
val db = databaseHelper.writableDatabase
|
||||
|
||||
|
@ -346,13 +346,13 @@ class MessageSendLogDatabase constructor(context: Context?, databaseHelper: SQLC
|
|||
}
|
||||
|
||||
fun deleteAll() {
|
||||
if (!FeatureFlags.senderKey()) return
|
||||
if (!FeatureFlags.retryReceipts()) return
|
||||
|
||||
databaseHelper.writableDatabase.delete(PayloadTable.TABLE_NAME, null, null)
|
||||
}
|
||||
|
||||
fun trimOldMessages(currentTime: Long, maxAge: Long) {
|
||||
if (!FeatureFlags.senderKey()) return
|
||||
if (!FeatureFlags.retryReceipts()) return
|
||||
|
||||
val db = databaseHelper.writableDatabase
|
||||
val query = "${PayloadTable.DATE_SENT} < ?"
|
||||
|
|
|
@ -23,7 +23,7 @@ class PendingRetryReceiptCache @VisibleForTesting constructor(
|
|||
private var populated: Boolean = false
|
||||
|
||||
fun insert(author: RecipientId, authorDevice: Int, sentTimestamp: Long, receivedTimestamp: Long, threadId: Long) {
|
||||
if (!FeatureFlags.senderKey()) return
|
||||
if (!FeatureFlags.retryReceipts()) return
|
||||
ensurePopulated()
|
||||
|
||||
synchronized(pendingRetries) {
|
||||
|
@ -33,7 +33,7 @@ class PendingRetryReceiptCache @VisibleForTesting constructor(
|
|||
}
|
||||
|
||||
fun get(author: RecipientId, sentTimestamp: Long): PendingRetryReceiptModel? {
|
||||
if (!FeatureFlags.senderKey()) return null
|
||||
if (!FeatureFlags.retryReceipts()) return null
|
||||
ensurePopulated()
|
||||
|
||||
synchronized(pendingRetries) {
|
||||
|
@ -42,7 +42,7 @@ class PendingRetryReceiptCache @VisibleForTesting constructor(
|
|||
}
|
||||
|
||||
fun getOldest(): PendingRetryReceiptModel? {
|
||||
if (!FeatureFlags.senderKey()) return null
|
||||
if (!FeatureFlags.retryReceipts()) return null
|
||||
ensurePopulated()
|
||||
|
||||
synchronized(pendingRetries) {
|
||||
|
@ -51,7 +51,7 @@ class PendingRetryReceiptCache @VisibleForTesting constructor(
|
|||
}
|
||||
|
||||
fun delete(model: PendingRetryReceiptModel) {
|
||||
if (!FeatureFlags.senderKey()) return
|
||||
if (!FeatureFlags.retryReceipts()) return
|
||||
ensurePopulated()
|
||||
|
||||
synchronized(pendingRetries) {
|
||||
|
|
|
@ -1787,8 +1787,8 @@ public final class MessageContentProcessor {
|
|||
}
|
||||
|
||||
private void handleRetryReceipt(@NonNull SignalServiceContent content, @NonNull DecryptionErrorMessage decryptionErrorMessage, @NonNull Recipient senderRecipient) {
|
||||
if (!FeatureFlags.senderKey()) {
|
||||
warn(String.valueOf(content.getTimestamp()), "[RetryReceipt] Sender key not enabled, skipping retry receipt.");
|
||||
if (!FeatureFlags.retryReceipts()) {
|
||||
warn(String.valueOf(content.getTimestamp()), "[RetryReceipt] Feature flag disabled, skipping retry receipt.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ public final class MessageDecryptionUtil {
|
|||
Log.w(TAG, String.valueOf(envelope.getTimestamp()), e);
|
||||
Recipient sender = Recipient.external(context, e.getSender());
|
||||
|
||||
if (sender.supportsMessageRetries() && Recipient.self().supportsMessageRetries() && FeatureFlags.senderKey()) {
|
||||
if (sender.supportsMessageRetries() && Recipient.self().supportsMessageRetries() && FeatureFlags.retryReceipts()) {
|
||||
jobs.add(handleRetry(context, sender, envelope, e));
|
||||
postInternalErrorNotification(context);
|
||||
} else {
|
||||
|
|
|
@ -78,7 +78,8 @@ public final class FeatureFlags {
|
|||
private static final String MEDIA_QUALITY_LEVELS = "android.mediaQuality.levels";
|
||||
private static final String RETRY_RECEIPT_LIFESPAN = "android.retryReceiptLifespan";
|
||||
private static final String RETRY_RESPOND_MAX_AGE = "android.retryRespondMaxAge";
|
||||
private static final String SENDER_KEY = "android.senderKey.3";
|
||||
private static final String SENDER_KEY = "android.senderKey.4";
|
||||
private static final String RETRY_RECEIPTS = "android.retryReceipts";
|
||||
private static final String SUGGEST_SMS_BLACKLIST = "android.suggestSmsBlacklist";
|
||||
private static final String ANNOUNCEMENT_GROUPS = "android.announcementGroups";
|
||||
|
||||
|
@ -114,6 +115,7 @@ public final class FeatureFlags {
|
|||
RETRY_RECEIPT_LIFESPAN,
|
||||
RETRY_RESPOND_MAX_AGE,
|
||||
SENDER_KEY,
|
||||
RETRY_RECEIPTS,
|
||||
SUGGEST_SMS_BLACKLIST,
|
||||
ANNOUNCEMENT_GROUPS
|
||||
);
|
||||
|
@ -162,7 +164,9 @@ public final class FeatureFlags {
|
|||
MEDIA_QUALITY_LEVELS,
|
||||
RETRY_RECEIPT_LIFESPAN,
|
||||
RETRY_RESPOND_MAX_AGE,
|
||||
SUGGEST_SMS_BLACKLIST
|
||||
SUGGEST_SMS_BLACKLIST,
|
||||
RETRY_RECEIPTS,
|
||||
SENDER_KEY
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -349,6 +353,11 @@ public final class FeatureFlags {
|
|||
return getString(MEDIA_QUALITY_LEVELS, "");
|
||||
}
|
||||
|
||||
/** Whether or not sending or responding to retry receipts is enabled. */
|
||||
public static boolean retryReceipts() {
|
||||
return getBoolean(RETRY_RECEIPTS, false);
|
||||
}
|
||||
|
||||
/** How long to wait before considering a retry to be a failure. */
|
||||
public static long retryReceiptLifespan() {
|
||||
return getLong(RETRY_RECEIPT_LIFESPAN, TimeUnit.HOURS.toMillis(1));
|
||||
|
|
Ładowanie…
Reference in New Issue