# add delivery receipts for private muc msgs
# enable update last-seen for muc-msgs
This commit is contained in:
parent
1a5321e41f
commit
1c600fefcf
|
@ -35,6 +35,9 @@ public class MessageGenerator extends AbstractGenerator {
|
||||||
} else if (message.getType() == Message.TYPE_PRIVATE) {
|
} else if (message.getType() == Message.TYPE_PRIVATE) {
|
||||||
packet.setTo(message.getCounterpart());
|
packet.setTo(message.getCounterpart());
|
||||||
packet.setType(MessagePacket.TYPE_CHAT);
|
packet.setType(MessagePacket.TYPE_CHAT);
|
||||||
|
if (this.mXmppConnectionService.indicateReceived()) {
|
||||||
|
packet.addChild("request", "urn:xmpp:receipts");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
packet.setTo(message.getCounterpart().toBareJid());
|
packet.setTo(message.getCounterpart().toBareJid());
|
||||||
packet.setType(MessagePacket.TYPE_GROUPCHAT);
|
packet.setType(MessagePacket.TYPE_GROUPCHAT);
|
||||||
|
|
|
@ -49,6 +49,11 @@ public abstract class AbstractParser {
|
||||||
protected void updateLastseen(final Element packet, final Account account,
|
protected void updateLastseen(final Element packet, final Account account,
|
||||||
final boolean presenceOverwrite) {
|
final boolean presenceOverwrite) {
|
||||||
final Jid from = packet.getAttributeAsJid("from");
|
final Jid from = packet.getAttributeAsJid("from");
|
||||||
|
updateLastseen(packet, account, from, presenceOverwrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateLastseen(final Element packet, final Account account, final Jid from,
|
||||||
|
final boolean presenceOverwrite) {
|
||||||
final String presence = from == null || from.isBareJid() ? "" : from.getResourcepart();
|
final String presence = from == null || from.isBareJid() ? "" : from.getResourcepart();
|
||||||
final Contact contact = account.getRoster().getContact(from);
|
final Contact contact = account.getRoster().getContact(from);
|
||||||
final long timestamp = getTimestamp(packet);
|
final long timestamp = getTimestamp(packet);
|
||||||
|
|
|
@ -49,7 +49,6 @@ public class MessageParser extends AbstractParser implements
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, jid.toBareJid(), false);
|
Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, jid.toBareJid(), false);
|
||||||
updateLastseen(packet, account, true);
|
|
||||||
String pgpBody = getPgpBody(packet);
|
String pgpBody = getPgpBody(packet);
|
||||||
Message finishedMessage;
|
Message finishedMessage;
|
||||||
if (pgpBody != null) {
|
if (pgpBody != null) {
|
||||||
|
@ -64,13 +63,18 @@ public class MessageParser extends AbstractParser implements
|
||||||
finishedMessage.markable = isMarkable(packet);
|
finishedMessage.markable = isMarkable(packet);
|
||||||
if (conversation.getMode() == Conversation.MODE_MULTI
|
if (conversation.getMode() == Conversation.MODE_MULTI
|
||||||
&& !jid.isBareJid()) {
|
&& !jid.isBareJid()) {
|
||||||
|
final Jid trueCounterpart = conversation.getMucOptions()
|
||||||
|
.getTrueCounterpart(jid.getResourcepart());
|
||||||
|
if (trueCounterpart != null) {
|
||||||
|
updateLastseen(packet, account, trueCounterpart, true);
|
||||||
|
}
|
||||||
finishedMessage.setType(Message.TYPE_PRIVATE);
|
finishedMessage.setType(Message.TYPE_PRIVATE);
|
||||||
finishedMessage.setTrueCounterpart(conversation.getMucOptions()
|
finishedMessage.setTrueCounterpart(trueCounterpart);
|
||||||
.getTrueCounterpart(jid.getResourcepart()));
|
|
||||||
if (conversation.hasDuplicateMessage(finishedMessage)) {
|
if (conversation.hasDuplicateMessage(finishedMessage)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
updateLastseen(packet, account, true);
|
||||||
}
|
}
|
||||||
finishedMessage.setCounterpart(jid);
|
finishedMessage.setCounterpart(jid);
|
||||||
finishedMessage.setTime(getTimestamp(packet));
|
finishedMessage.setTime(getTimestamp(packet));
|
||||||
|
@ -163,6 +167,10 @@ public class MessageParser extends AbstractParser implements
|
||||||
}
|
}
|
||||||
Conversation conversation = mXmppConnectionService
|
Conversation conversation = mXmppConnectionService
|
||||||
.findOrCreateConversation(account, from.toBareJid(), true);
|
.findOrCreateConversation(account, from.toBareJid(), true);
|
||||||
|
final Jid trueCounterpart = conversation.getMucOptions().getTrueCounterpart(from.getResourcepart());
|
||||||
|
if (trueCounterpart != null) {
|
||||||
|
updateLastseen(packet, account, trueCounterpart.toBareJid(), true);
|
||||||
|
}
|
||||||
if (packet.hasChild("subject")) {
|
if (packet.hasChild("subject")) {
|
||||||
conversation.setHasMessagesLeftOnServer(true);
|
conversation.setHasMessagesLeftOnServer(true);
|
||||||
conversation.getMucOptions().setSubject(packet.findChild("subject").getContent());
|
conversation.getMucOptions().setSubject(packet.findChild("subject").getContent());
|
||||||
|
|
|
@ -2041,7 +2041,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for (Conversation conversation : getConversations()) {
|
for (Conversation conversation : getConversations()) {
|
||||||
if (conversation.getJid().equals(recipient) && conversation.getAccount() == account) {
|
if (conversation.getJid().toBareJid().equals(recipient) && conversation.getAccount() == account) {
|
||||||
final Message message = conversation.findSentMessageWithUuid(uuid);
|
final Message message = conversation.findSentMessageWithUuid(uuid);
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
markMessage(message, status);
|
markMessage(message, status);
|
||||||
|
|
Loading…
Reference in a new issue