Commit 275676ec authored by Armando Jagucki's avatar Armando Jagucki Committed by ajagucki

PEP: Better handling of Contact Notification Filtering client disco#info results.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/branches@8859 b35dd754-fafc-0310-a699-88a17e54d16e
parent d96d3767
...@@ -455,21 +455,14 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, ...@@ -455,21 +455,14 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
return; return;
} }
else { else {
if (query.attributeValue("node") == null) {
return;
}
String queryNamespace = query.getNamespaceURI(); String queryNamespace = query.getNamespaceURI();
if (queryNamespace == null || !queryNamespace.equals("http://jabber.org/protocol/disco#info")) { if (queryNamespace == null || !queryNamespace.equals("http://jabber.org/protocol/disco#info")) {
return; return;
} }
} }
/*Element identity = query.element("identity");
if (identity == null) {
return;
}
else {
String identityCategory = identity.attributeValue("category");
if (identityCategory == null || !identityCategory.equals("client")) {
return;
}
}*/
if (Log.isDebugEnabled()) { if (Log.isDebugEnabled()) {
Log.debug("PEP: Intercepted a caps result packet: " + packet.toString()); Log.debug("PEP: Intercepted a caps result packet: " + packet.toString());
...@@ -488,8 +481,10 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, ...@@ -488,8 +481,10 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
// the node ID to the set of filtered nodes that jidFrom is interested in being // the node ID to the set of filtered nodes that jidFrom is interested in being
// notified about. // notified about.
// //
// If a node ID does not end in "+notify", remove it from the set of filtered nodes // If none of the feature variables contain the node ID ending in "+notify",
// that jidFrom is interested in being notified about. // remove it from the set of filtered nodes that jidFrom is interested in being
// notified about.
HashSet<String> supportedNodesSet = new HashSet<String>();
while (featuresIterator.hasNext()) { while (featuresIterator.hasNext()) {
Element featureElement = (Element) featuresIterator.next(); Element featureElement = (Element) featuresIterator.next();
...@@ -497,26 +492,30 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, ...@@ -497,26 +492,30 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
if (featureVar == null) { if (featureVar == null) {
continue; continue;
} }
supportedNodesSet.add(featureVar);
}
if (featureVar.endsWith("+notify")) { for (String nodeID : supportedNodesSet) {
String nodeID = featureVar.replace("+notify", ""); if (nodeID.endsWith("+notify")) {
HashSet<String> filteredNodeSet = filteredNodesMap.get(jidFrom); // Add the nodeID to the sender's filteredNodesSet.
HashSet<String> filteredNodesSet = filteredNodesMap.get(jidFrom);
if (filteredNodeSet == null) { if (filteredNodesSet == null) {
filteredNodeSet = new HashSet<String>(); filteredNodesSet = new HashSet<String>();
filteredNodeSet.add(nodeID); filteredNodesSet.add(nodeID);
filteredNodesMap.put(jidFrom, filteredNodeSet); filteredNodesMap.put(jidFrom, filteredNodesSet);
if (Log.isDebugEnabled()) { if (Log.isDebugEnabled()) {
Log.debug("PEP: Created filteredNodeSet for " + jidFrom); Log.debug("PEP: Created filteredNodesSet for " + jidFrom);
Log.debug("PEP: Added " + nodeID + " to " + jidFrom + "'s set of filtered nodes."); Log.debug("PEP: Added " + nodeID + " to " + jidFrom + "'s set of filtered nodes.");
} }
} }
else { else {
if (filteredNodeSet.add(nodeID)) { if (filteredNodesSet.add(nodeID)) {
if (Log.isDebugEnabled()) { if (Log.isDebugEnabled()) {
Log.debug("PEP: Added " + nodeID + " to " + jidFrom + "'s set of filtered nodes: "); Log.debug("PEP: Added " + nodeID + " to " + jidFrom + "'s set of filtered nodes: ");
Iterator tempIter = filteredNodeSet.iterator(); Iterator tempIter = filteredNodesSet.iterator();
while (tempIter.hasNext()) { while (tempIter.hasNext()) {
Log.debug("PEP: " + tempIter.next()); Log.debug("PEP: " + tempIter.next());
} }
...@@ -526,11 +525,19 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, ...@@ -526,11 +525,19 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
} }
else { else {
HashSet<String> filteredNodeSet = filteredNodesMap.get(jidFrom); // Remove the nodeID from the sender's filteredNodesSet if nodeIDPlusNotify
if (filteredNodeSet != null && filteredNodeSet.remove(featureVar)) { // is not in supportedNodesSet.
HashSet<String> filteredNodesSet = filteredNodesMap.get(jidFrom);
if (filteredNodesSet == null) {
return;
}
String nodeIDPlusNotify = nodeID + "+notify";
if (!supportedNodesSet.contains(nodeIDPlusNotify) && filteredNodesSet.remove(nodeIDPlusNotify)) {
if (Log.isDebugEnabled()) { if (Log.isDebugEnabled()) {
Log.debug("PEP: Removed " + featureVar + " from " + jidFrom + "'s set of filtered nodes: "); Log.debug("PEP: Removed " + nodeIDPlusNotify + " from " + jidFrom + "'s set of filtered nodes: ");
Iterator tempIter = filteredNodeSet.iterator(); Iterator tempIter = filteredNodesSet.iterator();
while (tempIter.hasNext()) { while (tempIter.hasNext()) {
Log.debug("PEP: " + tempIter.next()); Log.debug("PEP: " + tempIter.next());
} }
......
...@@ -349,7 +349,7 @@ public class PEPService implements PubSubService { ...@@ -349,7 +349,7 @@ public class PEPService implements PubSubService {
// the notification. // the notification.
Map<String, HashSet<String>> filteredNodesMap = XMPPServer.getInstance().getIQPEPHandler().getFilteredNodesMap(); Map<String, HashSet<String>> filteredNodesMap = XMPPServer.getInstance().getIQPEPHandler().getFilteredNodesMap();
HashSet<String> filteredNodesSet = filteredNodesMap.get(recipientFullJID.toString()); HashSet<String> filteredNodesSet = filteredNodesMap.get(recipientFullJID.toString());
if (filteredNodesSet != null && !filteredNodesSet.contains(nodeIDPublishedTo)) { if (filteredNodesSet != null && !filteredNodesSet.contains(nodeIDPublishedTo + "+notify")) {
return; return;
} }
......
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