Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
f852091a
Commit
f852091a
authored
8 years ago
by
Gary Chapman
Browse files
Options
Downloads
Patches
Plain Diff
- Refactored to remove unnecessary addUsernameByIdAndMute method
- Completed setReadOnlyById to set/unset muted user array
parent
5b680c5e
Loading
Loading
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/rocketchat-channel-settings/server/models/Rooms.coffee
+14
-3
14 additions, 3 deletions
...es/rocketchat-channel-settings/server/models/Rooms.coffee
server/methods/joinRoom.coffee
+4
-4
4 additions, 4 deletions
server/methods/joinRoom.coffee
with
18 additions
and
7 deletions
packages/rocketchat-channel-settings/server/models/Rooms.coffee
+
14
−
3
View file @
f852091a
...
@@ -16,10 +16,21 @@ RocketChat.models.Rooms.setReadOnlyById = (_id, readOnly) ->
...
@@ -16,10 +16,21 @@ RocketChat.models.Rooms.setReadOnlyById = (_id, readOnly) ->
$set
:
$set
:
ro
:
readOnly
ro
:
readOnly
update
.
$set
.
muted
=
[]
if
readOnly
if
readOnly
users
=
@
findOne
(
query
,
{
fields
:
{
usernames
:
1
}})
?
.
usernames
# we want to mute all users without the post-read-only permission
else
update
.
$set
.
muted
=
[]
# get all usernames for this room
users
=
@
findOne
(
query
,
{
fields
:
{
usernames
:
1
}})
users
.
usernames
.
forEach
(
userName
)
->
# lookup the user
user
=
RocketChat
.
models
.
Users
.
findOneByUsername
userName
if
user
!=
null
and
RocketChat
.
authz
.
hasPermission
(
user
.
_id
,
'post-read-only'
)
is
false
update
.
$set
.
muted
.
push
userName
return
@
update
query
,
update
return
@
update
query
,
update
...
...
This diff is collapsed.
Click to expand it.
server/methods/joinRoom.coffee
+
4
−
4
View file @
f852091a
...
@@ -23,10 +23,10 @@ Meteor.methods
...
@@ -23,10 +23,10 @@ Meteor.methods
RocketChat
.
callbacks
.
run
'beforeJoinRoom'
,
user
,
room
RocketChat
.
callbacks
.
run
'beforeJoinRoom'
,
user
,
room
# Automatically mute users in read only rooms
# Automatically mute users in read only rooms
if
room
.
ro
and
not
RocketChat
.
authz
.
hasPermission
(
Meteor
.
userId
(),
'post-read-only'
)
RocketChat
.
models
.
Rooms
.
addUsernameByIdAndMute
rid
,
user
.
username
muted
=
room
.
ro
and
not
RocketChat
.
authz
.
hasPermission
(
Meteor
.
userId
(),
'post-read-only'
)
else
RocketChat
.
models
.
Rooms
.
addUsernameById
rid
,
user
.
username
RocketChat
.
models
.
Rooms
.
addUsernameById
rid
,
user
.
username
,
muted
RocketChat
.
models
.
Subscriptions
.
createWithRoomAndUser
room
,
user
,
RocketChat
.
models
.
Subscriptions
.
createWithRoomAndUser
room
,
user
,
ts
:
now
ts
:
now
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment