powered by Jive Software

I've fixed a bug and created a patch. Can you commit it to SVN please?

Hi,

as I’ve already posted a few weeks ago in the Openfire Support forum, Openfire has a bug, when it comes to deleting roster items.

Currently Openfire behaves like this: If User A deletes Contact B on his roster, then User A is also deleted on Contact B’s roster.

This is due to this logic in IQRosterHandler.java:

roster.deleteRosterItem(item.getJID(), true);

// Forward set packet to the subscriber

if (localServer.isLocal(recipient)) { // Recipient is local so let’s handle it here

try {

Roster recipientRoster = userManager.getUser(recipient.getNode()).getRoster();

recipientRoster.deleteRosterItem(sender, true);

}

catch (UserNotFoundException e) {

// Do nothing

}

}

The correct way, however is to NOT delete User A on Contact B’s roster, but instead send presence stanzas of type “unsubscribe” or “unsubscribed”:

See http://xmpp.org/rfcs/rfc6121.html#roster-delete-success

I’ve fixed that behavior in org.jivesoftware.openfire.handler.IQRosterHandler:

// Instead of deleting the sender in the recipient’s roster, update it.

//recipientRoster.deleteRosterItem(sender, true);

RosterItem rosterItem = recipientRoster.getRosterItem(sender);

// If the receiver doesn’t have subscribed yet, delete the sender from the receiver’s roster, too.

if (rosterItem.getRecvStatus().equals(RosterItem.RECV_SUBSCRIBE)) {

recipientRoster.deleteRosterItem(sender, true);

}

// Otherwise only update it, so that the sender is not deleted from the receivers roster.

else {

rosterItem.setAskStatus(RosterItem.ASK_NONE);

rosterItem.setRecvStatus(RosterItem.RECV_NONE);

rosterItem.setSubStatus(RosterItem.SUB_NONE);

recipientRoster.updateRosterItem(rosterItem);

}

calling the updateRosterItem also automatically sends the “unsubscribe” and/or “unsubscribed” presences.

If the contact has not yet received the subscription, but the contact is deleted prior to receiving the subscription, just silently delete the item on the contact’s roster (since subscription requests are reflected in the roster).

I’ve also created a patch and tested it. Could someone with SVN access please apply it? Thanks!

Thanks, filed OF-720

Thanks! Hopefully somebody will review the patch and merge the code.