Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: take care on privacy/block lists #199

Merged
merged 1 commit into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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