Commit 3296124b authored by Dave Cridland's avatar Dave Cridland

Update message routing to RFC 6120

Various non-conformances in message routing caused some odd behaviour where
combinations of outgoing PEP events failing to be delivered could cause
errors to be delivered to all available clients.

This fixes message routing for three cases:

* Headline messages sent to the bare JID are now broadcast.
* Headline emssages sent to an offline session are discarded.
* Groupchat messages sent to a bare JID are handed to offline processing,
however these should not occur.
* Errors sent to the bare JID are discarded.
parent 12b4559b
...@@ -546,6 +546,16 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable, Clust ...@@ -546,6 +546,16 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable, Clust
// Get the sessions with non-negative priority for message carbons processing. // Get the sessions with non-negative priority for message carbons processing.
List<ClientSession> nonNegativePrioritySessions = getNonNegativeSessions(sessions, 0); List<ClientSession> nonNegativePrioritySessions = getNonNegativeSessions(sessions, 0);
if (packet.getType() == Message.Type.error) {
// Errors should be dropped at this point.
return true; // Not offline.
}
if (packet.getType() == Message.Type.groupchat) {
// Surreal message type; cannot occur.
return false; // Maybe offline has an idea?
}
if (nonNegativePrioritySessions.isEmpty()) { if (nonNegativePrioritySessions.isEmpty()) {
// No session is available so store offline // No session is available so store offline
Log.debug("Unable to route packet. No session is available so store offline. {} ", packet.toXML()); Log.debug("Unable to route packet. No session is available so store offline. {} ", packet.toXML());
...@@ -554,8 +564,11 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable, Clust ...@@ -554,8 +564,11 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable, Clust
// Check for message carbons enabled sessions and send the message to them. // Check for message carbons enabled sessions and send the message to them.
for (ClientSession session : nonNegativePrioritySessions) { for (ClientSession session : nonNegativePrioritySessions) {
if (packet.getType() == Message.Type.headline) {
// Headline messages are broadcast.
session.process(packet);
// Deliver to each session, if is message carbons enabled. // Deliver to each session, if is message carbons enabled.
if (shouldCarbonCopyToResource(session, packet, isPrivate)) { } else if (shouldCarbonCopyToResource(session, packet, isPrivate)) {
session.process(packet); session.process(packet);
// Deliver to each session if property route.really-all-resources is true // Deliver to each session if property route.really-all-resources is true
// (in case client does not support carbons) // (in case client does not support carbons)
...@@ -564,6 +577,10 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable, Clust ...@@ -564,6 +577,10 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable, Clust
} }
} }
if (packet.getType() == Message.Type.headline) {
return true;
}
if (JiveGlobals.getBooleanProperty("route.really-all-resources", false)) if (JiveGlobals.getBooleanProperty("route.really-all-resources", false))
return true; return true;
......
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