Fix bug causing call requests to not be handled properly.

This commit is contained in:
Cody Henthorne
2020-08-19 15:49:16 -04:00
committed by GitHub
parent cdae919b5e
commit ef6a5b6599
2 changed files with 23 additions and 6 deletions

View File

@@ -17,7 +17,6 @@ import org.thoughtcrime.securesms.groups.GroupChangeBusyException;
import org.thoughtcrime.securesms.groups.GroupChangeException;
import org.thoughtcrime.securesms.groups.GroupChangeFailedException;
import org.thoughtcrime.securesms.groups.GroupManager;
import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob;
import org.thoughtcrime.securesms.jobs.MultiDeviceBlockedUpdateJob;
import org.thoughtcrime.securesms.jobs.MultiDeviceMessageRequestResponseJob;
import org.thoughtcrime.securesms.jobs.RotateProfileKeyJob;
@@ -201,6 +200,20 @@ public class RecipientUtil {
return isMessageRequestAccepted(context, threadId, threadRecipient);
}
/**
* Like {@link #isMessageRequestAccepted(Context, long)} but with fewer checks around messages so it
* is more likely to return false.
*/
@WorkerThread
public static boolean isCallRequestAccepted(@NonNull Context context, @Nullable Recipient threadRecipient) {
if (threadRecipient == null) {
return true;
}
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(threadRecipient);
return isCallRequestAccepted(context, threadId, threadRecipient);
}
/**
* @return True if a conversation existed before we enabled message requests, otherwise false.
*/
@@ -244,6 +257,14 @@ public class RecipientUtil {
isPreMessageRequestThread(context, threadId);
}
@WorkerThread
private static boolean isCallRequestAccepted(@NonNull Context context, long threadId, @NonNull Recipient threadRecipient) {
return threadRecipient.isProfileSharing() ||
threadRecipient.isSystemContact() ||
hasSentMessageInThread(context, threadId) ||
isPreMessageRequestThread(context, threadId);
}
@WorkerThread
private static boolean hasSentMessageInThread(@NonNull Context context, long threadId) {
return DatabaseFactory.getMmsSmsDatabase(context).getOutgoingSecureConversationCount(threadId) != 0;