Commit f2386cce authored by Christian Schudt's avatar Christian Schudt

Include correct affiliation and role after revoking MUC membership.

Previous stanza had status code 321 (membership revoked), but still had the owner and role set to the old role:
affiliation="owner" role="moderator"

Now it is the correct role after revoking membership:
affiliation="none" role="none"
parent 2746a7f4
...@@ -163,6 +163,12 @@ public class LocalMUCRole implements MUCRole { ...@@ -163,6 +163,12 @@ public class LocalMUCRole implements MUCRole {
this.presence = newPresence; this.presence = newPresence;
this.presence.setFrom(getRoleAddress()); this.presence.setFrom(getRoleAddress());
if (extendedInformation != null) { if (extendedInformation != null) {
// Remove any previous extendedInformation, then re-add it.
Element mucUser = presence.getElement().element(QName.get("x", "http://jabber.org/protocol/muc#user"));
if (mucUser != null) {
// Remove any previous extendedInformation, then re-add it.
presence.getElement().remove(mucUser);
}
Element exi = extendedInformation.createCopy(); Element exi = extendedInformation.createCopy();
presence.getElement().add(exi); presence.getElement().add(exi);
} }
......
...@@ -1377,6 +1377,8 @@ public class LocalMUCRoom implements MUCRoom, GroupEventListener { ...@@ -1377,6 +1377,8 @@ public class LocalMUCRoom implements MUCRoom, GroupEventListener {
if (role.isLocal()) { if (role.isLocal()) {
role.setAffiliation(newAffiliation); role.setAffiliation(newAffiliation);
role.setRole(newRole); role.setRole(newRole);
// Set the new presence, so that the updated affiliation and role is reflected in the presence stanza.
role.setPresence(role.getPresence());
// Notify the other cluster nodes to update the occupant // Notify the other cluster nodes to update the occupant
CacheFactory.doClusterTask(new UpdateOccupant(this, role)); CacheFactory.doClusterTask(new UpdateOccupant(this, role));
// Prepare a new presence to be sent to all the room occupants // Prepare a new presence to be sent to all the room occupants
...@@ -1868,35 +1870,35 @@ public class LocalMUCRoom implements MUCRoom, GroupEventListener { ...@@ -1868,35 +1870,35 @@ public class LocalMUCRoom implements MUCRoom, GroupEventListener {
public boolean isManuallyLocked() { public boolean isManuallyLocked() {
return lockedTime > 0 && creationDate.getTime() != lockedTime; return lockedTime > 0 && creationDate.getTime() != lockedTime;
} }
/** /**
* Handles occupants updating their presence in the chatroom. Assumes the user updates their presence whenever their * Handles occupants updating their presence in the chatroom. Assumes the user updates their presence whenever their
* availability in the room changes. This method should not be called to handle other presence related updates, such * availability in the room changes. This method should not be called to handle other presence related updates, such
* as nickname changes. * as nickname changes.
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public void presenceUpdated(final MUCRole occupantRole, final Presence newPresence) { public void presenceUpdated(final MUCRole occupantRole, final Presence newPresence) {
final String occupantNickName = occupantRole.getNickname(); final String occupantNickName = occupantRole.getNickname();
// Update the presence of the occupant on the local node with the occupant's new availability. Updates the // Update the presence of the occupant on the local node with the occupant's new availability. Updates the
// local node first so the remote nodes receive presence that correctly reflects the occupant's new // local node first so the remote nodes receive presence that correctly reflects the occupant's new
// availability and previously existing role and affiliation with the room. // availability and previously existing role and affiliation with the room.
final UpdatePresence localUpdateRequest = new UpdatePresence(this, newPresence.createCopy(), occupantNickName); final UpdatePresence localUpdateRequest = new UpdatePresence(this, newPresence.createCopy(), occupantNickName);
localUpdateRequest.setOriginator(true); localUpdateRequest.setOriginator(true);
localUpdateRequest.run(); localUpdateRequest.run();
// Get the new, updated presence for the occupant in the room. The presence reflects the occupant's updated // Get the new, updated presence for the occupant in the room. The presence reflects the occupant's updated
// availability and their existing association. // availability and their existing association.
final Presence updatedPresence = occupantRole.getPresence().createCopy(); final Presence updatedPresence = occupantRole.getPresence().createCopy();
// Ask other cluster nodes to update the presence of the occupant. Uses the updated presence from the local // Ask other cluster nodes to update the presence of the occupant. Uses the updated presence from the local
// MUC role. // MUC role.
final UpdatePresence clusterUpdateRequest = new UpdatePresence(this, updatedPresence, occupantNickName); final UpdatePresence clusterUpdateRequest = new UpdatePresence(this, updatedPresence, occupantNickName);
CacheFactory.doClusterTask(clusterUpdateRequest); CacheFactory.doClusterTask(clusterUpdateRequest);
// Broadcast updated presence of occupant. // Broadcast updated presence of occupant.
broadcastPresence(updatedPresence, false); broadcastPresence(updatedPresence, false);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment