mirror of
https://github.com/oxen-io/session-android.git
synced 2025-05-01 16:20:47 +00:00
Only populate sync message context if sender == recipient.
// FREEBIE
This commit is contained in:
parent
68a3076be4
commit
e99129ec42
@ -70,7 +70,7 @@ public class TextSecureMessageSender {
|
|||||||
|
|
||||||
private final PushServiceSocket socket;
|
private final PushServiceSocket socket;
|
||||||
private final AxolotlStore store;
|
private final AxolotlStore store;
|
||||||
private final TextSecureAddress syncAddress;
|
private final TextSecureAddress localAddress;
|
||||||
private final Optional<EventListener> eventListener;
|
private final Optional<EventListener> eventListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,7 +91,7 @@ public class TextSecureMessageSender {
|
|||||||
{
|
{
|
||||||
this.socket = new PushServiceSocket(url, trustStore, new StaticCredentialsProvider(user, password, null));
|
this.socket = new PushServiceSocket(url, trustStore, new StaticCredentialsProvider(user, password, null));
|
||||||
this.store = store;
|
this.store = store;
|
||||||
this.syncAddress = new TextSecureAddress(user);
|
this.localAddress = new TextSecureAddress(user);
|
||||||
this.eventListener = eventListener;
|
this.eventListener = eventListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ public class TextSecureMessageSender {
|
|||||||
|
|
||||||
if (response != null && response.getNeedsSync()) {
|
if (response != null && response.getNeedsSync()) {
|
||||||
byte[] syncMessage = createSyncMessageContent(content, Optional.of(recipient), timestamp);
|
byte[] syncMessage = createSyncMessageContent(content, Optional.of(recipient), timestamp);
|
||||||
sendMessage(syncAddress, timestamp, syncMessage);
|
sendMessage(localAddress, timestamp, syncMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.isEndSession()) {
|
if (message.isEndSession()) {
|
||||||
@ -153,7 +153,7 @@ public class TextSecureMessageSender {
|
|||||||
try {
|
try {
|
||||||
if (response != null && response.getNeedsSync()) {
|
if (response != null && response.getNeedsSync()) {
|
||||||
byte[] syncMessage = createSyncMessageContent(content, Optional.<TextSecureAddress>absent(), timestamp);
|
byte[] syncMessage = createSyncMessageContent(content, Optional.<TextSecureAddress>absent(), timestamp);
|
||||||
sendMessage(syncAddress, timestamp, syncMessage);
|
sendMessage(localAddress, timestamp, syncMessage);
|
||||||
}
|
}
|
||||||
} catch (UntrustedIdentityException e) {
|
} catch (UntrustedIdentityException e) {
|
||||||
throw new EncapsulatedExceptions(e);
|
throw new EncapsulatedExceptions(e);
|
||||||
@ -319,7 +319,7 @@ public class TextSecureMessageSender {
|
|||||||
{
|
{
|
||||||
List<OutgoingPushMessage> messages = new LinkedList<>();
|
List<OutgoingPushMessage> messages = new LinkedList<>();
|
||||||
|
|
||||||
if (!recipient.equals(syncAddress)) {
|
if (!recipient.equals(localAddress)) {
|
||||||
messages.add(getEncryptedMessage(socket, recipient, TextSecureAddress.DEFAULT_DEVICE_ID, plaintext));
|
messages.add(getEncryptedMessage(socket, recipient, TextSecureAddress.DEFAULT_DEVICE_ID, plaintext));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ public class TextSecureMessageSender {
|
|||||||
throws IOException, UntrustedIdentityException
|
throws IOException, UntrustedIdentityException
|
||||||
{
|
{
|
||||||
AxolotlAddress axolotlAddress = new AxolotlAddress(recipient.getNumber(), deviceId);
|
AxolotlAddress axolotlAddress = new AxolotlAddress(recipient.getNumber(), deviceId);
|
||||||
TextSecureCipher cipher = new TextSecureCipher(store);
|
TextSecureCipher cipher = new TextSecureCipher(localAddress, store);
|
||||||
|
|
||||||
if (!store.containsSession(axolotlAddress)) {
|
if (!store.containsSession(axolotlAddress)) {
|
||||||
try {
|
try {
|
||||||
|
@ -38,8 +38,8 @@ import org.whispersystems.textsecure.api.messages.TextSecureEnvelope;
|
|||||||
import org.whispersystems.textsecure.api.messages.TextSecureGroup;
|
import org.whispersystems.textsecure.api.messages.TextSecureGroup;
|
||||||
import org.whispersystems.textsecure.api.messages.TextSecureMessage;
|
import org.whispersystems.textsecure.api.messages.TextSecureMessage;
|
||||||
import org.whispersystems.textsecure.api.messages.TextSecureSyncContext;
|
import org.whispersystems.textsecure.api.messages.TextSecureSyncContext;
|
||||||
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
import org.whispersystems.textsecure.internal.push.OutgoingPushMessage;
|
import org.whispersystems.textsecure.internal.push.OutgoingPushMessage;
|
||||||
import org.whispersystems.textsecure.internal.push.PushMessageProtos;
|
|
||||||
import org.whispersystems.textsecure.internal.push.PushTransportDetails;
|
import org.whispersystems.textsecure.internal.push.PushTransportDetails;
|
||||||
import org.whispersystems.textsecure.internal.util.Base64;
|
import org.whispersystems.textsecure.internal.util.Base64;
|
||||||
|
|
||||||
@ -57,10 +57,12 @@ import static org.whispersystems.textsecure.internal.push.PushMessageProtos.Push
|
|||||||
*/
|
*/
|
||||||
public class TextSecureCipher {
|
public class TextSecureCipher {
|
||||||
|
|
||||||
private final AxolotlStore axolotlStore;
|
private final AxolotlStore axolotlStore;
|
||||||
|
private final TextSecureAddress localAddress;
|
||||||
|
|
||||||
public TextSecureCipher(AxolotlStore axolotlStore) {
|
public TextSecureCipher(TextSecureAddress localAddress, AxolotlStore axolotlStore) {
|
||||||
this.axolotlStore = axolotlStore;
|
this.axolotlStore = axolotlStore;
|
||||||
|
this.localAddress = localAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OutgoingPushMessage encrypt(AxolotlAddress destination, byte[] unpaddedMessage) {
|
public OutgoingPushMessage encrypt(AxolotlAddress destination, byte[] unpaddedMessage) {
|
||||||
@ -127,7 +129,7 @@ public class TextSecureCipher {
|
|||||||
|
|
||||||
private TextSecureMessage createTextSecureMessage(TextSecureEnvelope envelope, PushMessageContent content) {
|
private TextSecureMessage createTextSecureMessage(TextSecureEnvelope envelope, PushMessageContent content) {
|
||||||
TextSecureGroup groupInfo = createGroupInfo(envelope, content);
|
TextSecureGroup groupInfo = createGroupInfo(envelope, content);
|
||||||
TextSecureSyncContext syncContext = createSyncContext(content);
|
TextSecureSyncContext syncContext = createSyncContext(envelope, content);
|
||||||
List<TextSecureAttachment> attachments = new LinkedList<>();
|
List<TextSecureAttachment> attachments = new LinkedList<>();
|
||||||
boolean endSession = ((content.getFlags() & PushMessageContent.Flags.END_SESSION_VALUE) != 0);
|
boolean endSession = ((content.getFlags() & PushMessageContent.Flags.END_SESSION_VALUE) != 0);
|
||||||
boolean secure = envelope.isWhisperMessage() || envelope.isPreKeyWhisperMessage();
|
boolean secure = envelope.isWhisperMessage() || envelope.isPreKeyWhisperMessage();
|
||||||
@ -143,8 +145,9 @@ public class TextSecureCipher {
|
|||||||
content.getBody(), syncContext, secure, endSession);
|
content.getBody(), syncContext, secure, endSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextSecureSyncContext createSyncContext(PushMessageContent content) {
|
private TextSecureSyncContext createSyncContext(TextSecureEnvelope envelope, PushMessageContent content) {
|
||||||
if (!content.hasSync()) return null;
|
if (!content.hasSync()) return null;
|
||||||
|
if (!envelope.getSource().equals(localAddress.getNumber())) return null;
|
||||||
|
|
||||||
return new TextSecureSyncContext(content.getSync().getDestination(),
|
return new TextSecureSyncContext(content.getSync().getDestination(),
|
||||||
content.getSync().getTimestamp());
|
content.getSync().getTimestamp());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user