Commit fa5b0ee0 authored by Guus der Kinderen's avatar Guus der Kinderen

Merge pull request #513 from sco0ter/offlinechatstates

Should not store chat state messages, which contain a thread element.
parents fbe58c8f 410a0628
......@@ -22,6 +22,7 @@ package org.jivesoftware.openfire;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.Namespace;
import org.dom4j.QName;
import org.dom4j.io.SAXReader;
import org.jivesoftware.database.DbConnectionManager;
......@@ -492,7 +493,9 @@ public class OfflineMessageStore extends BasicModule implements UserEventListene
if (item instanceof Element) {
Element el = (Element) item;
if (Namespace.NO_NAMESPACE.equals(el.getNamespace())) {
continue;
}
if (!el.getNamespaceURI().equals("http://jabber.org/protocol/chatstates")
&& !(el.getQName().equals(QName.get("rtt", "urn:xmpp:rtt:0")))
) {
......@@ -501,7 +504,7 @@ public class OfflineMessageStore extends BasicModule implements UserEventListene
}
}
return false;
return message.getBody() != null && !message.getBody().isEmpty();
case groupchat:
case headline:
......
......@@ -75,6 +75,16 @@ public class OfflineMessageStoreTest {
assertFalse(OfflineMessageStore.shouldStoreMessage(message));
}
@Test
public void shouldNotStoreEmptyChatMessagesWithOnlyChatStatesAndThread() {
Message message = new Message();
message.setType(Message.Type.chat);
message.setThread("1234");
PacketExtension chatState = new PacketExtension("composing", "http://jabber.org/protocol/chatstates");
message.addExtension(chatState);
assertFalse(OfflineMessageStore.shouldStoreMessage(message));
}
@Test
public void shouldStoreEmptyChatMessagesWithOtherExtensions() {
Message message = new Message();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment