Commit 9907cf12 authored by Daryl Herzmann's avatar Daryl Herzmann Committed by akrherz

OF-140 Add a system property to disable the auto invitation of newly

added members to a chatroom. (xmpp.muc.skipInvite).  Default behaviour
follows the spec and invites (xmpp.muc.skipInvite is false).


git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@11682 b35dd754-fafc-0310-a699-88a17e54d16e
parent c46e77de
...@@ -31,6 +31,7 @@ import org.jivesoftware.openfire.muc.ForbiddenException; ...@@ -31,6 +31,7 @@ import org.jivesoftware.openfire.muc.ForbiddenException;
import org.jivesoftware.openfire.muc.MUCRole; import org.jivesoftware.openfire.muc.MUCRole;
import org.jivesoftware.openfire.muc.NotAllowedException; import org.jivesoftware.openfire.muc.NotAllowedException;
import org.jivesoftware.openfire.user.UserNotFoundException; import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.util.JiveGlobals;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.PacketError; import org.xmpp.packet.PacketError;
...@@ -50,9 +51,12 @@ public class IQAdminHandler { ...@@ -50,9 +51,12 @@ public class IQAdminHandler {
private PacketRouter router; private PacketRouter router;
private boolean skipInvite;
public IQAdminHandler(LocalMUCRoom chatroom, PacketRouter packetRouter) { public IQAdminHandler(LocalMUCRoom chatroom, PacketRouter packetRouter) {
this.room = chatroom; this.room = chatroom;
this.router = packetRouter; this.router = packetRouter;
this.skipInvite = JiveGlobals.getBooleanProperty("xmpp.muc.skipInvite", false);
} }
/** /**
...@@ -245,8 +249,9 @@ public class IQAdminHandler { ...@@ -245,8 +249,9 @@ public class IQAdminHandler {
boolean hadAffiliation = room.getAffiliation(jid.toBareJID()) != MUCRole.Affiliation.none; boolean hadAffiliation = room.getAffiliation(jid.toBareJID()) != MUCRole.Affiliation.none;
presences.addAll(room.addMember(jid, nick, senderRole)); presences.addAll(room.addMember(jid, nick, senderRole));
// 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 and skipping invites
if (!hadAffiliation && room.isMembersOnly()) { // are not disabled system-wide xmpp.muc.skipInvite
if (!skipInvite && !hadAffiliation && room.isMembersOnly()) {
room.sendInvitation(jid, null, senderRole, null); room.sendInvitation(jid, null, senderRole, null);
} }
} else if ("outcast".equals(target)) { } else if ("outcast".equals(target)) {
...@@ -279,4 +284,4 @@ public class IQAdminHandler { ...@@ -279,4 +284,4 @@ public class IQAdminHandler {
} }
} }
} }
} }
\ No newline at end of file
...@@ -36,6 +36,7 @@ import org.jivesoftware.openfire.muc.ForbiddenException; ...@@ -36,6 +36,7 @@ import org.jivesoftware.openfire.muc.ForbiddenException;
import org.jivesoftware.openfire.muc.MUCRole; import org.jivesoftware.openfire.muc.MUCRole;
import org.jivesoftware.openfire.muc.cluster.RoomUpdatedEvent; import org.jivesoftware.openfire.muc.cluster.RoomUpdatedEvent;
import org.jivesoftware.openfire.user.UserNotFoundException; import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils; import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.cache.CacheFactory; import org.jivesoftware.util.cache.CacheFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -67,9 +68,13 @@ public class IQOwnerHandler { ...@@ -67,9 +68,13 @@ public class IQOwnerHandler {
private Element probeResult; private Element probeResult;
private boolean skipInvite;
public IQOwnerHandler(LocalMUCRoom chatroom, PacketRouter packetRouter) { public IQOwnerHandler(LocalMUCRoom chatroom, PacketRouter packetRouter) {
this.room = chatroom; this.room = chatroom;
this.router = packetRouter; this.router = packetRouter;
this.skipInvite = JiveGlobals.getBooleanProperty(
"xmpp.muc.skipInvite", false);
init(); init();
} }
...@@ -268,8 +273,9 @@ public class IQOwnerHandler { ...@@ -268,8 +273,9 @@ public class IQOwnerHandler {
boolean hadAffiliation = room.getAffiliation(jid.toBareJID()) != MUCRole.Affiliation.none; boolean hadAffiliation = room.getAffiliation(jid.toBareJID()) != MUCRole.Affiliation.none;
presences.addAll(room.addMember(jid, null, senderRole)); presences.addAll(room.addMember(jid, null, senderRole));
// 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 and skipping invites
if (!hadAffiliation && room.isMembersOnly()) { // are not disabled system-wide xmpp.muc.skipInvite
if (!skipInvite && !hadAffiliation && room.isMembersOnly()) {
room.sendInvitation(jid, null, senderRole, null); room.sendInvitation(jid, null, senderRole, null);
} }
} else if ("none".equals(targetAffiliation)) { } else if ("none".equals(targetAffiliation)) {
...@@ -766,4 +772,4 @@ public class IQOwnerHandler { ...@@ -766,4 +772,4 @@ public class IQOwnerHandler {
probeResult = element; probeResult = element;
probeResult.add(configurationForm.getElement()); probeResult.add(configurationForm.getElement());
} }
} }
\ No newline at end of file
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