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 Jan 16, 2021
1 parent d210513 commit b8e18ab
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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.JiveConstants;
Expand Down Expand Up @@ -189,6 +191,14 @@ public boolean addMessage(Message message) {
return false;
}

// 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 b8e18ab

Please sign in to comment.