do not process JMI from offline queue as live messages
This commit is contained in:
parent
32da5853d7
commit
5158fc4530
|
@ -378,6 +378,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
final Element result = MessageArchiveService.Version.findResult(original);
|
final Element result = MessageArchiveService.Version.findResult(original);
|
||||||
final String queryId = result == null ? null : result.getAttribute("queryid");
|
final String queryId = result == null ? null : result.getAttribute("queryid");
|
||||||
final MessageArchiveService.Query query = queryId == null ? null : mXmppConnectionService.getMessageArchiveService().findQuery(queryId);
|
final MessageArchiveService.Query query = queryId == null ? null : mXmppConnectionService.getMessageArchiveService().findQuery(queryId);
|
||||||
|
final boolean offlineMessagesRetrieved = account.getXmppConnection().isOfflineMessagesRetrieved();
|
||||||
if (query != null && query.validFrom(original.getFrom())) {
|
if (query != null && query.validFrom(original.getFrom())) {
|
||||||
final Pair<MessagePacket, Long> f = original.getForwardedMessagePacket("result", query.version.namespace);
|
final Pair<MessagePacket, Long> f = original.getForwardedMessagePacket("result", query.version.namespace);
|
||||||
if (f == null) {
|
if (f == null) {
|
||||||
|
@ -852,7 +853,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
if (sessionId == null) {
|
if (sessionId == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (query == null) {
|
if (query == null && offlineMessagesRetrieved) {
|
||||||
if (serverMsgId == null) {
|
if (serverMsgId == null) {
|
||||||
serverMsgId = extractStanzaId(account, packet);
|
serverMsgId = extractStanzaId(account, packet);
|
||||||
}
|
}
|
||||||
|
@ -873,24 +874,25 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
&& contact.showInContactList()) {
|
&& contact.showInContactList()) {
|
||||||
processMessageReceipts(account, packet, remoteMsgId, null);
|
processMessageReceipts(account, packet, remoteMsgId, null);
|
||||||
}
|
}
|
||||||
} else if (query.isCatchup()) {
|
} else if ((query != null && query.isCatchup()) || !offlineMessagesRetrieved) {
|
||||||
if ("propose".equals(action)) {
|
if ("propose".equals(action)) {
|
||||||
final Element description = child.findChild("description");
|
final Element description = child.findChild("description");
|
||||||
final String namespace = description == null ? null : description.getNamespace();
|
final String namespace =
|
||||||
|
description == null ? null : description.getNamespace();
|
||||||
if (Namespace.JINGLE_APPS_RTP.equals(namespace)) {
|
if (Namespace.JINGLE_APPS_RTP.equals(namespace)) {
|
||||||
final Conversation c = mXmppConnectionService.findOrCreateConversation(account, counterpart.asBareJid(), false, false);
|
final Conversation c =
|
||||||
final Message preExistingMessage = c.findRtpSession(sessionId, status);
|
mXmppConnectionService.findOrCreateConversation(
|
||||||
|
account, counterpart.asBareJid(), false, false);
|
||||||
|
final Message preExistingMessage =
|
||||||
|
c.findRtpSession(sessionId, status);
|
||||||
if (preExistingMessage != null) {
|
if (preExistingMessage != null) {
|
||||||
preExistingMessage.setServerMsgId(serverMsgId);
|
preExistingMessage.setServerMsgId(serverMsgId);
|
||||||
mXmppConnectionService.updateMessage(preExistingMessage);
|
mXmppConnectionService.updateMessage(preExistingMessage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
final Message message = new Message(
|
final Message message =
|
||||||
c,
|
new Message(
|
||||||
status,
|
c, status, Message.TYPE_RTP_SESSION, sessionId);
|
||||||
Message.TYPE_RTP_SESSION,
|
|
||||||
sessionId
|
|
||||||
);
|
|
||||||
message.setServerMsgId(serverMsgId);
|
message.setServerMsgId(serverMsgId);
|
||||||
message.setTime(timestamp);
|
message.setTime(timestamp);
|
||||||
message.setBody(new RtpSessionStatus(false, 0).toString());
|
message.setBody(new RtpSessionStatus(false, 0).toString());
|
||||||
|
@ -898,9 +900,14 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
mXmppConnectionService.databaseBackend.createMessage(message);
|
mXmppConnectionService.databaseBackend.createMessage(message);
|
||||||
}
|
}
|
||||||
} else if ("proceed".equals(action)) {
|
} else if ("proceed".equals(action)) {
|
||||||
//status needs to be flipped to find the original propose
|
// status needs to be flipped to find the original propose
|
||||||
final Conversation c = mXmppConnectionService.findOrCreateConversation(account, counterpart.asBareJid(), false, false);
|
final Conversation c =
|
||||||
final int s = packet.fromAccount(account) ? Message.STATUS_RECEIVED : Message.STATUS_SEND;
|
mXmppConnectionService.findOrCreateConversation(
|
||||||
|
account, counterpart.asBareJid(), false, false);
|
||||||
|
final int s =
|
||||||
|
packet.fromAccount(account)
|
||||||
|
? Message.STATUS_RECEIVED
|
||||||
|
: Message.STATUS_SEND;
|
||||||
final Message message = c.findRtpSession(sessionId, s);
|
final Message message = c.findRtpSession(sessionId, s);
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
message.setBody(new RtpSessionStatus(true, 0).toString());
|
message.setBody(new RtpSessionStatus(true, 0).toString());
|
||||||
|
@ -910,11 +917,15 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
message.setTime(timestamp);
|
message.setTime(timestamp);
|
||||||
mXmppConnectionService.updateMessage(message, true);
|
mXmppConnectionService.updateMessage(message, true);
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, "unable to find original rtp session message for received propose");
|
Log.d(
|
||||||
|
Config.LOGTAG,
|
||||||
|
"unable to find original rtp session message for received propose");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ("finish".equals(action)) {
|
} else if ("finish".equals(action)) {
|
||||||
Log.d(Config.LOGTAG,"received JMI 'finish' during MAM catch-up. Can be used to update success/failure and duration");
|
Log.d(
|
||||||
|
Config.LOGTAG,
|
||||||
|
"received JMI 'finish' during MAM catch-up. Can be used to update success/failure and duration");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//MAM reloads (non catchups
|
//MAM reloads (non catchups
|
||||||
|
|
|
@ -2739,7 +2739,7 @@ public class XmppConnection implements Runnable {
|
||||||
Log.d(
|
Log.d(
|
||||||
Config.LOGTAG,
|
Config.LOGTAG,
|
||||||
account.getJid().asBareJid()
|
account.getJid().asBareJid()
|
||||||
+ ": received ping response after sending initial presence");
|
+ ": got ping response after sending initial presence");
|
||||||
XmppConnection.this.offlineMessagesRetrieved = true;
|
XmppConnection.this.offlineMessagesRetrieved = true;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -2747,6 +2747,10 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOfflineMessagesRetrieved() {
|
||||||
|
return this.offlineMessagesRetrieved;
|
||||||
|
}
|
||||||
|
|
||||||
private class MyKeyManager implements X509KeyManager {
|
private class MyKeyManager implements X509KeyManager {
|
||||||
@Override
|
@Override
|
||||||
public String chooseClientAlias(String[] strings, Principal[] principals, Socket socket) {
|
public String chooseClientAlias(String[] strings, Principal[] principals, Socket socket) {
|
||||||
|
|
Loading…
Reference in a new issue