improved strategy for ignoring self addressed jingle messages

This commit is contained in:
Daniel Gultsch 2020-04-10 21:18:43 +02:00
parent 7b382d2ba5
commit 5eea961155
2 changed files with 18 additions and 16 deletions

View File

@ -92,8 +92,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 28 targetSdkVersion 28
versionCode 367 versionCode 368
versionName "2.8.0-alpha" versionName "2.8.0-alpha.2"
archivesBaseName += "-$versionName" archivesBaseName += "-$versionName"
applicationId "eu.siacs.conversations" applicationId "eu.siacs.conversations"
resValue "string", "applicationId", applicationId resValue "string", "applicationId", applicationId

View File

@ -127,15 +127,17 @@ public class JingleConnectionManager extends AbstractConnectionManager {
} }
return; return;
} }
final boolean carbonCopy = from.asBareJid().equals(account.getJid().asBareJid()); final boolean addressedToSelf = from.asBareJid().equals(account.getJid().asBareJid());
final Jid with; final AbstractJingleConnection.Id id;
if (account.getJid().asBareJid().equals(from.asBareJid())) { if (addressedToSelf) {
with = to; if (to.isFullJid()) {
id = AbstractJingleConnection.Id.of(account, to, sessionId);
} else { } else {
with = from; return;
}
} else {
id = AbstractJingleConnection.Id.of(account, from, sessionId);
} }
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received jingle message from " + from + " with=" + with + " " + message);
final AbstractJingleConnection.Id id = AbstractJingleConnection.Id.of(account, with, sessionId);
final AbstractJingleConnection existingJingleConnection = connections.get(id); final AbstractJingleConnection existingJingleConnection = connections.get(id);
if (existingJingleConnection != null) { if (existingJingleConnection != null) {
if (existingJingleConnection instanceof JingleRtpConnection) { if (existingJingleConnection instanceof JingleRtpConnection) {
@ -145,9 +147,9 @@ public class JingleConnectionManager extends AbstractConnectionManager {
} }
return; return;
} }
if (carbonCopy) {
if (addressedToSelf) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ignore jingle message from self"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ignore jingle message from self");
return;
} }
if ("propose".equals(message.getName())) { if ("propose".equals(message.getName())) {
@ -158,7 +160,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
final MessagePacket reject = mXmppConnectionService.getMessageGenerator().sessionReject(from, sessionId); final MessagePacket reject = mXmppConnectionService.getMessageGenerator().sessionReject(from, sessionId);
mXmppConnectionService.sendMessagePacket(account, reject); mXmppConnectionService.sendMessagePacket(account, reject);
} else { } else {
final JingleRtpConnection rtpConnection = new JingleRtpConnection(this, id, with); final JingleRtpConnection rtpConnection = new JingleRtpConnection(this, id, from);
this.connections.put(id, rtpConnection); this.connections.put(id, rtpConnection);
rtpConnection.deliveryMessage(from, message); rtpConnection.deliveryMessage(from, message);
} }
@ -167,7 +169,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
} }
} else if ("proceed".equals(message.getName())) { } else if ("proceed".equals(message.getName())) {
final RtpSessionProposal proposal = new RtpSessionProposal(account, with.asBareJid(), sessionId); final RtpSessionProposal proposal = new RtpSessionProposal(account, from.asBareJid(), sessionId);
synchronized (rtpSessionProposals) { synchronized (rtpSessionProposals) {
if (rtpSessionProposals.remove(proposal) != null) { if (rtpSessionProposals.remove(proposal) != null) {
final JingleRtpConnection rtpConnection = new JingleRtpConnection(this, id, account.getJid()); final JingleRtpConnection rtpConnection = new JingleRtpConnection(this, id, account.getJid());
@ -175,16 +177,16 @@ public class JingleConnectionManager extends AbstractConnectionManager {
rtpConnection.transitionOrThrow(AbstractJingleConnection.State.PROPOSED); rtpConnection.transitionOrThrow(AbstractJingleConnection.State.PROPOSED);
rtpConnection.deliveryMessage(from, message); rtpConnection.deliveryMessage(from, message);
} else { } else {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": no rtp session proposal found for " + with + " to deliver proceed"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": no rtp session proposal found for " + from + " to deliver proceed");
} }
} }
} else if ("reject".equals(message.getName())) { } else if ("reject".equals(message.getName())) {
final RtpSessionProposal proposal = new RtpSessionProposal(account, with.asBareJid(), sessionId); final RtpSessionProposal proposal = new RtpSessionProposal(account, from.asBareJid(), sessionId);
synchronized (rtpSessionProposals) { synchronized (rtpSessionProposals) {
if (rtpSessionProposals.remove(proposal) != null) { if (rtpSessionProposals.remove(proposal) != null) {
mXmppConnectionService.notifyJingleRtpConnectionUpdate(account, proposal.with, proposal.sessionId, RtpEndUserState.DECLINED_OR_BUSY); mXmppConnectionService.notifyJingleRtpConnectionUpdate(account, proposal.with, proposal.sessionId, RtpEndUserState.DECLINED_OR_BUSY);
} else { } else {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": no rtp session proposal found for " + with + " to deliver reject"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": no rtp session proposal found for " + from + " to deliver reject");
} }
} }
} else { } else {