diff --git a/changelog.html b/changelog.html
index f18d3e870..5f0c02cd7 100644
--- a/changelog.html
+++ b/changelog.html
@@ -44,6 +44,12 @@
REST API Plugin Changelog
+1.9.1 (tbd)
+
+ - [#148] - Example of MUC invite contains escaped characters
+ - [#146] - Chatroom 'affiliation' URL template clash
+
+
1.9.0 August 4, 2022
- [#141] - Remove boilerplate code for managing MUC room affiliations
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/controller/MUCRoomController.java b/src/java/org/jivesoftware/openfire/plugin/rest/controller/MUCRoomController.java
index 149f8f0b3..2ac5df31b 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/controller/MUCRoomController.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/controller/MUCRoomController.java
@@ -550,18 +550,18 @@ public MUCRoomMessageEntities getRoomHistory(String roomName, String serviceName
* the service name
* @param roomName
* the room name
- * @param mucInvitationEntity
+ * @param mucInvitationsEntity
* the invitation entity containing invitation reason and jids to invite
* @throws ServiceException
* the service exception
*/
- public void inviteUsersAndOrGroups(String serviceName, String roomName, MUCInvitationEntity mucInvitationEntity)
+ public void inviteUsersAndOrGroups(String serviceName, String roomName, MUCInvitationsEntity mucInvitationsEntity)
throws ServiceException {
MUCRoom room = getRoom(serviceName, roomName);
// First determine where to send all the invitations
Set targetJIDs = new HashSet<>();
- for (String jidString : mucInvitationEntity.getJidsToInvite()) {
+ for (String jidString : mucInvitationsEntity.getJidsToInvite()) {
JID jid = UserUtils.checkAndGetJID(jidString);
// Is it a group? Then unpack and send to every single group member.
Group g = UserUtils.getGroupIfIsGroup(jid);
@@ -575,7 +575,7 @@ public void inviteUsersAndOrGroups(String serviceName, String roomName, MUCInvit
// And now send
for (JID jid : targetJIDs) {
try {
- room.sendInvitation(jid, mucInvitationEntity.getReason(), room.getRole(), null);
+ room.sendInvitation(jid, mucInvitationsEntity.getReason(), room.getRole(), null);
} catch (ForbiddenException | CannotBeInvitedException e) {
throw new ServiceException("Could not invite user", jid.toString(), ExceptionType.NOT_ALLOWED, Response.Status.FORBIDDEN, e);
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCInvitationEntity.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCInvitationEntity.java
index 81cb4f4dd..907daa31c 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCInvitationEntity.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCInvitationEntity.java
@@ -16,22 +16,16 @@
package org.jivesoftware.openfire.plugin.rest.entity;
-import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
-import java.util.ArrayList;
-import java.util.List;
@XmlRootElement(name = "mucInvitation")
public class MUCInvitationEntity {
String reason;
- private List jidsToInvite;
-
public MUCInvitationEntity() {
}
@@ -44,19 +38,4 @@ public String getReason() {
public void setReason(String reason) {
this.reason = reason;
}
-
- @XmlElementWrapper(name = "jidsToInvite")
- @XmlElement(name = "jid")
- @JsonProperty(value = "jidsToInvite")
- @Schema(description = "The JIDs and/or names of the users and groups to invite into the room", example = "jane@example.org")
- public List getJidsToInvite() {
- if (jidsToInvite == null) {
- jidsToInvite = new ArrayList<>();
- }
- return jidsToInvite;
- }
-
- public void setJidsToInvite(List jidsToInvite) {
- this.jidsToInvite = jidsToInvite;
- }
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCInvitationsEntity.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCInvitationsEntity.java
new file mode 100644
index 000000000..d0d3a7b9e
--- /dev/null
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCInvitationsEntity.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2022.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jivesoftware.openfire.plugin.rest.entity;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
+import java.util.List;
+
+@XmlRootElement(name = "mucInvitations")
+public class MUCInvitationsEntity extends MUCInvitationEntity
+{
+ public MUCInvitationsEntity() {
+ super();
+ }
+
+ private List jidsToInvite;
+
+ @XmlElementWrapper(name = "jidsToInvite")
+ @XmlElement(name = "jid")
+ @JsonProperty(value = "jidsToInvite")
+ @Schema(description = "The JIDs and/or names of the users and groups to invite into the room")
+ public List getJidsToInvite() {
+ if (jidsToInvite == null) {
+ jidsToInvite = new ArrayList<>();
+ }
+ return jidsToInvite;
+ }
+
+ public void setJidsToInvite(List jidsToInvite) {
+ this.jidsToInvite = jidsToInvite;
+ }
+
+}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/service/MUCRoomAffiliationsService.java b/src/java/org/jivesoftware/openfire/plugin/rest/service/MUCRoomAffiliationsService.java
index 86d2425c9..340de8443 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/service/MUCRoomAffiliationsService.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/service/MUCRoomAffiliationsService.java
@@ -39,7 +39,7 @@
import java.util.List;
import java.util.stream.Collectors;
-@Path("restapi/v1/chatrooms/{roomName}/{affiliation}")
+@Path("restapi/v1/chatrooms/{roomName}/{affiliation: (admins|members|outcasts|owners)}")
@Tag(name = "Chat room", description = "Managing Multi-User chat rooms.")
public class MUCRoomAffiliationsService
{
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/service/MUCRoomService.java b/src/java/org/jivesoftware/openfire/plugin/rest/service/MUCRoomService.java
index 44bd24b3f..b154ec0db 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/service/MUCRoomService.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/service/MUCRoomService.java
@@ -240,10 +240,12 @@ public Response inviteUserOrGroupToMUCRoom(
@RequestBody(description = "The invitation message to send and whom to send it to.", required = true) MUCInvitationEntity mucInvitationEntity)
throws ServiceException
{
- if (!mucInvitationEntity.getJidsToInvite().contains(jid)) {
- mucInvitationEntity.getJidsToInvite().add(jid);
+ final MUCInvitationsEntity multiple = new MUCInvitationsEntity();
+ multiple.setReason(mucInvitationEntity.getReason());
+ if (!multiple.getJidsToInvite().contains(jid)) {
+ multiple.getJidsToInvite().add(jid);
}
- MUCRoomController.getInstance().inviteUsersAndOrGroups(serviceName, roomName, mucInvitationEntity);
+ MUCRoomController.getInstance().inviteUsersAndOrGroups(serviceName, roomName, multiple);
return Response.status(Status.OK).build();
}
@@ -262,10 +264,10 @@ public Response inviteUserOrGroupToMUCRoom(
public Response inviteUsersAndOrGroupsToMUCRoom(
@Parameter(description = "The name of the chat room in which to invite a user or group", example = "lobby", required = true) @PathParam("roomName") String roomName,
@Parameter(description = "The name of the chat room's MUC service.", example = "conference", required = false) @DefaultValue("conference") @QueryParam("servicename") String serviceName,
- @RequestBody(description = "The invitation message to send and whom to send it to.", required = true) MUCInvitationEntity mucInvitationEntity)
+ @RequestBody(description = "The invitation message to send and whom to send it to.", required = true) MUCInvitationsEntity mucInvitationsEntity)
throws ServiceException
{
- MUCRoomController.getInstance().inviteUsersAndOrGroups(serviceName, roomName, mucInvitationEntity);
+ MUCRoomController.getInstance().inviteUsersAndOrGroups(serviceName, roomName, mucInvitationsEntity);
return Response.status(Status.OK).build();
}