mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 12:28:24 +00:00
feat: add push notifying in the message sender to prevent self sends
This commit is contained in:
parent
e89f54a0b9
commit
7d7dbd7632
@ -127,7 +127,7 @@ public class PushGroupUpdateJob extends BaseJob implements InjectableType {
|
|||||||
|
|
||||||
messageSender.sendMessage(0, new SignalServiceAddress(source),
|
messageSender.sendMessage(0, new SignalServiceAddress(source),
|
||||||
UnidentifiedAccessUtil.getAccessFor(context, Recipient.from(context, Address.Companion.fromSerialized(source), false)),
|
UnidentifiedAccessUtil.getAccessFor(context, Recipient.from(context, Address.Companion.fromSerialized(source), false)),
|
||||||
message);
|
message, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -287,14 +287,14 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
|||||||
|
|
||||||
if (SessionMetaProtocol.shared.isNoteToSelf(address.getNumber())) {
|
if (SessionMetaProtocol.shared.isNoteToSelf(address.getNumber())) {
|
||||||
// Loki - Device link messages don't go through here
|
// Loki - Device link messages don't go through here
|
||||||
SendMessageResult result = messageSender.sendMessage(messageId, address, unidentifiedAccessPair, mediaMessage);
|
SendMessageResult result = messageSender.sendMessage(messageId, address, unidentifiedAccessPair, mediaMessage, true);
|
||||||
if (result.getLokiAPIError() != null) {
|
if (result.getLokiAPIError() != null) {
|
||||||
throw result.getLokiAPIError();
|
throw result.getLokiAPIError();
|
||||||
} else {
|
} else {
|
||||||
return result.getSuccess().isUnidentified();
|
return result.getSuccess().isUnidentified();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SendMessageResult result = messageSender.sendMessage(messageId, address, unidentifiedAccessPair, mediaMessage);
|
SendMessageResult result = messageSender.sendMessage(messageId, address, unidentifiedAccessPair, mediaMessage, false);
|
||||||
if (result.getLokiAPIError() != null) {
|
if (result.getLokiAPIError() != null) {
|
||||||
throw result.getLokiAPIError();
|
throw result.getLokiAPIError();
|
||||||
} else {
|
} else {
|
||||||
@ -303,7 +303,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
|||||||
try {
|
try {
|
||||||
// send to ourselves to sync multi-device
|
// send to ourselves to sync multi-device
|
||||||
Optional<UnidentifiedAccessPair> syncAccess = UnidentifiedAccessUtil.getAccessForSync(context);
|
Optional<UnidentifiedAccessPair> syncAccess = UnidentifiedAccessUtil.getAccessForSync(context);
|
||||||
SendMessageResult selfSendResult = messageSender.sendMessage(messageId, localAddress, syncAccess, mediaSelfSendMessage);
|
SendMessageResult selfSendResult = messageSender.sendMessage(messageId, localAddress, syncAccess, mediaSelfSendMessage, true);
|
||||||
if (selfSendResult.getLokiAPIError() != null) {
|
if (selfSendResult.getLokiAPIError() != null) {
|
||||||
throw selfSendResult.getLokiAPIError();
|
throw selfSendResult.getLokiAPIError();
|
||||||
}
|
}
|
||||||
|
@ -226,14 +226,14 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
|||||||
|
|
||||||
if (SessionMetaProtocol.shared.isNoteToSelf(address.getNumber())) {
|
if (SessionMetaProtocol.shared.isNoteToSelf(address.getNumber())) {
|
||||||
// Loki - Device link messages don't go through here
|
// Loki - Device link messages don't go through here
|
||||||
SendMessageResult result = messageSender.sendMessage(messageId, address, unidentifiedAccess, textSecureMessage);
|
SendMessageResult result = messageSender.sendMessage(messageId, address, unidentifiedAccess, textSecureMessage, true);
|
||||||
if (result.getLokiAPIError() != null) {
|
if (result.getLokiAPIError() != null) {
|
||||||
throw result.getLokiAPIError();
|
throw result.getLokiAPIError();
|
||||||
} else {
|
} else {
|
||||||
return result.getSuccess().isUnidentified();
|
return result.getSuccess().isUnidentified();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SendMessageResult result = messageSender.sendMessage(messageId, address, unidentifiedAccess, textSecureMessage);
|
SendMessageResult result = messageSender.sendMessage(messageId, address, unidentifiedAccess, textSecureMessage, false);
|
||||||
if (result.getLokiAPIError() != null) {
|
if (result.getLokiAPIError() != null) {
|
||||||
throw result.getLokiAPIError();
|
throw result.getLokiAPIError();
|
||||||
} else {
|
} else {
|
||||||
@ -242,7 +242,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
|||||||
try {
|
try {
|
||||||
// send to ourselves to sync multi-device
|
// send to ourselves to sync multi-device
|
||||||
Optional<UnidentifiedAccessPair> syncAccess = UnidentifiedAccessUtil.getAccessForSync(context);
|
Optional<UnidentifiedAccessPair> syncAccess = UnidentifiedAccessUtil.getAccessForSync(context);
|
||||||
SendMessageResult selfSendResult = messageSender.sendMessage(messageId, localAddress, syncAccess, textSecureSelfSendMessage);
|
SendMessageResult selfSendResult = messageSender.sendMessage(messageId, localAddress, syncAccess, textSecureSelfSendMessage, true);
|
||||||
if (selfSendResult.getLokiAPIError() != null) {
|
if (selfSendResult.getLokiAPIError() != null) {
|
||||||
throw selfSendResult.getLokiAPIError();
|
throw selfSendResult.getLokiAPIError();
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public class RequestGroupInfoJob extends BaseJob implements InjectableType {
|
|||||||
|
|
||||||
messageSender.sendMessage(0, new SignalServiceAddress(source),
|
messageSender.sendMessage(0, new SignalServiceAddress(source),
|
||||||
UnidentifiedAccessUtil.getAccessFor(context, Recipient.from(context, Address.Companion.fromExternal(context, source), false)),
|
UnidentifiedAccessUtil.getAccessFor(context, Recipient.from(context, Address.Companion.fromExternal(context, source), false)),
|
||||||
message);
|
message, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -241,14 +241,15 @@ public class SignalServiceMessageSender {
|
|||||||
public SendMessageResult sendMessage(long messageID,
|
public SendMessageResult sendMessage(long messageID,
|
||||||
SignalServiceAddress recipient,
|
SignalServiceAddress recipient,
|
||||||
Optional<UnidentifiedAccessPair> unidentifiedAccess,
|
Optional<UnidentifiedAccessPair> unidentifiedAccess,
|
||||||
SignalServiceDataMessage message)
|
SignalServiceDataMessage message,
|
||||||
|
boolean isSelfSend)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
byte[] content = createMessageContent(message, recipient);
|
byte[] content = createMessageContent(message, recipient);
|
||||||
long timestamp = message.getTimestamp();
|
long timestamp = message.getTimestamp();
|
||||||
boolean useFallbackEncryption = SessionManagementProtocol.shared.shouldMessageUseFallbackEncryption(message, recipient.getNumber(), store);
|
boolean useFallbackEncryption = SessionManagementProtocol.shared.shouldMessageUseFallbackEncryption(message, recipient.getNumber(), store);
|
||||||
boolean isClosedGroup = message.group.isPresent() && message.group.get().getGroupType() == SignalServiceGroup.GroupType.SIGNAL;
|
boolean isClosedGroup = message.group.isPresent() && message.group.get().getGroupType() == SignalServiceGroup.GroupType.SIGNAL;
|
||||||
SendMessageResult result = sendMessage(messageID, recipient, getTargetUnidentifiedAccess(unidentifiedAccess), timestamp, content, false, message.getTTL(), message.getDeviceLink().isPresent(), useFallbackEncryption, isClosedGroup, message.hasVisibleContent(), message.getSyncTarget());
|
SendMessageResult result = sendMessage(messageID, recipient, getTargetUnidentifiedAccess(unidentifiedAccess), timestamp, content, false, message.getTTL(), message.getDeviceLink().isPresent(), useFallbackEncryption, isClosedGroup, message.hasVisibleContent() && !isSelfSend, message.getSyncTarget());
|
||||||
|
|
||||||
// // Loki - This shouldn't get invoked for note to self
|
// // Loki - This shouldn't get invoked for note to self
|
||||||
// boolean wouldSignalSendSyncMessage = (result.getSuccess() != null && result.getSuccess().isNeedsSync()) || unidentifiedAccess.isPresent();
|
// boolean wouldSignalSendSyncMessage = (result.getSuccess() != null && result.getSuccess().isNeedsSync()) || unidentifiedAccess.isPresent();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user