Skip to content

Commit

Permalink
OF-2189: Do not store offline if on blocklist.
Browse files Browse the repository at this point in the history
Messages that arrive for offline users should not be stored in their offline message store, if the message would have been blocked if the intended recipient would have been online.
  • Loading branch information
guusdk committed Jun 27, 2023
1 parent aa6a417 commit 7d3ed5d
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.jivesoftware.openfire.container.BasicModule;
import org.jivesoftware.openfire.event.UserEventDispatcher;
import org.jivesoftware.openfire.event.UserEventListener;
import org.jivesoftware.openfire.privacy.PrivacyList;
import org.jivesoftware.openfire.privacy.PrivacyListManager;
import org.jivesoftware.openfire.user.User;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.util.*;
Expand Down Expand Up @@ -173,6 +175,14 @@ public OfflineMessage addMessage(Message message) {
return null;
}

// If the sender of the message is on the user's default privacy list, don't store (OF-2189). Note that we're
// processing messages sent to an offline user, so an active privacy list does not apply.
final PrivacyList defaultPrivacyList = PrivacyListManager.getInstance().getDefaultPrivacyList(username);
if (defaultPrivacyList.shouldBlockPacket(message)) {
Log.trace( "Not storing message, as it is rejected by the default privacy list of the recipient ({}).", recipient );
return false;
}

long messageID = SequenceManager.nextID(JiveConstants.OFFLINE);

// Get the message in XML format.
Expand Down

0 comments on commit 7d3ed5d

Please sign in to comment.