mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 02:25:19 +00:00
Fix sync message sending.
This commit is contained in:
parent
ed6ca6a64a
commit
96fa96f5c1
@ -127,15 +127,6 @@ fun signAndSendPairingAuthorisationMessage(context: Context, pairingAuthorisatio
|
||||
|
||||
}
|
||||
|
||||
fun shouldSendSycMessage(context: Context, address: Address): Promise<Boolean, Exception> {
|
||||
if (address.isGroup || address.isEmail || address.isMmsGroup) {
|
||||
return Promise.of(false)
|
||||
}
|
||||
|
||||
// Don't send sync messages if it's one of our devices
|
||||
return isOneOfOurDevices(context, address).map { !it }
|
||||
}
|
||||
|
||||
fun isOneOfOurDevices(context: Context, address: Address): Promise<Boolean, Exception> {
|
||||
if (address.isGroup || address.isEmail || address.isMmsGroup) {
|
||||
return Promise.of(false)
|
||||
|
@ -288,6 +288,7 @@ public class MessageSender {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we get here then we are sending a message to a device that is not ours
|
||||
boolean[] hasSentSyncMessage = { false };
|
||||
MultiDeviceUtilities.getAllDevicePublicKeysWithFriendStatus(context, recipientPublicKey).success(devices -> {
|
||||
int friendCount = MultiDeviceUtilities.getFriendCount(context, devices.keySet());
|
||||
@ -302,24 +303,13 @@ public class MessageSender {
|
||||
if (isFriend) {
|
||||
// Send a normal message if the user is friends with the recipient
|
||||
// We should also send a sync message if we haven't already sent one
|
||||
Promise<Boolean, Exception> promise = Promise.Companion.of(false, Kovenant.INSTANCE.getContext());
|
||||
if (!hasSentSyncMessage[0]) {
|
||||
promise = MultiDeviceUtilities.shouldSendSycMessage(context, address).success(value -> {
|
||||
hasSentSyncMessage[0] = value;
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
boolean shouldSendSyncMessage = !hasSentSyncMessage[0] && address.isPhone();
|
||||
if (type == MessageType.MEDIA) {
|
||||
PushMediaSendJob.enqueue(context, jobManager, messageId, messageIDToUse, address, shouldSendSyncMessage);
|
||||
} else {
|
||||
jobManager.add(new PushTextSendJob(messageId, messageIDToUse, address, shouldSendSyncMessage));
|
||||
}
|
||||
|
||||
promise.success(shouldSendSyncMessage -> {
|
||||
Util.runOnMain(() -> {
|
||||
if (type == MessageType.MEDIA) {
|
||||
PushMediaSendJob.enqueue(context, jobManager, messageId, messageIDToUse, address, shouldSendSyncMessage);
|
||||
} else {
|
||||
jobManager.add(new PushTextSendJob(messageId, messageIDToUse, address, shouldSendSyncMessage));
|
||||
}
|
||||
});
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
if (shouldSendSyncMessage) { hasSentSyncMessage[0] = true; }
|
||||
} else {
|
||||
// Send friend requests to non friends. If the user is friends with any
|
||||
// of the devices then send out a default friend request message.
|
||||
|
Loading…
Reference in New Issue
Block a user