use type=chat more often to go along with new, simple carbon and mam rules

* change chat states to type=chat and chat markers to type=chat
* use same type as requesting stanza for delivery receipts (which should make them type=chat most of the time)
This commit is contained in:
Daniel Gultsch 2015-07-22 14:15:00 +02:00
parent a1e63944a2
commit 63206e6d4a
2 changed files with 15 additions and 12 deletions

View File

@ -115,6 +115,7 @@ public class MessageGenerator extends AbstractGenerator {
public MessagePacket generateChatState(Conversation conversation) { public MessagePacket generateChatState(Conversation conversation) {
final Account account = conversation.getAccount(); final Account account = conversation.getAccount();
MessagePacket packet = new MessagePacket(); MessagePacket packet = new MessagePacket();
packet.setType(MessagePacket.TYPE_CHAT);
packet.setTo(conversation.getJid().toBareJid()); packet.setTo(conversation.getJid().toBareJid());
packet.setFrom(account.getJid()); packet.setFrom(account.getJid());
packet.addChild(ChatState.toElement(conversation.getOutgoingChatState())); packet.addChild(ChatState.toElement(conversation.getOutgoingChatState()));
@ -123,7 +124,7 @@ public class MessageGenerator extends AbstractGenerator {
public MessagePacket confirm(final Account account, final Jid to, final String id) { public MessagePacket confirm(final Account account, final Jid to, final String id) {
MessagePacket packet = new MessagePacket(); MessagePacket packet = new MessagePacket();
packet.setType(MessagePacket.TYPE_NORMAL); packet.setType(MessagePacket.TYPE_CHAT);
packet.setTo(to); packet.setTo(to);
packet.setFrom(account.getJid()); packet.setFrom(account.getJid());
Element received = packet.addChild("displayed","urn:xmpp:chat-markers:0"); Element received = packet.addChild("displayed","urn:xmpp:chat-markers:0");
@ -131,8 +132,7 @@ public class MessageGenerator extends AbstractGenerator {
return packet; return packet;
} }
public MessagePacket conferenceSubject(Conversation conversation, public MessagePacket conferenceSubject(Conversation conversation,String subject) {
String subject) {
MessagePacket packet = new MessagePacket(); MessagePacket packet = new MessagePacket();
packet.setType(MessagePacket.TYPE_GROUPCHAT); packet.setType(MessagePacket.TYPE_GROUPCHAT);
packet.setTo(conversation.getJid().toBareJid()); packet.setTo(conversation.getJid().toBareJid());
@ -166,10 +166,9 @@ public class MessageGenerator extends AbstractGenerator {
return packet; return packet;
} }
public MessagePacket received(Account account, public MessagePacket received(Account account, MessagePacket originalMessage, String namespace, int type) {
MessagePacket originalMessage, String namespace) {
MessagePacket receivedPacket = new MessagePacket(); MessagePacket receivedPacket = new MessagePacket();
receivedPacket.setType(MessagePacket.TYPE_NORMAL); receivedPacket.setType(type);
receivedPacket.setTo(originalMessage.getFrom()); receivedPacket.setTo(originalMessage.getFrom());
receivedPacket.setFrom(account.getJid()); receivedPacket.setFrom(account.getJid());
Element received = receivedPacket.addChild("received", namespace); Element received = receivedPacket.addChild("received", namespace);

View File

@ -369,15 +369,19 @@ public class MessageParser extends AbstractParser implements
mXmppConnectionService.updateConversationUi(); mXmppConnectionService.updateConversationUi();
} }
if (mXmppConnectionService.confirmMessages() && remoteMsgId != null && !isForwarded) { if (mXmppConnectionService.confirmMessages() && remoteMsgId != null && !isForwarded && !isTypeGroupChat) {
if (packet.hasChild("markable", "urn:xmpp:chat-markers:0")) { if (packet.hasChild("markable", "urn:xmpp:chat-markers:0")) {
MessagePacket receipt = mXmppConnectionService MessagePacket receipt = mXmppConnectionService.getMessageGenerator().received(account,
.getMessageGenerator().received(account, packet, "urn:xmpp:chat-markers:0"); packet,
"urn:xmpp:chat-markers:0",
MessagePacket.TYPE_CHAT);
mXmppConnectionService.sendMessagePacket(account, receipt); mXmppConnectionService.sendMessagePacket(account, receipt);
} }
if (packet.hasChild("request", "urn:xmpp:receipts")) { if (packet.hasChild("request", "urn:xmpp:receipts")) {
MessagePacket receipt = mXmppConnectionService MessagePacket receipt = mXmppConnectionService.getMessageGenerator().received(account,
.getMessageGenerator().received(account, packet, "urn:xmpp:receipts"); packet,
"urn:xmpp:receipts",
packet.getType());
mXmppConnectionService.sendMessagePacket(account, receipt); mXmppConnectionService.sendMessagePacket(account, receipt);
} }
} }