On Thu, Aug 26, 2010 at 10:38 PM, Niklas Gustavsson
<[email protected]> wrote:
> I ran into a problem while integration testing MUC. Turns out that IQ
> stanzas does not get correctly routed to components in the case where
> the stanza is targeted at a JID containing a node. This is common in
> MUC, where clients will send IQ admin stanzas to rooms (e.g.
> [email protected]). I'm not familiar with the background to the
> current relaying logic. The code is found in:
> org.apache.vysper.xmpp.modules.core.base.handler.RelayingIQHandler.executeIQLogic()
Here's a patch that solves my problem, might cause other...
Index:
src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/RelayingIQHandler.java
===================================================================
---
src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/RelayingIQHandler.java
(revision
958281)
+++
src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/RelayingIQHandler.java
(working
copy)
@@ -61,7 +61,7 @@
if (outboundStanza) {
try {
- boolean toComponent = !to.isNodeSet() && !to.isResourceSet();
+ boolean toComponent = isComponent(to,
serverRuntimeContext.getServerEnitity());
Entity from = stanza.getFrom();
if (from == null || !from.isResourceSet()) {
@@ -94,7 +94,7 @@
// write inbound stanza to the user
Entity from = stanza.getFrom();
- boolean fromComponent = (from != null) &&
(!from.isNodeSet()) && (!from.isResourceSet());
+ boolean fromComponent = (from != null) &&
isComponent(from, serverRuntimeContext.getServerEnitity());;
// determine if 'from' is a component or a matching subscription...
boolean isToContact = false;
@@ -116,4 +116,8 @@
return null;
}
+
+ private boolean isComponent(Entity toVerify, Entity server) {
+ return toVerify.getDomain().endsWith("." + server.getDomain());
+ }
}
/niklas