extract stanza-id from muc reflections
This commit is contained in:
parent
4a7dbaab1e
commit
5a00b11594
|
@ -212,6 +212,20 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String extractStanzaid(Element packet, boolean isTypeGroupChat, Conversation conversation) {
|
||||||
|
final Jid by;
|
||||||
|
final boolean safeToExtract;
|
||||||
|
if (isTypeGroupChat) {
|
||||||
|
by = conversation.getJid().toBareJid();
|
||||||
|
safeToExtract = conversation.getMucOptions().hasFeature(Namespace.STANZA_IDS);
|
||||||
|
} else {
|
||||||
|
Account account = conversation.getAccount();
|
||||||
|
by = account.getJid().toBareJid();
|
||||||
|
safeToExtract = account.getXmppConnection().getFeatures().stanzaIds();
|
||||||
|
}
|
||||||
|
return safeToExtract ? extractStanzaId(packet, by) : null;
|
||||||
|
}
|
||||||
|
|
||||||
private static String extractStanzaId(Element packet, Jid by) {
|
private static String extractStanzaId(Element packet, Jid by) {
|
||||||
for(Element child : packet.getChildren()) {
|
for(Element child : packet.getChildren()) {
|
||||||
if (child.getName().equals("stanza-id")
|
if (child.getName().equals("stanza-id")
|
||||||
|
@ -385,11 +399,16 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
if ((body != null || pgpEncrypted != null || axolotlEncrypted != null) && !isMucStatusMessage) {
|
if ((body != null || pgpEncrypted != null || axolotlEncrypted != null) && !isMucStatusMessage) {
|
||||||
Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.toBareJid(), isTypeGroupChat, false, query);
|
Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.toBareJid(), isTypeGroupChat, false, query);
|
||||||
final boolean conversationMultiMode = conversation.getMode() == Conversation.MODE_MULTI;
|
final boolean conversationMultiMode = conversation.getMode() == Conversation.MODE_MULTI;
|
||||||
|
|
||||||
|
if (serverMsgId == null) {
|
||||||
|
extractStanzaid(packet, isTypeGroupChat, conversation);
|
||||||
|
}
|
||||||
|
|
||||||
if (isTypeGroupChat) {
|
if (isTypeGroupChat) {
|
||||||
if (counterpart.getResourcepart().equals(conversation.getMucOptions().getActualNick())) {
|
if (counterpart.getResourcepart().equals(conversation.getMucOptions().getActualNick())) {
|
||||||
status = Message.STATUS_SEND_RECEIVED;
|
status = Message.STATUS_SEND_RECEIVED;
|
||||||
isCarbon = true; //not really carbon but received from another resource
|
isCarbon = true; //not really carbon but received from another resource
|
||||||
if (mXmppConnectionService.markMessage(conversation, remoteMsgId, status)) {
|
if (mXmppConnectionService.markMessage(conversation, remoteMsgId, status, serverMsgId)) {
|
||||||
return;
|
return;
|
||||||
} else if (remoteMsgId == null || Config.IGNORE_ID_REWRITE_IN_MUC) {
|
} else if (remoteMsgId == null || Config.IGNORE_ID_REWRITE_IN_MUC) {
|
||||||
Message message = conversation.findSentMessageWithBody(packet.getBody());
|
Message message = conversation.findSentMessageWithBody(packet.getBody());
|
||||||
|
@ -438,21 +457,6 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
message = new Message(conversation, body, Message.ENCRYPTION_NONE, status);
|
message = new Message(conversation, body, Message.ENCRYPTION_NONE, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serverMsgId == null) {
|
|
||||||
final Jid by;
|
|
||||||
final boolean safeToExtract;
|
|
||||||
if (isTypeGroupChat) {
|
|
||||||
by = conversation.getJid().toBareJid();
|
|
||||||
safeToExtract = conversation.getMucOptions().hasFeature(Namespace.STANZA_IDS);
|
|
||||||
} else {
|
|
||||||
by = account.getJid().toBareJid();
|
|
||||||
safeToExtract = account.getXmppConnection().getFeatures().stanzaIds();
|
|
||||||
}
|
|
||||||
if (safeToExtract) {
|
|
||||||
serverMsgId = extractStanzaId(packet, by);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
message.setCounterpart(counterpart);
|
message.setCounterpart(counterpart);
|
||||||
message.setRemoteMsgId(remoteMsgId);
|
message.setRemoteMsgId(remoteMsgId);
|
||||||
message.setServerMsgId(serverMsgId);
|
message.setServerMsgId(serverMsgId);
|
||||||
|
|
|
@ -3180,12 +3180,15 @@ public class XmppConnectionService extends Service {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean markMessage(Conversation conversation, String uuid, int status) {
|
public boolean markMessage(Conversation conversation, String uuid, int status, String serverMessageId) {
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Message message = conversation.findSentMessageWithUuid(uuid);
|
Message message = conversation.findSentMessageWithUuid(uuid);
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
|
if (message.getServerMsgId() == null) {
|
||||||
|
message.setServerMsgId(serverMessageId);
|
||||||
|
}
|
||||||
markMessage(message, status);
|
markMessage(message, status);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue