Skip to content

Commit

Permalink
RFC 6121 compliant message routing
Browse files Browse the repository at this point in the history
Where a message fails to be routed to a full jid, we should only route to the
bare jid if the type is "chat"; otherwise we should bounce if it's not an
error.
  • Loading branch information
Dave Cridland committed May 21, 2014
1 parent 62a18f9 commit 95ae05d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/java/org/jivesoftware/openfire/MessageRouter.java
Expand Up @@ -250,7 +250,18 @@ public void routingFailed(JID recipient, Packet packet) {
// If message was sent to an unavailable full JID of a user then retry using the bare JID
if (serverName.equals(recipient.getDomain()) && recipient.getResource() != null &&
userManager.isRegisteredUser(recipient.getNode())) {
routingTable.routePacket(recipient.asBareJID(), packet, false);
Message msg = (Message)packet;
if (msg.getType().equals(Message.Type.chat)) {
routingTable.routePacket(recipient.asBareJID(), packet, false);
} else if (!msg.getType().equals(Message.Type.error)) {
// Bounce message, ideally - doing nothing is also OK.
Message bounce = msg.createCopy();
bounce.setTo(msg.getFrom());
bounce.setFrom(msg.getTo());
bounce.setType(Message.Type.error);
bounce.setError(PacketError.Condition.service_unavailable);
routingTable.routePacket(msg.getFrom(), bounce, true);
}
} else {
// Just store the message offline
messageStrategy.storeOffline((Message) packet);
Expand Down

0 comments on commit 95ae05d

Please sign in to comment.