mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 13:08:46 +00:00
Add more logging around missing RecipientId.
This commit is contained in:
committed by
Cody Henthorne
parent
f5215d715a
commit
bce133ac28
@@ -601,7 +601,11 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
}
|
||||
|
||||
val recipientId = RecipientId.from(id)
|
||||
update(recipientId, groupUpdates)
|
||||
val updateSuccess = update(recipientId, groupUpdates)
|
||||
|
||||
if (!updateSuccess) {
|
||||
Log.w(TAG, "Failed to update newly-created record for $recipientId")
|
||||
}
|
||||
|
||||
return recipientId
|
||||
}
|
||||
|
||||
@@ -114,15 +114,11 @@ class PushProcessMessageJob private constructor(
|
||||
}
|
||||
|
||||
fun processOrDefer(messageProcessor: MessageContentProcessor, result: MessageDecryptor.Result.Success, localReceiveMetric: SignalLocalMetrics.MessageReceive): PushProcessMessageJob? {
|
||||
val queueName: String
|
||||
|
||||
val groupContext = GroupUtil.getGroupContextIfPresent(result.content)
|
||||
val groupId = groupContext?.groupId
|
||||
var requireNetwork = false
|
||||
|
||||
if (groupId != null) {
|
||||
queueName = getQueueName(RecipientId.from(groupId))
|
||||
|
||||
val queueName: String = if (groupId != null) {
|
||||
if (groupId.isV2) {
|
||||
val localRevision = groups.getGroupV2Revision(groupId.requireV2())
|
||||
|
||||
@@ -131,10 +127,11 @@ class PushProcessMessageJob private constructor(
|
||||
requireNetwork = true
|
||||
}
|
||||
}
|
||||
getQueueName(RecipientId.from(groupId))
|
||||
} else if (result.content.syncMessage != null && result.content.syncMessage!!.sent != null && result.content.syncMessage!!.sent!!.destinationServiceId != null) {
|
||||
queueName = getQueueName(RecipientId.from(ServiceId.parseOrThrow(result.content.syncMessage!!.sent!!.destinationServiceId!!)))
|
||||
getQueueName(RecipientId.from(ServiceId.parseOrThrow(result.content.syncMessage!!.sent!!.destinationServiceId!!)))
|
||||
} else {
|
||||
queueName = getQueueName(RecipientId.from(result.metadata.sourceServiceId))
|
||||
getQueueName(RecipientId.from(result.metadata.sourceServiceId))
|
||||
}
|
||||
|
||||
return if (requireNetwork || !isQueueEmpty(queueName = queueName, isGroup = groupId != null)) {
|
||||
|
||||
@@ -125,11 +125,11 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
@Throws(BadGroupIdException::class)
|
||||
private fun getMessageDestination(content: Content, sender: Recipient): Recipient {
|
||||
return if (content.storyMessage != null && content.storyMessage!!.group.isValid) {
|
||||
getGroupRecipient(content.storyMessage!!.group, sender)
|
||||
getGroupRecipient(content.storyMessage?.group, sender)
|
||||
} else if (content.dataMessage.hasGroupContext) {
|
||||
getGroupRecipient(content.dataMessage!!.groupV2, sender)
|
||||
getGroupRecipient(content.dataMessage?.groupV2, sender)
|
||||
} else if (content.editMessage?.dataMessage.hasGroupContext) {
|
||||
getGroupRecipient(content.editMessage!!.dataMessage!!.groupV2, sender)
|
||||
getGroupRecipient(content.editMessage?.dataMessage?.groupV2, sender)
|
||||
} else {
|
||||
sender
|
||||
}
|
||||
|
||||
@@ -320,7 +320,14 @@ public class Recipient {
|
||||
*/
|
||||
@WorkerThread
|
||||
public static @NonNull Recipient externalPossiblyMigratedGroup(@NonNull GroupId groupId) {
|
||||
return Recipient.resolved(RecipientId.from(groupId));
|
||||
RecipientId id = RecipientId.from(groupId);
|
||||
try {
|
||||
return Recipient.resolved(id);
|
||||
} catch (RecipientTable.MissingRecipientException ex) {
|
||||
Log.w(TAG, "Could not find recipient (" + id + ") for group " + groupId + ". Clearing RecipientId cache and trying again.", ex);
|
||||
RecipientId.clearCache();
|
||||
return Recipient.resolved(SignalDatabase.recipients().getOrInsertFromPossiblyMigratedGroupId(groupId));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.annimon.stream.Stream;
|
||||
|
||||
import org.signal.core.util.DatabaseId;
|
||||
import org.signal.core.util.LongSerializer;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.util.DelimiterUtil;
|
||||
@@ -27,8 +28,9 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class RecipientId implements Parcelable, Comparable<RecipientId>, DatabaseId {
|
||||
|
||||
private static final long UNKNOWN_ID = -1;
|
||||
private static final char DELIMITER = ',';
|
||||
private static final String TAG = "RecipientId";
|
||||
private static final long UNKNOWN_ID = -1;
|
||||
private static final char DELIMITER = ',';
|
||||
|
||||
public static final RecipientId UNKNOWN = RecipientId.from(UNKNOWN_ID);
|
||||
public static final LongSerializer<RecipientId> SERIALIZER = new Serializer();
|
||||
@@ -73,6 +75,7 @@ public class RecipientId implements Parcelable, Comparable<RecipientId>, Databas
|
||||
public static @NonNull RecipientId from(@NonNull GroupId groupId) {
|
||||
RecipientId recipientId = RecipientIdCache.INSTANCE.get(groupId);
|
||||
if (recipientId == null) {
|
||||
Log.d(TAG, "RecipientId cache miss for " + groupId);
|
||||
recipientId = SignalDatabase.recipients().getOrInsertFromPossiblyMigratedGroupId(groupId);
|
||||
if (groupId.isV2()) {
|
||||
RecipientIdCache.INSTANCE.put(groupId, recipientId);
|
||||
|
||||
Reference in New Issue
Block a user