Commit 0b5b16e4 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Modified to keep extensions sent together with the group chat room invitation. JM-135


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@903 b35dd754-fafc-0310-a699-88a17e54d16e
parent 90a76802
...@@ -15,6 +15,7 @@ import java.util.List; ...@@ -15,6 +15,7 @@ import java.util.List;
import java.util.Date; import java.util.Date;
import java.util.Collection; import java.util.Collection;
import org.dom4j.Element;
import org.jivesoftware.messenger.muc.spi.IQAdminHandler; import org.jivesoftware.messenger.muc.spi.IQAdminHandler;
import org.jivesoftware.messenger.muc.spi.IQOwnerHandler; import org.jivesoftware.messenger.muc.spi.IQOwnerHandler;
import org.jivesoftware.util.NotFoundException; import org.jivesoftware.util.NotFoundException;
...@@ -824,9 +825,11 @@ public interface MUCRoom extends ChatDeliverer { ...@@ -824,9 +825,11 @@ public interface MUCRoom extends ChatDeliverer {
* @param to the JID of the user that is being invited. * @param to the JID of the user that is being invited.
* @param reason the reason of the invitation or null if none. * @param reason the reason of the invitation or null if none.
* @param role the role of the occupant that sent the invitation. * @param role the role of the occupant that sent the invitation.
* @param extensions the list of extensions sent with the original message invitation or null
* if none.
* @throws ForbiddenException If the user is not allowed to send the invitation. * @throws ForbiddenException If the user is not allowed to send the invitation.
*/ */
public void sendInvitation(JID to, String reason, MUCRole role) public void sendInvitation(JID to, String reason, MUCRole role, List<Element> extensions)
throws ForbiddenException; throws ForbiddenException;
/** /**
......
...@@ -243,7 +243,7 @@ public class IQAdminHandler { ...@@ -243,7 +243,7 @@ public class IQAdminHandler {
// If the user had an affiliation don't send an invitation. Otherwise // If the user had an affiliation don't send an invitation. Otherwise
// send an invitation if the room is members-only // send an invitation if the room is members-only
if (!hadAffiliation && room.isMembersOnly()) { if (!hadAffiliation && room.isMembersOnly()) {
room.sendInvitation(jid, null, senderRole); room.sendInvitation(jid, null, senderRole, null);
} }
} }
else if ("outcast".equals(target)) { else if ("outcast".equals(target)) {
......
...@@ -252,7 +252,7 @@ public class IQOwnerHandler { ...@@ -252,7 +252,7 @@ public class IQOwnerHandler {
// If the user had an affiliation don't send an invitation. Otherwise // If the user had an affiliation don't send an invitation. Otherwise
// send an invitation if the room is members-only // send an invitation if the room is members-only
if (!hadAffiliation && room.isMembersOnly()) { if (!hadAffiliation && room.isMembersOnly()) {
room.sendInvitation(new JID(bareJID), null, senderRole); room.sendInvitation(new JID(bareJID), null, senderRole, null);
} }
} }
else if ("none".equals(targetAffiliation)) { else if ("none".equals(targetAffiliation)) {
......
...@@ -1292,7 +1292,7 @@ public class MUCRoomImpl implements MUCRoom { ...@@ -1292,7 +1292,7 @@ public class MUCRoomImpl implements MUCRoom {
this.subject = subject; this.subject = subject;
} }
public void sendInvitation(JID to, String reason, MUCRole senderRole) public void sendInvitation(JID to, String reason, MUCRole senderRole, List<Element> extensions)
throws ForbiddenException { throws ForbiddenException {
if (!isMembersOnly() || canOccupantsInvite() if (!isMembersOnly() || canOccupantsInvite()
|| MUCRole.ADMINISTRATOR == senderRole.getAffiliation() || MUCRole.ADMINISTRATOR == senderRole.getAffiliation()
...@@ -1302,6 +1302,13 @@ public class MUCRoomImpl implements MUCRoom { ...@@ -1302,6 +1302,13 @@ public class MUCRoomImpl implements MUCRoom {
Message message = new Message(); Message message = new Message();
message.setFrom(role.getRoleAddress()); message.setFrom(role.getRoleAddress());
message.setTo(to); message.setTo(to);
// Add a list of extensions sent with the original message invitation (if any)
if (extensions != null) {
for(Element element : extensions) {
element.setParent(null);
message.getElement().add(element);
}
}
Element frag = message.addChildElement("x", "http://jabber.org/protocol/muc#user"); Element frag = message.addChildElement("x", "http://jabber.org/protocol/muc#user");
// ChatUser will be null if the room itself (ie. via admin console) made the request // ChatUser will be null if the room itself (ie. via admin console) made the request
if (senderRole.getChatUser() != null) { if (senderRole.getChatUser() != null) {
......
...@@ -230,10 +230,16 @@ public class MUCUserImpl implements MUCUser { ...@@ -230,10 +230,16 @@ public class MUCUserImpl implements MUCUser {
room.lock.writeLock().unlock(); room.lock.writeLock().unlock();
} }
} }
// Try to keep the list of extensions sent together with the
// message invitation. These extensions will be sent to the
// invitee.
List<Element> extensions = new ArrayList<Element>(packet
.getElement().elements());
extensions.remove(userInfo);
// Send the invitation to the user // Send the invitation to the user
room.sendInvitation(new JID(info.attributeValue("to")), room.sendInvitation(new JID(info.attributeValue("to")),
info.elementTextTrim("reason"), role); info.elementTextTrim("reason"), role, extensions);
} }
else if (userInfo != null else if (userInfo != null
&& userInfo.element("decline") != null) { && userInfo.element("decline") != null) {
......
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