Skip to content
Snippets Groups Projects
Commit 1510a55c authored by cfaisy's avatar cfaisy
Browse files

fix(group): fix rocketchat hook

parent 6e47a311
No related branches found
No related tags found
1 merge request!542Resolve "Fix group members import functionality"
Pipeline #14032 passed
......@@ -637,17 +637,19 @@ if (Meteor.isServer && rcEnabled) {
Meteor.afterMethod('groups.addGroupMembersToGroup', function kcAddGroupMembersToGroup({ groupId, anotherGroupId }) {
if (!this.error) {
const group = Groups.findOne({ _id: groupId });
const group2 = Groups.findOne({ _id: anotherGroupId });
const users = Meteor.users.find({ _id: { $in: group2.members } });
const users = Meteor.users.find({ _id: { $in: group.members } });
users.forEach((user) => {
if (!Roles.userIsInRole(user._id, 'member', anotherGroupId)) {
rcClient.setRole(group2.slug, user.username, 'member', this.userId);
// remove candidate Role if present
if (Roles.userIsInRole(user._id, 'candidate', groupId)) {
rcClient.setRole(group2.slug, user.username, 'member', this.userId);
}
rcClient.ensureUser(user._id, this.userId).then((rcUser) => {
if (rcUser != null) {
const { username } = rcUser;
rcClient.setRole(group2.slug, username, 'member', this.userId);
}
});
}
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment