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

Fix #857 Cannot add user to room. #860

Merged
merged 1 commit into from
Sep 23, 2015
Merged
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
10 changes: 8 additions & 2 deletions server/methods/addUserToRoom.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
Meteor.methods
addUserToRoom: (data) ->
fromId = Meteor.userId()
# console.log '[methods] addUserToRoom -> '.green, 'fromId:', fromId, 'data:', data
console.log '[methods] addUserToRoom -> '.green, 'data:', data

unless Match.test data?.rid, String
throw new Meteor.Error 'invalid-rid'

unless Match.test data?.username, String
throw new Meteor.Error 'invalid-username'

room = RocketChat.models.Rooms.findOneById data.rid

Expand All @@ -13,7 +19,7 @@ Meteor.methods
if room.usernames.indexOf(data.username) isnt -1
return

newUser = RocketChat.models.Users.findOneByUsername username: data.username
newUser = RocketChat.models.Users.findOneByUsername data.username

RocketChat.models.Rooms.addUsernameById data.rid, data.username

Expand Down