Commit 237cf9c4 authored by Christian Schudt's avatar Christian Schudt

OF-810 RFC 6121 Routing Compliance Fix

parent a811a1f8
...@@ -250,7 +250,10 @@ public class MessageRouter extends BasicModule { ...@@ -250,7 +250,10 @@ public class MessageRouter extends BasicModule {
// If message was sent to an unavailable full JID of a user then retry using the bare JID // 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 && if (serverName.equals(recipient.getDomain()) && recipient.getResource() != null &&
userManager.isRegisteredUser(recipient.getNode())) { userManager.isRegisteredUser(recipient.getNode())) {
Message msg = (Message)packet;
if (msg.getType().equals(Message.Type.chat)) {
routingTable.routePacket(recipient.asBareJID(), packet, false); routingTable.routePacket(recipient.asBareJID(), packet, false);
}
} else { } else {
// Just store the message offline // Just store the message offline
messageStrategy.storeOffline((Message) packet); messageStrategy.storeOffline((Message) packet);
......
...@@ -86,12 +86,7 @@ public class OfflineMessageStrategy extends BasicModule { ...@@ -86,12 +86,7 @@ public class OfflineMessageStrategy extends BasicModule {
!UserManager.getInstance().isRegisteredUser(recipientJID.getNode())) { !UserManager.getInstance().isRegisteredUser(recipientJID.getNode())) {
return; return;
} }
// Do not store messages of type groupchat, error or headline as specified in JEP-160
if (Message.Type.groupchat == message.getType() ||
Message.Type.error == message.getType() ||
Message.Type.headline == message.getType()) {
return;
}
// Do not store messages if communication is blocked // Do not store messages if communication is blocked
PrivacyList list = PrivacyList list =
PrivacyListManager.getInstance().getDefaultPrivacyList(recipientJID.getNode()); PrivacyListManager.getInstance().getDefaultPrivacyList(recipientJID.getNode());
...@@ -103,6 +98,38 @@ public class OfflineMessageStrategy extends BasicModule { ...@@ -103,6 +98,38 @@ public class OfflineMessageStrategy extends BasicModule {
return; return;
} }
// 8.5.2. localpart@domainpart
// 8.5.2.2. No Available or Connected Resources
if (recipientJID.getResource() == null) {
if (message.getType() == Message.Type.headline || message.getType() == Message.Type.error) {
// For a message stanza of type "headline" or "error", the server MUST silently ignore the message.
return;
}
// // For a message stanza of type "groupchat", the server MUST return an error to the sender, which SHOULD be <service-unavailable/>.
else if (message.getType() == Message.Type.groupchat) {
bounce(message);
return;
}
} else {
// 8.5.3. localpart@domainpart/resourcepart
// 8.5.3.2.1. Message
// For a message stanza of type "normal", "groupchat", or "headline", the server MUST either (a) silently ignore the stanza
// or (b) return an error stanza to the sender, which SHOULD be <service-unavailable/>.
if (message.getType() == Message.Type.normal || message.getType() == Message.Type.groupchat || message.getType() == Message.Type.headline) {
if (type == Type.bounce) {
bounce(message);
} else {
return;
}
}
// For a message stanza of type "error", the server MUST silently ignore the stanza.
else if (message.getType() == Message.Type.error) {
// For a message stanza of type "error", the server MUST silently ignore the stanza.
return;
}
}
if (type == Type.bounce) { if (type == Type.bounce) {
bounce(message); bounce(message);
} }
...@@ -168,8 +195,8 @@ public class OfflineMessageStrategy extends BasicModule { ...@@ -168,8 +195,8 @@ public class OfflineMessageStrategy extends BasicModule {
try { try {
// Generate a rejection response to the sender // Generate a rejection response to the sender
Message errorResponse = message.createCopy(); Message errorResponse = message.createCopy();
errorResponse.setError(new PacketError(PacketError.Condition.item_not_found, // return an error stanza to the sender, which SHOULD be <service-unavailable/>
PacketError.Type.continue_processing)); errorResponse.setError(PacketError.Condition.service_unavailable);
errorResponse.setFrom(message.getTo()); errorResponse.setFrom(message.getTo());
errorResponse.setTo(message.getFrom()); errorResponse.setTo(message.getFrom());
// Send the response // Send the response
......
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