combine multiple message receipts into single message
This commit is contained in:
parent
2225b0b6d5
commit
d42c82abf2
|
@ -4,6 +4,7 @@ import net.java.otr4j.OtrException;
|
||||||
import net.java.otr4j.session.Session;
|
import net.java.otr4j.session.Session;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
@ -72,9 +73,9 @@ public class MessageGenerator extends AbstractGenerator {
|
||||||
Element html = packet.addChild("html","http://jabber.org/protocol/xhtml-im");
|
Element html = packet.addChild("html","http://jabber.org/protocol/xhtml-im");
|
||||||
Element body = html.addChild("body","http://www.w3.org/1999/xhtml");
|
Element body = html.addChild("body","http://www.w3.org/1999/xhtml");
|
||||||
Element img = body.addChild("img");
|
Element img = body.addChild("img");
|
||||||
img.setAttribute("src",params.url.toString());
|
img.setAttribute("src", params.url.toString());
|
||||||
img.setAttribute("height",params.height);
|
img.setAttribute("height", params.height);
|
||||||
img.setAttribute("width",params.width);
|
img.setAttribute("width", params.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addMessageHints(MessagePacket packet) {
|
public static void addMessageHints(MessagePacket packet) {
|
||||||
|
@ -188,13 +189,14 @@ public class MessageGenerator extends AbstractGenerator {
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessagePacket received(Account account, MessagePacket originalMessage, String namespace, int type) {
|
public MessagePacket received(Account account, MessagePacket originalMessage, ArrayList<String> namespaces, int type) {
|
||||||
MessagePacket receivedPacket = new MessagePacket();
|
MessagePacket receivedPacket = new MessagePacket();
|
||||||
receivedPacket.setType(type);
|
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);
|
for(String namespace : namespaces) {
|
||||||
received.setAttribute("id", originalMessage.getId());
|
receivedPacket.addChild("received", namespace).setAttribute("id", originalMessage.getId());
|
||||||
|
}
|
||||||
return receivedPacket;
|
return receivedPacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import eu.siacs.conversations.crypto.PgpDecryptionService;
|
||||||
import net.java.otr4j.session.Session;
|
import net.java.otr4j.session.Session;
|
||||||
import net.java.otr4j.session.SessionStatus;
|
import net.java.otr4j.session.SessionStatus;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
|
@ -393,17 +394,17 @@ public class MessageParser extends AbstractParser implements
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mXmppConnectionService.confirmMessages() && remoteMsgId != null && !isForwarded && !isTypeGroupChat) {
|
if (mXmppConnectionService.confirmMessages() && remoteMsgId != null && !isForwarded && !isTypeGroupChat) {
|
||||||
|
ArrayList<String> receiptsNamespaces = new ArrayList<>();
|
||||||
if (packet.hasChild("markable", "urn:xmpp:chat-markers:0")) {
|
if (packet.hasChild("markable", "urn:xmpp:chat-markers:0")) {
|
||||||
MessagePacket receipt = mXmppConnectionService.getMessageGenerator().received(account,
|
receiptsNamespaces.add("urn:xmpp:chat-markers:0");
|
||||||
packet,
|
|
||||||
"urn:xmpp:chat-markers:0",
|
|
||||||
MessagePacket.TYPE_CHAT);
|
|
||||||
mXmppConnectionService.sendMessagePacket(account, receipt);
|
|
||||||
}
|
}
|
||||||
if (packet.hasChild("request", "urn:xmpp:receipts")) {
|
if (packet.hasChild("request", "urn:xmpp:receipts")) {
|
||||||
|
receiptsNamespaces.add("urn:xmpp:receipts");
|
||||||
|
}
|
||||||
|
if (receiptsNamespaces.size() > 0) {
|
||||||
MessagePacket receipt = mXmppConnectionService.getMessageGenerator().received(account,
|
MessagePacket receipt = mXmppConnectionService.getMessageGenerator().received(account,
|
||||||
packet,
|
packet,
|
||||||
"urn:xmpp:receipts",
|
receiptsNamespaces,
|
||||||
packet.getType());
|
packet.getType());
|
||||||
mXmppConnectionService.sendMessagePacket(account, receipt);
|
mXmppConnectionService.sendMessagePacket(account, receipt);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue