Commit d712c2d7 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

1. User interceptors should only be applied to local users. JM-582

2. Small optimization

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3507 b35dd754-fafc-0310-a699-88a17e54d16e
parent 7a12660f
......@@ -11,11 +11,15 @@
package org.jivesoftware.wildfire.interceptor;
import org.jivesoftware.wildfire.Session;
import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.Session;
import org.jivesoftware.wildfire.XMPPServer;
import org.xmpp.packet.Packet;
import java.util.*;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
......@@ -38,6 +42,7 @@ public class InterceptorManager {
private static InterceptorManager instance = new InterceptorManager();
private XMPPServer server = XMPPServer.getInstance();
private List<PacketInterceptor> globalInterceptors =
new CopyOnWriteArrayList<PacketInterceptor>();
private Map<String, List<PacketInterceptor>> usersInterceptors =
......@@ -236,8 +241,12 @@ public class InterceptorManager {
}
}
// Invoke the interceptors that are related to the address of the session
if (usersInterceptors.isEmpty()) {
// Do nothing
return;
}
String username = session.getAddress().getNode();
if (username != null) {
if (username != null && server.isLocal(session.getAddress())) {
Collection<PacketInterceptor> userInterceptors = usersInterceptors.get(username);
if (userInterceptors != null && !userInterceptors.isEmpty()) {
for (PacketInterceptor interceptor : userInterceptors) {
......
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