aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-12-01 12:22:47 +0100
committerChristian S <christian@pix-art.de>2015-12-04 09:12:00 +0100
commitbff0463c3b1ed54a1ae05ac81090a811abe92088 (patch)
treec1c0f75c8ff9422b9bae32cb6ab8e2a06c1ded2b /src/main/java
parentd3ce68ea30c97acaa5f4fb4961ad5fba586f6362 (diff)
combine multiple message receipts into single message
Diffstat (limited to '')
-rw-r--r--src/main/java/eu/siacs/conversations/generator/MessageGenerator.java14
-rw-r--r--src/main/java/eu/siacs/conversations/parser/MessageParser.java13
2 files changed, 15 insertions, 12 deletions
diff --git a/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java b/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java
index 573049c79..9c847d0e0 100644
--- a/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java
+++ b/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java
@@ -4,6 +4,7 @@ import net.java.otr4j.OtrException;
import net.java.otr4j.session.Session;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
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 body = html.addChild("body","http://www.w3.org/1999/xhtml");
Element img = body.addChild("img");
- img.setAttribute("src",params.url.toString());
- img.setAttribute("height",params.height);
- img.setAttribute("width",params.width);
+ img.setAttribute("src", params.url.toString());
+ img.setAttribute("height", params.height);
+ img.setAttribute("width", params.width);
}
public static void addMessageHints(MessagePacket packet) {
@@ -188,13 +189,14 @@ public class MessageGenerator extends AbstractGenerator {
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();
receivedPacket.setType(type);
receivedPacket.setTo(originalMessage.getFrom());
receivedPacket.setFrom(account.getJid());
- Element received = receivedPacket.addChild("received", namespace);
- received.setAttribute("id", originalMessage.getId());
+ for(String namespace : namespaces) {
+ receivedPacket.addChild("received", namespace).setAttribute("id", originalMessage.getId());
+ }
return receivedPacket;
}
diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
index 58ca51350..b4c648fe9 100644
--- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
@@ -7,6 +7,7 @@ import eu.siacs.conversations.crypto.PgpDecryptionService;
import net.java.otr4j.session.Session;
import net.java.otr4j.session.SessionStatus;
+import java.util.ArrayList;
import java.util.Set;
import eu.siacs.conversations.Config;
@@ -393,17 +394,17 @@ public class MessageParser extends AbstractParser implements
}
if (mXmppConnectionService.confirmMessages() && remoteMsgId != null && !isForwarded && !isTypeGroupChat) {
+ ArrayList<String> receiptsNamespaces = new ArrayList<>();
if (packet.hasChild("markable", "urn:xmpp:chat-markers:0")) {
- MessagePacket receipt = mXmppConnectionService.getMessageGenerator().received(account,
- packet,
- "urn:xmpp:chat-markers:0",
- MessagePacket.TYPE_CHAT);
- mXmppConnectionService.sendMessagePacket(account, receipt);
+ receiptsNamespaces.add("urn:xmpp:chat-markers:0");
}
if (packet.hasChild("request", "urn:xmpp:receipts")) {
+ receiptsNamespaces.add("urn:xmpp:receipts");
+ }
+ if (receiptsNamespaces.size() > 0) {
MessagePacket receipt = mXmppConnectionService.getMessageGenerator().received(account,
packet,
- "urn:xmpp:receipts",
+ receiptsNamespaces,
packet.getType());
mXmppConnectionService.sendMessagePacket(account, receipt);
}