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 {
// 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 {
// Just store the message offline
messageStrategy.storeOffline((Message) packet);
......
......@@ -86,12 +86,7 @@ public class OfflineMessageStrategy extends BasicModule {
!UserManager.getInstance().isRegisteredUser(recipientJID.getNode())) {
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
PrivacyList list =
PrivacyListManager.getInstance().getDefaultPrivacyList(recipientJID.getNode());
......@@ -103,6 +98,38 @@ public class OfflineMessageStrategy extends BasicModule {
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) {
bounce(message);
}
......@@ -168,8 +195,8 @@ public class OfflineMessageStrategy extends BasicModule {
try {
// Generate a rejection response to the sender
Message errorResponse = message.createCopy();
errorResponse.setError(new PacketError(PacketError.Condition.item_not_found,
PacketError.Type.continue_processing));
// return an error stanza to the sender, which SHOULD be <service-unavailable/>
errorResponse.setError(PacketError.Condition.service_unavailable);
errorResponse.setFrom(message.getTo());
errorResponse.setTo(message.getFrom());
// 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