Skip to content

Commit

Permalink
fix: take care on privacy/block lists
Browse files Browse the repository at this point in the history
  • Loading branch information
mightymop committed Nov 16, 2021
1 parent 8a89508 commit babb505
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/java/org/jivesoftware/openfire/archive/ArchiveInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
import org.jivesoftware.openfire.interceptor.InterceptorManager;
import org.jivesoftware.openfire.interceptor.PacketInterceptor;
import org.jivesoftware.openfire.interceptor.PacketRejectedException;
import org.jivesoftware.openfire.privacy.PrivacyList;
import org.jivesoftware.openfire.privacy.PrivacyListManager;
import org.jivesoftware.openfire.session.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
Expand All @@ -42,6 +46,7 @@
public class ArchiveInterceptor implements PacketInterceptor {

private ConversationManager conversationManager;
private static final Logger Log = LoggerFactory.getLogger(ArchiveInterceptor.class);

public ArchiveInterceptor(ConversationManager conversationManager) {
this.conversationManager = conversationManager;
Expand All @@ -66,6 +71,16 @@ public void interceptPacket(Packet packet, Session session, boolean incoming, bo
if (message.getBody() != null) {
// Only process messages that are between two users, group chat rooms, or gateways.
if (conversationManager.isConversation(message)) {
//take care on blocklist
JID to = message.getTo();
if (to!=null)
{
final PrivacyList defaultPrivacyList = PrivacyListManager.getInstance().getDefaultPrivacyList(to.getNode());
if (defaultPrivacyList!=null&&defaultPrivacyList.shouldBlockPacket(message)) {
Log.debug( "Not storing message, as it is rejected by the default privacy list of the recipient ({}).", to.getNode() );
return;
}
}
// Process this event in the senior cluster member or local JVM when not in a cluster
if (ClusterManager.isSeniorClusterMember()) {
conversationManager.processMessage(message.getFrom(), message.getTo(), message.getBody(), message.toXML(), new Date());
Expand Down

0 comments on commit babb505

Please sign in to comment.