mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-28 21:50:45 +00:00
Partially unbork accepting FRs sent by slave devices
This commit is contained in:
parent
92b4b81935
commit
40bc3bfda0
@ -1409,7 +1409,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
// TODO: Burn this with fire when we can
|
// TODO: Burn this with fire when we can
|
||||||
PromiseUtilities.timeout(LokiFileServerAPI.shared.getDeviceLinks(publicKey, false), 4000).get();
|
PromiseUtilities.timeout(LokiFileServerAPI.shared.getDeviceLinks(publicKey, false), 6000).get();
|
||||||
String masterPublicKey = org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol.shared.getMasterDevice(publicKey);
|
String masterPublicKey = org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol.shared.getMasterDevice(publicKey);
|
||||||
if (masterPublicKey == null) {
|
if (masterPublicKey == null) {
|
||||||
masterPublicKey = publicKey;
|
masterPublicKey = publicKey;
|
||||||
@ -1441,7 +1441,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
// TODO: Burn this with fire when we can
|
// TODO: Burn this with fire when we can
|
||||||
PromiseUtilities.timeout(LokiFileServerAPI.shared.getDeviceLinks(publicKey, false), 4000).get();
|
PromiseUtilities.timeout(LokiFileServerAPI.shared.getDeviceLinks(publicKey, false), 6000).get();
|
||||||
String masterPublicKey = org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol.shared.getMasterDevice(publicKey);
|
String masterPublicKey = org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol.shared.getMasterDevice(publicKey);
|
||||||
if (masterPublicKey == null) {
|
if (masterPublicKey == null) {
|
||||||
masterPublicKey = publicKey;
|
masterPublicKey = publicKey;
|
||||||
|
@ -8,6 +8,7 @@ import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore
|
|||||||
import org.thoughtcrime.securesms.database.Address
|
import org.thoughtcrime.securesms.database.Address
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
import org.thoughtcrime.securesms.loki.utilities.recipient
|
import org.thoughtcrime.securesms.loki.utilities.recipient
|
||||||
|
import org.thoughtcrime.securesms.loki.utilities.timeout
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient
|
import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.sms.MessageSender
|
import org.thoughtcrime.securesms.sms.MessageSender
|
||||||
import org.thoughtcrime.securesms.util.GroupUtil
|
import org.thoughtcrime.securesms.util.GroupUtil
|
||||||
@ -30,7 +31,7 @@ object ClosedGroupsProtocol {
|
|||||||
if (!conversation.address.isClosedGroup || groupID == null) { return false }
|
if (!conversation.address.isClosedGroup || groupID == null) { return false }
|
||||||
// A closed group's members should never include slave devices
|
// A closed group's members should never include slave devices
|
||||||
val senderPublicKey = content.sender
|
val senderPublicKey = content.sender
|
||||||
LokiFileServerAPI.shared.getDeviceLinks(senderPublicKey).get()
|
LokiFileServerAPI.shared.getDeviceLinks(senderPublicKey).timeout(6000).get()
|
||||||
val senderMasterPublicKey = MultiDeviceProtocol.shared.getMasterDevice(senderPublicKey)
|
val senderMasterPublicKey = MultiDeviceProtocol.shared.getMasterDevice(senderPublicKey)
|
||||||
val publicKeyToCheckFor = senderMasterPublicKey ?: senderPublicKey
|
val publicKeyToCheckFor = senderMasterPublicKey ?: senderPublicKey
|
||||||
val members = DatabaseFactory.getGroupDatabase(context).getGroupMembers(groupID, true)
|
val members = DatabaseFactory.getGroupDatabase(context).getGroupMembers(groupID, true)
|
||||||
|
@ -224,9 +224,17 @@ object FriendRequestProtocol {
|
|||||||
// friend request status is reset to NONE. Bob now sends Alice a friend request. Alice's thread's
|
// friend request status is reset to NONE. Bob now sends Alice a friend request. Alice's thread's
|
||||||
// friend request status is reset to RECEIVED
|
// friend request status is reset to RECEIVED
|
||||||
lokiThreadDB.setFriendRequestStatus(threadID, LokiThreadFriendRequestStatus.REQUEST_RECEIVED)
|
lokiThreadDB.setFriendRequestStatus(threadID, LokiThreadFriendRequestStatus.REQUEST_RECEIVED)
|
||||||
val lastMessageID = getLastMessageID(context, threadID)
|
val masterPublicKey = MultiDeviceProtocol.shared.getMasterDevice(publicKey) ?: publicKey
|
||||||
if (lastMessageID != null) {
|
val masterThreadID = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient(context, masterPublicKey))
|
||||||
DatabaseFactory.getLokiMessageDatabase(context).setFriendRequestStatus(lastMessageID, LokiMessageFriendRequestStatus.REQUEST_PENDING)
|
val masterThreadLastMessageID = getLastMessageID(context, masterThreadID) // Messages get routed into the master thread
|
||||||
|
if (masterThreadLastMessageID != null) {
|
||||||
|
DatabaseFactory.getLokiMessageDatabase(context).setFriendRequestStatus(masterThreadLastMessageID, LokiMessageFriendRequestStatus.REQUEST_PENDING)
|
||||||
|
} else {
|
||||||
|
// Device link fetching could fail, in which case the message could get routed into the slave thread
|
||||||
|
val slaveThreadLastMessageID = getLastMessageID(context, threadID)
|
||||||
|
if (slaveThreadLastMessageID != null) {
|
||||||
|
DatabaseFactory.getLokiMessageDatabase(context).setFriendRequestStatus(slaveThreadLastMessageID, LokiMessageFriendRequestStatus.REQUEST_PENDING)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user