Skip to content
Snippets Groups Projects
Unverified Commit 38685683 authored by Marcelo Schmidt's avatar Marcelo Schmidt
Browse files

Change post-read-only to post-readonly and create set-readonly;

parent ed80ab56
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,6 @@ Meteor.startup ->
{ _id: 'manage-integrations', roles : ['admin'] }
{ _id: 'manage-own-integrations', roles : ['admin', 'bot'] }
{ _id: 'manage-oauth-apps', roles : ['admin'] }
{ _id: 'post-read-only', roles : ['admin', 'moderator', 'owner'] }
{ _id: 'mention-all', roles : ['admin', 'owner', 'moderator', 'user'] }
{ _id: 'mute-user', roles : ['admin', 'owner', 'moderator'] }
{ _id: 'remove-user', roles : ['admin', 'owner', 'moderator'] }
......
......@@ -17,14 +17,14 @@ RocketChat.models.Rooms.setReadOnlyById = (_id, readOnly) ->
ro: readOnly
if readOnly
# we want to mute all users without the post-read-only permission
# we want to mute all users without the post-readonly permission
usernames = @findOne(query, { fields: { usernames: 1 }})
users = RocketChat.models.Users.findUsersByUsernames usernames?.usernames, {fields: {username: 1}}
users.forEach (user) ->
if RocketChat.authz.hasPermission(user._id, 'post-read-only') is false
if RocketChat.authz.hasPermission(user._id, 'post-readonly') is false
# create a new array if necessary
update.$set.muted = [] if !update.$set.muted
update.$set.muted = [] if !update.$set.muted
update.$set.muted.push user.username
else
# remove the muted user array
......
Meteor.startup(function() {
RocketChat.models.Permissions.upsert('post-readonly', {$set: { roles: ['admin', 'owner', 'moderator'] } });
RocketChat.models.Permissions.upsert('set-readonly', {$set: { roles: ['admin', 'owner'] } });
});
......@@ -12,7 +12,7 @@ RocketChat.addUserToRoom = function(rid, user, inviter, silenced) {
RocketChat.callbacks.run('beforeJoinRoom', user, room);
}
var muted = room.ro && !RocketChat.authz.hasPermission(user._id, 'post-read-only');
var muted = room.ro && !RocketChat.authz.hasPermission(user._id, 'post-readonly');
RocketChat.models.Rooms.addUsernameById(rid, user.username, muted);
RocketChat.models.Subscriptions.createWithRoomAndUser(room, user, {
ts: now,
......
......@@ -66,8 +66,8 @@ RocketChat.createRoom = function(type, name, owner, members, readOnly) {
continue;
}
// make all room members muted by default, unless they have the post-read-only permission
if (readOnly === true && !RocketChat.authz.hasPermission(member._id, 'post-read-only')) {
// make all room members muted by default, unless they have the post-readonly permission
if (readOnly === true && !RocketChat.authz.hasPermission(member._id, 'post-readonly')) {
RocketChat.models.Rooms.muteUsernameByRoomId(room._id, username);
}
......
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