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> {
|
fun isOneOfOurDevices(context: Context, address: Address): Promise<Boolean, Exception> {
|
||||||
if (address.isGroup || address.isEmail || address.isMmsGroup) {
|
if (address.isGroup || address.isEmail || address.isMmsGroup) {
|
||||||
return Promise.of(false)
|
return Promise.of(false)
|
||||||
|
@ -288,6 +288,7 @@ public class MessageSender {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we get here then we are sending a message to a device that is not ours
|
||||||
boolean[] hasSentSyncMessage = { false };
|
boolean[] hasSentSyncMessage = { false };
|
||||||
MultiDeviceUtilities.getAllDevicePublicKeysWithFriendStatus(context, recipientPublicKey).success(devices -> {
|
MultiDeviceUtilities.getAllDevicePublicKeysWithFriendStatus(context, recipientPublicKey).success(devices -> {
|
||||||
int friendCount = MultiDeviceUtilities.getFriendCount(context, devices.keySet());
|
int friendCount = MultiDeviceUtilities.getFriendCount(context, devices.keySet());
|
||||||
@ -302,24 +303,13 @@ public class MessageSender {
|
|||||||
if (isFriend) {
|
if (isFriend) {
|
||||||
// Send a normal message if the user is friends with the recipient
|
// 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
|
// 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());
|
boolean shouldSendSyncMessage = !hasSentSyncMessage[0] && address.isPhone();
|
||||||
if (!hasSentSyncMessage[0]) {
|
if (type == MessageType.MEDIA) {
|
||||||
promise = MultiDeviceUtilities.shouldSendSycMessage(context, address).success(value -> {
|
PushMediaSendJob.enqueue(context, jobManager, messageId, messageIDToUse, address, shouldSendSyncMessage);
|
||||||
hasSentSyncMessage[0] = value;
|
} else {
|
||||||
return Unit.INSTANCE;
|
jobManager.add(new PushTextSendJob(messageId, messageIDToUse, address, shouldSendSyncMessage));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
if (shouldSendSyncMessage) { hasSentSyncMessage[0] = true; }
|
||||||
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;
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
// Send friend requests to non friends. If the user is friends with any
|
// Send friend requests to non friends. If the user is friends with any
|
||||||
// of the devices then send out a default friend request message.
|
// of the devices then send out a default friend request message.
|
||||||
|
Loading…
Reference in New Issue
Block a user