Commit 7f084676 authored by Dave Cridland's avatar Dave Cridland Committed by GitHub

Merge pull request #634 from guusdk/OF-1174_muc_iq_response

OF-1174: MUC should always respond to IQ requests.
parents e8cc92f4 0aab9098
......@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.dom4j.Element;
import org.dom4j.QName;
import org.jivesoftware.openfire.PacketException;
import org.jivesoftware.openfire.PacketRouter;
import org.jivesoftware.openfire.auth.UnauthorizedException;
......@@ -223,10 +224,8 @@ public class LocalMUCUser implements MUCUser {
JID recipient = packet.getTo();
String group = recipient.getNode();
if (group == null) {
// Ignore packets to the groupchat server
// In the future, we'll need to support TYPE_IQ queries to the server for MUC
Log.info(LocaleUtils.getLocalizedString("muc.error.not-supported") + " "
+ packet.toString());
// Packets to the groupchat server. This should not occur (should be handled by MultiUserChatServiceImpl instead)
Log.warn( LocaleUtils.getLocalizedString( "muc.error.not-supported" ) + " " + packet.toString() );
}
else {
MUCRole role = roles.get(group);
......@@ -371,13 +370,18 @@ public class LocalMUCUser implements MUCUser {
lastPacketTime = System.currentTimeMillis();
JID recipient = packet.getTo();
String group = recipient.getNode();
if (group == null) {
// Ignore packets to the groupchat server
// In the future, we'll need to support TYPE_IQ queries to the server for MUC
Log.info(LocaleUtils.getLocalizedString("muc.error.not-supported") + " "
+ packet.toString());
if (group == null)
{
// Packets to the groupchat server. This should not occur (should be handled by MultiUserChatServiceImpl instead)
if ( packet.isRequest() )
{
sendErrorPacket( packet, PacketError.Condition.feature_not_implemented );
}
Log.warn( LocaleUtils.getLocalizedString( "muc.error.not-supported" ) + " " + packet.toString() );
}
else {
else
{
// Packets to a specific node/group/room
MUCRole role = roles.get(group);
if (role == null) {
// If a non-occupant sends a disco to an address of the form <room@service/nick>,
......@@ -599,6 +603,9 @@ public class LocalMUCUser implements MUCUser {
}
}
}
} else {
// Packets to the groupchat server. This should not occur (should be handled by MultiUserChatServiceImpl instead)
Log.warn( LocaleUtils.getLocalizedString( "muc.error.not-supported" ) + " " + packet.toString() );
}
}
......
......@@ -80,11 +80,7 @@ import org.xmpp.component.ComponentManager;
import org.xmpp.forms.DataForm;
import org.xmpp.forms.DataForm.Type;
import org.xmpp.forms.FormField;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
import org.xmpp.packet.Presence;
import org.xmpp.packet.*;
import org.xmpp.resultsetmanagement.ResultSet;
/**
......@@ -335,10 +331,26 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService
return;
}
}
// The packet is a normal packet that should possibly be sent to the room
JID recipient = packet.getTo();
String roomName = recipient != null ? recipient.getNode() : null;
getChatUser(packet.getFrom(), roomName).process(packet);
if ( packet.getTo().getNode() == null )
{
// This was addressed at the service itself, which by now should have been handled.
if ( packet instanceof IQ && ((IQ) packet).isRequest() )
{
final IQ reply = IQ.createResultIQ( (IQ) packet );
reply.setChildElement( ((IQ) packet).getChildElement().createCopy() );
reply.setError( PacketError.Condition.feature_not_implemented );
router.route( reply );
}
Log.debug( "Ignoring stanza addressed at conference service: {}", packet.toXML() );
}
else
{
// The packet is a normal packet that should possibly be sent to the room
JID recipient = packet.getTo();
String roomName = recipient != null ? recipient.getNode() : null;
getChatUser( packet.getFrom(), roomName ).process( packet );
}
}
catch (Exception e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
......@@ -386,6 +398,9 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService
IQ reply = XMPPServer.getInstance().getIQDiscoItemsHandler().handleIQ(iq);
router.route(reply);
}
else if ("urn:xmpp:ping".equals(namespace)) {
router.route( IQ.createResultIQ(iq) );
}
else {
return false;
}
......
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