Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use user group with roles on create/update chat room. #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,13 @@ public MUCRoomEntity convertToMUCRoomEntity(MUCRoom room, boolean expand) {
private void setRoles(MUCRoom room, MUCRoomEntity mucRoomEntity) throws ForbiddenException, NotAllowedException,
ConflictException {
List<JID> roles = new ArrayList<JID>();
Collection<JID> owners = new ArrayList<JID>();
Collection<JID> existingOwners = new ArrayList<JID>();
List<JID> mucRoomEntityOwners = new ArrayList<JID>();

List<JID> mucRoomEntityOwners = MUCRoomUtils.convertStringsToJIDs(mucRoomEntity.getOwners());
owners.addAll(room.getOwners());
for (String ownerJid : mucRoomEntity.getOwners()) {
mucRoomEntityOwners.add(UserUtils.checkAndGetJID(ownerJid));
}
Collection<JID> owners = new ArrayList<JID>(room.getOwners());

// Find same owners
for (JID jid : owners) {
Expand All @@ -528,7 +530,6 @@ private void setRoles(MUCRoom room, MUCRoomEntity mucRoomEntity) throws Forbidde

// Don't delete the same owners
owners.removeAll(existingOwners);
room.addOwners(MUCRoomUtils.convertStringsToJIDs(mucRoomEntity.getOwners()), room.getRole());

// Collect all roles to reset
roles.addAll(owners);
Expand All @@ -540,18 +541,22 @@ private void setRoles(MUCRoom room, MUCRoomEntity mucRoomEntity) throws Forbidde
room.addNone(jid, room.getRole());
}

room.addOwners(MUCRoomUtils.convertStringsToJIDs(mucRoomEntity.getOwners()), room.getRole());
for (String ownerJid : mucRoomEntity.getOwners()) {
room.addOwner(UserUtils.checkAndGetJID(ownerJid), room.getRole());
}
if (mucRoomEntity.getAdmins() != null) {
room.addAdmins(MUCRoomUtils.convertStringsToJIDs(mucRoomEntity.getAdmins()), room.getRole());
for (String adminJid : mucRoomEntity.getAdmins()) {
room.addAdmin(UserUtils.checkAndGetJID(adminJid), room.getRole());
}
}
if (mucRoomEntity.getMembers() != null) {
for (String memberJid : mucRoomEntity.getMembers()) {
room.addMember(new JID(memberJid), null, room.getRole());
room.addMember(UserUtils.checkAndGetJID(memberJid), null, room.getRole());
}
}
if (mucRoomEntity.getOutcasts() != null) {
for (String outcastJid : mucRoomEntity.getOutcasts()) {
room.addOutcast(new JID(outcastJid), null, room.getRole());
room.addOutcast(UserUtils.checkAndGetJID(outcastJid), null, room.getRole());
}
}
}
Expand Down