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 authored and guusdk committed Jan 19, 2022
1 parent 40d93cb commit d9cbf83
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ <h1>
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/125'>Issue #125</a>] - Combining keyword and date range makes search fail</li>
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/162'>Issue #162</a>] - Admin console pages should not break when not all cluster nodes have (the same) version of the plugin loaded</li>
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/163'>Issue #163</a>] - Migrate Jive Globals to System Properties</li>
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/184'>Issue #184</a>] - Do not archive messages that are rejected by blocklist</li>
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/190'>Issue #190</a>] - Allow code-update to force a reindexation</li>
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/192'>Issue #192</a>] - Combining keyword and participant(s) makes search fail</li>
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/195'>Issue #195</a>] - Class incompatibility with latest OF MUC</li>
Expand Down
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 d9cbf83

Please sign in to comment.