diff --git a/src/java/org/jivesoftware/openfire/spi/RoutingTableImpl.java b/src/java/org/jivesoftware/openfire/spi/RoutingTableImpl.java
index 817d079..1f286a1 100644
--- a/src/java/org/jivesoftware/openfire/spi/RoutingTableImpl.java
+++ b/src/java/org/jivesoftware/openfire/spi/RoutingTableImpl.java
@@ -286,7 +286,8 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable, Clust
// The receiving server and SHOULD remove the element before delivering to the recipient.
packet.getElement().remove(privateElement);
- if (jid.getResource() == null) {
+ // Patch: always act as if we got a bare JID
+ if (packet instanceof Message || jid.getResource() == null) {
// Packet sent to a bare JID of a user
if (packet instanceof Message) {
// Find best route of local user
@@ -605,8 +606,8 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable, Clust
}
}
else {
- // Deliver stanza to all connected resources with highest priority
- sessions = getHighestPrioritySessions(sessions);
+ // Patch don't limit sessions to highest priority
+ sessions = getNonZeroPrioritySessions(sessions);
for (ClientSession session : sessions) {
// Make sure, we don't send the packet again, if it has already been sent by message carbons.
if (!shouldSentToResource(session, packet, isPrivate)) {
@@ -618,6 +619,25 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable, Clust
return true;
}
+ // Patch
+ /**
+ * Returns the sessions that had priority greater than zero.
+ *
+ * @param sessions the list of user sessions that filter and get the ones with nonzero priority.
+ * @return the sessions that had the presence priority greater than zero or empty collection
+ * if all were negative.
+ */
+ private List getNonZeroPrioritySessions(List sessions) {
+ // Get sessions that have the highest priority
+ List answer = new ArrayList(sessions.size());
+ for (ClientSession session : sessions) {
+ if (session.getPresence().getPriority() >= 0) {
+ answer.add(session);
+ }
+ }
+ return answer;
+ }
+
private boolean shouldSentToResource(ClientSession session, Message message, boolean isPrivate) {
return !isPrivate && session.isMessageCarbonsEnabled() && message.getType() == Message.Type.chat;
}
@@ -652,6 +672,26 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable, Clust
return answer;
}
+ // Patch
+ /**
+ * Returns the sessions that had priority greater than zero.
+ *
+ * @param sessions the list of user sessions that filter and get the ones with nonzero priority.
+ * @return the sessions that had the presence priority greater than zero or empty collection
+ * if all were negative.
+ */
+ private List getNonZeroPrioritySessions(List sessions) {
+ // Get sessions that have the highest priority
+ List answer = new ArrayList(sessions.size());
+ for (ClientSession session : sessions) {
+ if (session.getPresence().getPriority() >= 0) {
+ answer.add(session);
+ }
+ }
+ return answer;
+ }
+
+
public ClientSession getClientRoute(JID jid) {
// Check if this session is hosted by this cluster node
ClientSession session = (ClientSession) localRoutingTable.getRoute(jid.toString());
diff --git a/src/plugins/kraken/src/java/net/sf/kraken/session/TransportSession.java b/src/plugins/kraken/src/java/net/sf/kraken/session/TransportSession.java
index 0935c92..178032a 100644
--- a/src/plugins/kraken/src/java/net/sf/kraken/session/TransportSession.java
+++ b/src/plugins/kraken/src/java/net/sf/kraken/session/TransportSession.java
@@ -419,6 +419,10 @@ public abstract class TransportSession {
* @return Full JID including resource with highest priority.
*/
public JID getJIDWithHighestPriority() {
+ // PATCH: do not specify resource to send to if route.all-resources is set
+ if( JiveGlobals.getBooleanProperty("route.all-resources", false) ) {
+ return new JID(jid.getNode(),jid.getDomain(),null);
+ }
return new JID(jid.getNode(),jid.getDomain(),highestResource);
}